LRTSim                package:RLRsim                R Documentation

_S_i_m_u_l_a_t_i_o_n _o_f _t_h_e (_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 _S_t_a_t_i_s_t_i_c

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

     These functions simulate values from the (exact) finite sample
     distribution of the (restricted) likelihood ratio statistic for
     testing the presence of the variance component (and restrictions
     of the fixed effects) in a simple linear mixed model with known
     correlation structure of the random effect and i.i.d. errors. They
     are usually called by 'exactLRT' or 'exactRLRT'.

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

     LRTSim(X, Z, q, sqrt.Sigma, seed = NA, nsim = 5000, log.grid.hi = 8,
            log.grid.lo=-10, gridlength=200)
     RLRTSim(X, Z, sqrt.Sigma, lambda0 = NA, seed = NA, nsim = 5000, use.approx=0,
            log.grid.hi=8, log.grid.lo=-10, gridlength=200)

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

       X: The fixed effects design matrix of the model under the
          alternative 

       Z: The random effects design matrix of the model under the
          alternative 

       q: The number of parameters restrictions on the fixed effects
          (see Details)

sqrt.Sigma: The upper triangular cholesky factor of  the correlation
          matrix of the random effect

 lambda0: The value of the ratio of the variances of the random effect
          and the errors under the null

    seed: Specify a seed for 'set.seed'

    nsim: Number of values to simulate 

use.approx: If 0, the exact distribution is simulated. If between 0 and
          1, only the largest eigenvalues whose sum represents at least
          'use.approx'*(sum of all eigenvalues) are used.

log.grid.hi: Lower value of the grid on the log scale. See *Details*

log.grid.lo: Lower value of the grid on the log scale. See *Details*

gridlength: Length of the grid.  

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

     The model under the alternative must be a linear mixed model
     y=X*beta+Z*b+epsilon with a single random effect b with known
     correlation structure Sigma and error terms that are i.i.d. The
     simulated distribution of the likelihood ratio statistic was
     derived by Crainiceanu & Ruppert (2004). The simulation algorithm
     uses a gridsearch over a log-regular grid of values of
     lambda=Var(b)/Var(epsilon) to maximize the likelihood under the
     alternative for 'nsim' realizations of y drawn under the null
     hypothesis. 'log.grid.hi' and 'log.grid.lo' are  the lower and
     upper limits of this grid on the log scale. 'gridlength' is the
     number of points on the grid.

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

     A dataframe with 'nsim' rows and 2 columns: 

  lambda: estimates of lambda under the alternative

     lrt: simulated realizations of the test statistic

_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:

     'exactLRT', 'exactRLRT' for tests

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

     library(lme4)
     g <- rep(1:10, e = 10)
     x <- rnorm(100)
     y <- 0.1 * x + rnorm(100)
     m <- lmer(y ~ x + (1|g), method="ML")
     m0 <- lm(y ~ 1)
     X <- m@X
     Z <- t(as.matrix(m@Zt))
     lrt <- LRTSim(X, Z, 1, diag(10))

