mkran                  package:gss                  R Documentation

_G_e_n_e_r_a_t_i_n_g _R_a_n_d_o_m _E_f_f_e_c_t_s _i_n _M_i_x_e_d-_E_f_f_e_c_t _M_o_d_e_l_s

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

     Generate entries representing random effects in mixed-effect
     models.

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

     mkran(formula, data)

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

 formula: Symbolic description of the random effects.

    data: Data frame containing the variables in the model.

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

     This function generates random effect terms from simple grouping
     variables, for use in nonparametric mixed-effect models as
     described in Gu and Ma (2005a, b).  The syntax of the formula
     resembles that of similar utilities for linear and nonlinear
     mixed-effect models, as described in Pinheiro and Bates (2000).

     Currently, 'mkran' takes only two kinds of formulas, '~1|grp2' or
     '~grp1|grp2'.  Both 'grp1' and 'grp2' should be factors, and for
     the second formula, the levels of 'grp2' should be nested under
     those of 'grp1'.

     The Z matrix is determined by 'grp2'.  When observations are
     ordered according to the levels of 'grp2', the Z matrix is block
     diagonal of 1 vectors.

     The Sigma matrix is diagonal.  For '~1|grp2', it has one tuning
     parameter.  For '~grp1|grp2', the number of parameters equals the
     number of levels of 'grp1', with each parameter shared by the
     'grp2' levels nested under the same 'grp1' level.

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

     A list of three components. 

       z: Z matrix.

   sigma: Sigma matrix to be evaluated through
          'sigma$fun(para,sigma$env)'.

    init: Initial parameter values.

_N_o_t_e:

     One may pass a formula or a list to the argument 'random' in calls
     to 'ssanova' or'gssanova' to fit nonparametric mixed-effect
     models.  A formula will be converted to a list using 'mkran'.  A
     list should be of the same form as the value of 'mkran'.

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

     Chong Gu, chong@stat.purdue.edu

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

     Gu, C. and Ma, P. (2005), Optimal smoothing in nonparametric
     mixed-effect models.  _The Annals of Statistics_, *33*, 1357-1379.

     Gu, C. and Ma, P. (2005), Generalized nonparametric mixed-effect
     models: computation and smoothing parameter selection. _Journal of
     Computational and Graphical Statistics_, *14*, 485-504.

     Pinheiro and Bates (2000), _Mixed-Effects Models in S and S-PLUS_.
      New York: Springer-Verlag.

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

     ## Toy data
     test <- data.frame(grp=as.factor(rep(1:2,c(2,3))))
     ## First formula
     ran.test <- mkran(~1|grp,test)
     ran.test$z
     ran.test$sigma$fun(2,ran.test$sigma$env) # diag(10^(-2),2)
     ## Second formula
     ran.test <- mkran(~grp|grp,test)
     ran.test$z
     ran.test$sigma$fun(c(1,2),ran.test$sigma$env) # diag(10^(-1),10^(-2))
     ## Clean up
     ## Not run: rm(test,ran.test)

