[R] How to create MULTILEVELS in a dataset??

Ista Zahn istazahn at gmail.com
Mon Oct 19 06:00:50 CEST 2009


Hi Saurav,
I was waiting for someone else to answer you, because I'm not sure
I'll be able to explain clearly. But since no one is jumping on it,
I'll take a stab.

On Sun, Oct 18, 2009 at 5:52 PM, saurav pathak <pathak.saurav at gmail.com> wrote:
> Dear R users
>
> I have a data set which has five variables. One depenedent variable y, and 4
> Independent variables (education-level, householdincome, countrygdp and
> countrygdpsquare). The first two are data corresponding to the individual
> and the next two coorespond to the country to which the individual belongs
> to. My data set does not make this distinction between individual level and
> country level. Is there a way such that I can make R make countrygdp and
> countrygdpsquare at a different level than the individual level data. In
> other words I wish to transform my dataset such that it recognizes two
> individual level variables to be at Level-1 and the other two country level
> variables at Level-2.
>

If you're using lmer I don't think you need to do anything special in
terms of data preparation. You will need an explicit country code I
think.

> I need to run a multilevel model, but first I must make my dataset recognise
> data at Level-1 and Level-2. How can I create this country level group (gdp
> and gdp^2) such that I can perform a multilevel model as follows:
>
> lmer(y ~ education-level + householdincome + countrygdp + countrygdpsquare +
> (1 I Level2),family=binomial(link="probit),data=dataset)

I think you just need to specify country as the grouping variable:

 lmer(y ~ education-level + householdincome + countrygdp +
countrygdpsquare + (1 I
country),family=binomial(link="probit),data=dataset)

>
> Please kindly help me with the relevant commands for creating this Level2
> (having two variables)

I hope this helps -- I thinks it's less complicated than you were assuming.

-Ista
>
> Thanks
> Saurav
>
>
>
>
>
> Dr.Saurav Pathak
> PhD, Univ.of.Florida
> Mechanical Engineering
> Doctoral Student
> Innovation and Entrepreneurship
> Imperial College Business School
> s.pathak08 at imperial.ac.uk
> 0044-7795321121
>
>        [[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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org




More information about the R-help mailing list