[R] R vs SAS and HLM on multilevel analysis- basic question

From: Ista Zahn <istazahn_at_gmail.com>
Date: Mon, 16 Jun 2008 09:32:47 -0400

On Jun 16, 2008, at 6:00 AM, r-help-request_at_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_at_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]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 16 Jun 2008 - 13:52:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 16 Jun 2008 - 14:30:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive