exactRLRT               package:RLRsim               R Documentation

_R_e_s_t_r_i_c_t_e_d _L_i_k_e_l_i_h_o_o_d _R_a_t_i_o _T_e_s_t_s _f_o_r _l_i_n_e_a_r _m_i_x_e_d _m_o_d_e_l_s

_D_e_s_c_r_i_p_t_i_o_n:

     This function provides an (exact) restricted likelihood ratio test
     based on simulated values from the finite sample distribution for
     testing whether the variance of a random effect is 0 in a linear
     mixed model with known correlation structure of the tested random
     effect and i.i.d. errors.

_U_s_a_g_e:

     exactRLRT(m, mA = NULL, m0 = NULL, seed = NA, nsim = 10000,
              log.grid.hi = 8, log.grid.lo = -10, gridlength = 200, print.p = TRUE,
              return.sample = FALSE, ...)

_A_r_g_u_m_e_n_t_s:

       m: The fitted model under the alternative or, for testing in
          models with multiple variance components, the reduced model
          containing only the random effect to be tested (see Details),
          an 'lme', 'lmer' or  'spm' object

      mA: The full model under the alternative for testing in models
          with multiple variance components

      m0: The model under the null for testing in models with multiple
          variance components

    seed: input for 'set.seed'

    nsim: Number of values to simulate

log.grid.hi: Lower value of the grid on the log scale. See 'exactRLRT'. 

log.grid.lo: Lower value of the grid on the log scale. See 'exactRLRT'. 

gridlength: Length of the grid. See 'exactLRT'.  

 print.p: print table with observed variance ratio, observed test
          statistic -2log RLR and p-value?

return.sample: return simulated sample?

     ...: Further parameters to be passed to 'RLRTSim'.

_D_e_t_a_i_l_s:

     Tests in models with only a single variance component require only
     the first argument 'm'. For testing in models with multiple
     variance components, 'm' contains only the random effect whose
     variance is to be tested, while 'mA' and 'm0' are the models under
     the alternative and the null, respectively. For models with a
     single variance component, the simulated distribution is exact if
     the number of parameters (fixed and random) is smaller than the
     number of observations. For models with multiple components,
     theoretical results are still outstanding. Fairly extensive
     simulation studies suggest that the application of the test is
     safe and the simulated distribution is correct as long as the
     number of parameters (fixed and random) is smaller than the number
     of observations and the nuisance variance components are not
     superfluous or very small. The exact finite sample distribution of
     the restricted likelihood ratio test statistic that is simulated
     from was derived by Crainiceanu & Ruppert (2004).

_V_a_l_u_e:

     If 'return.sample = FALSE', the p-value. Else a list with
     components 

       p: p-value for the observed test statistic

  sample: the simulated sample of test statistics under the null

_A_u_t_h_o_r(_s):

     Fabian Scheipl

_R_e_f_e_r_e_n_c_e_s:

     Crainiceanu, C. and Ruppert, D. (2004) Likelihood ratio tests in
     linear mixed models with one variance component, _Journal of the
     Royal Statistical Society: Series B_,*66*,165-185.

_S_e_e _A_l_s_o:

     'RLRTSim' for the underlying simulation algorithm; 'exactLRT' for
     likelihood based tests

_E_x_a_m_p_l_e_s:

     library(lme4)
     data(sleepstudy)
     mA <- lmer(Reaction ~ I(Days-4.5) + (1|Subject) + (0 + I(Days-4.5)|Subject), sleepstudy)
     m0 <- update(mA, . ~ . - (0 + I(Days-4.5)|Subject))
     m.slope  <- update(mA, . ~ . - (1|Subject))
     #test for subject specific slopes:
     exactRLRT(m.slope, mA, m0)

     detach(package:lme4) #avoid conflicts
     library(mgcv)
     data(trees)
     #test quadratic trend vs. smooth alternative
     m.q<-gamm(I(log(Volume)) ~ Height + s(Girth, m = 3), data = trees, method = "REML")$lme
     exactRLRT(m.q)
     #test linear trend vs. smooth alternative
     m.l<-gamm(I(log(Volume)) ~ Height + s(Girth, m = 2), data = trees, method = "REML")$lme
     exactRLRT(m.l)

