-----Original Message-----
From: Alan Cobo-Lewis [mailto:alanc at umit.maine.edu]
Sent: Wednesday, July 11, 2007 6:40 PM
To: r-sig-mixed-models at r-project.org
Cc: " "Afshartous at basalt.its.maine.edu; Afshartous, David;
Andrew Robinson
Subject: Re: random effect variance per treatment group in lmer
Dave,
How about using stratifying variance on level of drug using (
0 + as.numeric(drug=="D") | Patient ) + ( 0 +
as.numeric(drug=="P") | Patient ) Here's some code (whose sim
also builds in a fixed effect of time that applies only to
the Drug condition).
set.seed(500)
n.timepoints <- 8
n.subj.per.tx <- 20
sd.d <- 5; sd.p <- 2; sd.res <- 1.3
drug <- factor(rep(c("D", "P"), each = n.timepoints, times =
n.subj.per.tx)) drug.baseline <- rep( c(0,5),
each=n.timepoints, times=n.subj.per.tx ) Patient <-
rep(1:(n.subj.per.tx*2), each = n.timepoints)
Patient.baseline <- rep( rnorm( n.subj.per.tx*2, sd=c(sd.d,
sd.p) ), each=n.timepoints ) time <- factor(paste("Time-",
rep(1:n.timepoints, n.subj.per.tx*2), sep="")) time.baseline
<- rep(1:n.timepoints,n.subj.per.tx*2)*as.numeric(drug=="D")
dv <- rnorm( n.subj.per.tx*n.timepoints*2,
mean=time.baseline+Patient.baseline+drug.baseline, sd=sd.res
) dat.new <- data.frame(time, drug, dv, Patient) xyplot(
dv~time|drug, group=Patient, type="l", data=dat.new ) # fit
model treats time as a quantitative predictor ( fm.het <-
lmer( dv ~ rep(1:n.timepoints, n.subj.per.tx*2)*drug + ( 0 +
as.numeric(drug=="D") | Patient ) + ( 0 +
as.numeric(drug=="P") | Patient ), data=dat.new ) )
HTH,
alan
From: "Afshartous, David" <afshart at exchange.sba.miami.edu>
All,
I didn't receive a response to the query below sent to the general
R-help mailing list so figured I'd try this mailing list.
advance if this is an overly simplistic question for this
started w/ lmer after not using lme for awhile.
Cheers,
Dave