[R-sig-ME] Power Analysis for Linear Mixed Model with Covariates
Ulf Köther
ukoether at uke.de
Wed May 14 00:41:24 CEST 2014
Dear Gerasimos,
I am really no expert, but I would guess, you get no slope because you
implemented time as a factor variable, therefore lmer is giving you
correlated random intercepts, one for each factor-level...
Just try to add another variable for time:
expdat <- expand.grid(kid = factor(1:500), Time = factor(1:4), Treat = c("XTx", "BAU"))
expdat$obs <- factor(seq(nrow(expdat)))
expdat$time.month <- rep(c(0,3,6,9), each = 500)
...
fit1 <- lmer(Outcome ~ Treat*Time + (1 + time.month | kid), data = expdat)
This should give you what you want, I think...
Ulf
Am 14.05.2014 00:12, schrieb Gerasimos Fergadiotis:
> I would like to conduct a power analysis for a linear mixed model with fixed effects for Treatment(two levels) and Time (four time points: pre, mid, post treatment, 3 months post treatment; each three months apart) and correlated random effects for children (intercepts and slopes). I am using the following code in R using the lmer function:
>
> expdat <- expand.grid(kid = factor(1:500), Time = factor(1:4), Treat = c("XTx", "BAU"))
> expdat$obs <- factor(seq(nrow(expdat)))
> set.seed(101)
> nsim <- 20
> beta <- c(100, -7, 8, 15, 20, 0, 0, 0)
> theta <- c(15.000000, 7.500000, 7.500000, 7.500000, 12.990381, 4.330127, 4.330127,
> 12.247449, 3.061862, 11.858541)
> ss <- simulate(~Treat*Time + (1+Time | kid), nsim = nsim, family = gaussian,
> weights = rep(25, nrow(expdat)), newdata = expdat, newparams =
> list(theta = theta, beta = beta, sigma = 1))
> expdat$Outcome <- ss[, 1]
> fit1 <- lmer(Outcome ~ Treat*Time + (1+Time | kid), data = expdat)
> I have the following questions:
>
> In the output I see the variance associated with the random intercepts at each time point and their correlation. However, I cannot find in the output the variance associated with the slopes, and I cannot find information about the correction between the intercepts and the slopes. Where is that information?
> How does the lmer know that Time has levels and that it should estimate a unique effect for each level of the Time factor instead of a general slope parameter?
> I am attaching the summary statement of the model:
> Linear mixed model fit by REML ['lmerMod']
> Formula: Outcome ~ Treat * Time + (1 + Time | kid)
> Data: expdat
>
> REML criterion at convergence: 22951.8
>
> Scaled residuals:
> Min 1Q Median 3Q Max
> -2.55473 -0.47186 -0.00007 0.47268 2.57786
>
> Random effects:
> Groups Name Variance Std.Dev. Corr
> kid (Intercept) 235.4531 15.3445
> Time2 230.9249 15.1962 0.43
> Time3 220.6076 14.8529 0.52 0.53
> Time4 213.2725 14.6039 0.48 0.51 0.52
> Residual 0.9749 0.9874
> Number of obs: 4000, groups: kid, 500
>
> Fixed effects:
> Estimate Std. Error t value
> (Intercept) 100.92006 0.68765 146.76
> TreatBAU -6.94796 0.06245 -111.26
> Time2 7.39371 0.68246 10.83
> Time3 15.17849 0.66717 22.75
> Time4 19.27623 0.65608 29.38
> TreatBAU:Time2 -0.16052 0.08831 -1.82
> TreatBAU:Time3 -0.05291 0.08831 -0.60
> TreatBAU:Time4 -0.14215 0.08831 -1.61
>
> Correlation of Fixed Effects:
> (Intr) TrtBAU Time2 Time3 Time4 TBAU:T2 TBAU:T3
> TreatBAU -0.045
> Time2 0.422 0.046
> Time3 0.510 0.047 0.528
> Time4 0.468 0.048 0.506 0.520
> TretBAU:Tm2 0.032 -0.707 -0.065 -0.033 -0.034
> TretBAU:Tm3 0.032 -0.707 -0.032 -0.066 -0.034 0.500
> TretBAU:Tm4 0.032 -0.707 -0.032 -0.033 -0.067 0.500 0.500
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Gerasimos Fergadiotis, PhD., CCC-SLP
> Assistant Professor
> Speech & Hearing Sciences
> 724 SW Harrison St., RM 84B
> Portland State University
> Portland, Oregon 97201
> Phone: 503.725.2217
> Fax: 503.725.9171
> Web page: http://aaldresearch.wix.com/aald
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
--
________________________________________
Dipl.-Psych. Ulf Köther
PEPP-Team
Klinik für Psychiatrie und Psychotherapie
Universitätsklinikum Hamburg-Eppendorf
Martinistr. 52
20246 Hamburg
PEPP-Team:
Tel.: +49 (0) 40 7410 53243
pepp at uke.de
Persönlich:
Tel.: +49 (0) 40 7410 55851
Mobil: (9) 55851
ukoether at uke.de
________________________________________
--
DANKE FÜR 125 JAHRE ENGAGEMENT UND VERTRAUEN.
www.uke.de/125
_____________________________________________________________________
Besuchen Sie uns auf: www.uke.de
_____________________________________________________________________
Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vertreter des Vorsitzenden), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Rainer Schoppik
_____________________________________________________________________
SAVE PAPER - THINK BEFORE PRINTING
More information about the R-sig-mixed-models
mailing list