eugen pircalabelu
2008-Jun-15 23:16 UTC
[R] R vs SAS and HLM on multilevel analysis- basic question
Hi R users! I am trying to learn some multilevel analysis, but unfortunately i am now very confused. The reason: http://www.ats.ucla.edu/stat/hlm/seminars/hlm_mlm/mlm_hlm_seminar.htm http://www.ats.ucla.edu/stat/sas/seminars/sas_mlm/mlm_sas_seminar.htm and MlmSoftRev. pdf from mlmRev package.>From what i see, the first two links seem to declare the level one variable as a random part (i don't know sas synthax, but i think i am right ) while Mr. Bates' pdf says that a grouping variable is the random part of the model, though both models, use roughly the same type of information, some characteristic of the school, along with individual characteristics in explaining individual achivement.Am i mistaken somehow? If not, could they both be valid models (i presume) but each showing something else, in terms of connections between this variables? Thank you and sorry for taking up your time. [[alternative HTML version deleted]]
Douglas Bates
2008-Jun-16 13:22 UTC
[R] R vs SAS and HLM on multilevel analysis- basic question
We may want to move this discussion to the R-SIG-Mixed-Models list, which I have cc:'d on this reply. On Sun, Jun 15, 2008 at 6:16 PM, eugen pircalabelu <eugen_pircalabelu at yahoo.com> wrote:> Hi R users!> I am trying to learn some multilevel analysis, but unfortunately i am now very confused. The reason: http://www.ats.ucla.edu/stat/hlm/seminars/hlm_mlm/mlm_hlm_seminar.htm > http://www.ats.ucla.edu/stat/sas/seminars/sas_mlm/mlm_sas_seminar.htm> and > MlmSoftRev. pdf from mlmRev package.> >From what i see, the first two links seem to declare the level one variable as a random part (i don't know sas synthax, but i think i am right ) while Mr. Bates' pdf says that a grouping variable is the random part of the model, though both models, use roughly the same type of information, some characteristic of the school, along with individual characteristics in explaining individual achivement.I'm not exactly sure what you are asking. If you are saying that the terminology and notation can be confusing, I certainly agree. I think those who developed HLM and MLWin have done a tremendous service to their users in providing them with sophisticated tools for modeling data. However, the way that they structure the model is really only appropriate for models with nested random effects and, to my mind, introduces many unnecessary and restrictive ways of thinking of the data and the model.> Am i mistaken somehow? If not, could they both be valid models (i presume) but each showing something else, in terms of connections between this variables?As I said, I don't quite understand what you are asking and, rather than formulate an answer to the wrong question, I'll ask if you can rephrase your question and perhaps be more explicit about an example. In particular, you made reference to a "school". Are you referring to a particular example?
Ista Zahn
2008-Jun-16 13:32 UTC
[R] R vs SAS and HLM on multilevel analysis- basic question
On Jun 16, 2008, at 6:00 AM, r-help-request@r-project.org wrote:> From: eugen pircalabelu <eugen_pircalabelu@yahoo.com> > Date: June 15, 2008 7:16:09 PM EDT > To: R-help <r-help@stat.math.ethz.ch> > Subject: [R] R vs SAS and HLM on multilevel analysis- basic question > > > Hi R users! > > I am trying to learn some multilevel analysis, but unfortunately i > am now very confused. The reason:http://www.ats.ucla.edu/stat/hlm/seminars/hlm_mlm/mlm_hlm_seminar.htm > http://www.ats.ucla.edu/stat/sas/seminars/sas_mlm/mlm_sas_seminar.htm > > and > MlmSoftRev. pdf from mlmRev package. > >> From what i see, the first two links seem to declare the level one >> variable as a random part (i don't know sas synthax, but i think i >> am right ) while Mr. Bates' pdf says that a grouping variable is >> the random part of the model, though both models, use roughly the >> same type of information, some characteristic of the school, along >> with individual characteristics in explaining individual achivement. > > Am i mistaken somehow? If not, could they both be valid models (i > presume) but each showing something else, in terms of connections > between this variables?Yes, I believe you are mistaken, but I have only a rudimentary understanding of mixed effects modeling so I won't comment further except to say that I'm pretty sure both sources you listed above are talking about the same kinds of models.> >I don't know SAS at all, but I've used both HLM and R to run mixed effects models. Part of the confusion may be due to the different ways that R and HLM expect the input data to be formatted. To run a 2- level model in HLM you need two separate files corresponding to the two levels. When you input the data into HLM you specify the grouping factor that links the two files together. In R you can use a single data file and specify the grouping factor in the model syntax. I posted a similar question several months ago--see http://tolstoy.newcastle.edu.au/R/e4/help/08/02/3600.html I also received an off-list reply pointing me to http://www.ats.ucla.edu/stat/examples/alda.htm which gives both HLM and R syntax for the same models. One of the examples on the website is as follows: ################ HLM Level 1 Model COG = beta_0 + beta_1(TIME) + r Level 2 model: beta_0 = gamma_00 + gamma_01(PROGRAM) + mu_0 beta_1 = gamma_10 + gamma_11(PROGRAM) + mu_1 ################# Notice that no grouping factor is specified because this is done separately, in the data input stage. The corresponding R syntax is ################# R syntax: model1<- lmer(cog~time*program + (time | id), data=dataframe) ################# Notice that there is an extra term in the R syntax (id) that is not in the HLM syntax. Again, this is because you have to tell HLM what the grouping variable is when you input the data, while in R you specify the grouping variable in the model. I'm guessing this may be the source of some of your confusion.> Thank you and sorry for taking up your time.No problem, HTH. -Ista [[alternative HTML version deleted]]