[R-sig-ME] modeling effects in multiple data frames

marKo mtoncic at ffri.hr
Tue Jul 16 16:32:08 CEST 2013


Thanks for the hint (both of you).
Nice the poly command. I know that i have to include I(time^2) I have 
written it without thinking.
The Ben's idea gives me plenty of flexibility regrading data manipulation.
Thanks a lot.


Marko

On 16.07.2013 16:18, Ben Bolker wrote:
> Emmanuel Curis <emmanuel.curis at ...> writes:
>
>> Assuming your hundred data.frames are in a list called data, why not
>> simply join them in a single data.frame: something like
>>
>> d <- do.call( rbind, data )
>>
>> This should work if all your data.frames (text files) have the same
>> number of variables and the same names for them.
>    More specifically,
>
> datList <- lapply(list.files(...),read.table)
> nvec <- sapply(datList,nrow)
> d <- cbind(do.call(rbind,datList),id=rep(1:length(datList),nvec))
>
> lme4(out~poly(time,2,raw=TRUE)+(poly(time,2,raw=TRUE)|id),data=d)
>
> Note that time^2 won't work as expected in a formula context; you either need
>
> 1 + time + I(time^2)
>
> or
>
> poly(time,2)  ## orthogonal polynomial
>
> or
>
> poly(time,2,raw=TRUE)  ## regular polynomial
>
>    orthogonal polynomials are probably better unless you need
> to be able to interpret the parameters in a specific way
>
> [snip]
>
>> « out: outcome variable (300 per participant)
>> « t: time variable (300 per participant)
>> « id: individual (100 for now)
>> «
>> « I wood like to model something like:
>> «
>> « lme4(out~1+time+time^2+(1+tim3+time^2|id, data=?????)
>> «
>> « So 100 data-frames (not exactly, txt files) with 300 data points per
>> « data-frame. id variable defined by data-frame (txt file used).
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list