[R] plot of all.effects object
David Afshartous
dafshartous at med.miami.edu
Thu Sep 11 22:48:13 CEST 2008
Dear John,
Thanks and sorry for the typo.
For the example below, how do I get the time.num variable to correspond to
the x-axis? I tried refitting the model with a different order of supplied
variables but this didn't do it.
Cheers,
David
On 9/11/08 4:28 PM, "John Fox" <jfox at mcmaster.ca> wrote:
> Dear David,
>
> You have to spell the name of term correctly:
>
> plot(fm.effects, "time.num:drug:X")
>
> (Admittedly, the error message is cryptic: I'll look into that.)
>
> A couple of other comments: (1) There is only one high-order term in
> your model, so it's not necessary to use all.effects(); (2) if you
> plot(fm.effects) (i.e., without specifying the term to plot) you'll be
> presented with a menu, in this instance with only one choice.
>
> I hope this helps,
> John
>
> On Thu, 11 Sep 2008 15:54:25 -0400
> David Afshartous <dafshartous at med.miami.edu> wrote:
>>
>>
>> All,
>>
>> I'm trying to plot an all.effects() object, as shown in the help for
>> all.effects and also Crawley's R book (p.178, 2007). The data has a
>> repeated
>> measures structure, but I'm using all.effects for the simple lm() fit
>> here.
>> Below is a reproducible example that yields the error message.
>>
>>
>> fm.ex = lm(dv ~ time.num*drug*X, data = dat.new)
>> fm.effects = all.effects(fm.ex, xlevels = list(time.num = 1:4))
>>
>>> plot(fm.effects, "time.num:Drug:X")
>> Error in plot.window(...) : need finite 'xlim' values
>> In addition: Warning messages:
>> 1: In min(x) : no non-missing arguments to min; returning Inf
>> 2: In max(x) : no non-missing arguments to max; returning -Inf
>> 3: In min(x) : no non-missing arguments to min; returning Inf
>> 4: In max(x) : no non-missing arguments to max; returning -Inf
>>
>> Cheers,
>> David
>>
>>
>>
>>
>>
>> ############################
>> sessionInfo()
>> R version 2.7.1 (2008-06-23)
>> i386-apple-darwin8.10.1
>>
>> locale:
>> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] grid stats graphics grDevices utils datasets
>> methods
>> base
>>
>> other attached packages:
>> [1] effects_1.0-12 lattice_0.17-8
>>
>> loaded via a namespace (and not attached):
>> [1] Matrix_0.999375-11 lme4_0.999375-24 nlme_3.1-89
>> tools_2.7.
>>
>> set.seed(500)
>> n.timepoints <- 4
>> 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)
>> dat.new$time.num = rep(1:n.timepoints, n.subj.per.tx*2)
>> dat.new$X <- rnorm(160) ### to check plot of all.effects info
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --------------------------------
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox/
More information about the R-help
mailing list