[R-sig-ME] Repeated measures with a non-linear time effect
Daniel Rubi
daniel_rubi at ymail.com
Thu Jul 21 21:50:30 CEST 2016
Hi Jörg,
Unfortunately setting time as integer doesn't change anything whereas setting it as a factor means that the number of random effects will be equal to the number of samples.
Perhaps this is an alternative:fit1 <- gls(measure~time*group,correlation=corSymm(form=~1|subject),weight=varIdent(form=~1|time),data=df)
as it does capture the group and interaction effects but I think I need to contrast it with a null model and I'm not sure what would that null model be.
Any idea?
On Thursday, July 21, 2016 3:27 PM, Jörg Albrecht <albrechj at staff.uni-marburg.de> wrote:
Hi Dan,
most likely the model treats your time covariate as a continuous predictor. Try str(df), then time should appear as integer (int). If you specify time as a factor (with three levels: 1, 2, 3) the model will be able to estimate the time x treatment interaction separately for each time point. However, you still have to decide whether treating time as a factorial variable makes sense for your dataset.
Best,
Jörg
> Am 21.07.2016 um 20:13 schrieb Daniel Rubi via R-sig-mixed-models <r-sig-mixed-models at r-project.org>:
>
> Hi,
> I have repeated measures from two groups (treatment and control), three subjects in each, over three time points.
>
> Here's the data in an R data.frame:df <- data.frame(subject=rep(c("T1","T2","T3","C1","C2","C3"),3), group=rep(c(rep("T",3),rep("C",3)),3), time=c(rep(1,6),rep(2,6),rep(3,6)), measure=c(0,253,155,16,232,251,1035,1014,760,98,239,87,371,60,47,0,260,190), col=rep(c(rep("red",3),rep("blue",3)),3), stringsAsFactors=F)
>
>
> The plot shows the time x group interaction:
>
> R code for producing the plot:
> plot(df$time,df$measure,col=df$col,xlab="time",ylab="measure")
> legend("topleft",legend=c("treatment","control"),col=c("red","blue"),pch=1)
>
>
> My question is what model to use to capture the time x group interaction.
> I thought:library(lmerTest)fit <- lmer(measure~time+group+time*group+(time|subject),data=df)
> might do it.
> But the summary of this model doesn't really capture that:> summary(fit)Linear mixed model fit by REMLt-tests use Satterthwaite approximations to degrees of freedom ['lmerMod']Formula: measure ~ time + group + time * group + (time | subject) Data: df
> REML criterion at convergence: 210
>
> Scaled residuals:
> Min 1Q Median 3Q Max
> -1.228 -0.448 -0.163 0.275 1.923
>
> Random effects:
> Groups Name Variance Std.Dev. Corr
> subject (Intercept) 0.00e+00 0.00e+00
> time 3.06e-16 1.75e-08 NaN
> Residual 1.05e+05 3.25e+02
> Number of obs: 18, groups: subject, 6
>
> Fixed effects:
> Estimate Std. Error df t value Pr(>|t|)
> (Intercept) 168.89 286.35 13.78 0.59 0.56
> time -8.17 132.55 13.78 -0.06 0.95
> groupT 218.33 404.96 13.78 0.54 0.60
> time:groupT 19.83 187.46 13.78 0.11 0.92
>
> Correlation of Fixed Effects:
> (Intr) time groupT
> time -0.926
> groupT -0.707 0.655
> time:groupT 0.655 -0.707 -0.926
>
>
> So my question is what model to use?
>
> Thanks a lot,Dan
>
> <Rplot.png>_______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list