Hi Anna,

If you want to nest id in area then you should use the term (1|area/id) but
I would treat area as a fixed effect because you only have 3 levels of area


Note that in your dummy data you need to force x1 to be numeric x1 <-
as.numeric() because at the moment it's being treated as a factor, assuming
it is a continuous variable of course.


Andy.





andydolman@gmail.com


On 22 April 2010 12:58, anna freni sterrantino <annafreni@yahoo.it> wrote:

> Hello all !
> I have a question about how to specify a model.
>
> My dataset is composed of  69 units splitted ( not equally)
> on three areas. For each of the 69 units I have  data collected
> for 56 time points. My data are in a long format
> something like this:
>
>
> id=c(rep("id1",56),rep("id2",56),rep("id3",56),rep("id4",56),rep("id5",56),rep("id6",56),rep("id7",56))
> areas=c(rep("a",112),rep("b",112),rep("c",168))
> time=rep(1:7,56)
> x1=c(rep(sample(1:20, 56,T ),2),
> rep(sample(20:30,56,T),2),rep(sample(50:60,56,T),3))
> y1=rep(0:1,392)
> y2=rep(0:1,392)
> sex=c(rep("F",56), rep("M",56), rep("F", 56),rep("F",56), rep("M",56),
> rep("F", 56),rep("M",56))
> df=as.data.frame(cbind(id,areas,time,x1,sex,y1,y2))
>
> there are 7 id,  three areas
> a ( 2 obs)
> b ( 2 obs)
> c( 3  obs)
>  the 56 time points regard 8 weeks of  collecting data.
> y1 and  y2 are the outcome registered for each day
> and  x1 is a predictor that is collected every day but is the same
> for  area.
>
>
> I  wrote the model
> accounting for the repeated measure for each subject
> like this
>
> glmer( y1 ~ x1 +(1|id), data=df ...)
>
> but I guess that I should account for the areas too.
> but I don't have it clear how.
> The subject are nested in the areas
> so something like
>
> glmer( y1 ~ x1 +(1|id) + (1|id/areas), data=df ...)
>
> would be correct?
>
>
> Many thanks for your help .
>
> Best Regards
> Anna
>
>
>
>
> Anna Freni Sterrantino
> Ph.D Student
> Department of Statistics
> University of Bologna, Italy
> via Belle Arti 41, 40124 BO.
>
>
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]


