Skip to content

summary.lme() vs. anova.lme()

7 messages · Dimitris Rizopoulos, Andy Bunn, Brian Ripley +2 more

#
Dear R list:

I modelled changes in a variable (mconc) over time (d) for individuals
(replicate) given one of three treatments (treatment) using:
mconc.lme <- lme(mconc~treatment*poly(d,2), random=~poly(d,2)|replicate,
data=my.data)

summary(mconc.lme) shows that the linear coefficient of one of the
treatments is significantly different to zero, viz.
                            Value Std.Error  DF   t-value p-value
					...	     ... ...      ...
...
treatmentf:poly(d, 2)1  1.3058562 0.5072409 315  2.574430  0.0105

But anova(mconc.lme) gives a non-significant result for the treatment*time
interaction, viz.
                     numDF denDF   F-value p-value
(Intercept)              1   315 159.17267  <.0001
treatment                2    39   0.51364  0.6023
poly(d, 2)               2   315  17.43810  <.0001
treatment:poly(d, 2)     4   315   2.01592  0.0920

Pinheiro & Bates (2000) only discusses anova() for single arguments briefly
on p.90.
I would like to know whether these results indicate that the significant
effect found in summary(mconc.lme) is spurious (perhaps due to
multiplicity).

Many thanks,
Dan Bebber

Department of Plant Sciences
University of Oxford
South Parks Road
Oxford OX1 3RB
UK
Tel. 01865 275000
#
Hi Dan,

check the `type' argument of `anova.lme()' which defaults to 
"sequential". This is also discussed in Pinheiro and Bates but I don't 
have the book with me now to trace the page.

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Dan Bebber" <danbebber at forestecology.co.uk>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, November 17, 2004 3:35 PM
Subject: [R] summary.lme() vs. anova.lme()
#
Is there a way to calculate the number of months between dates?

StartDate <- strptime("01 March 1950", "%d %B %Y")
EventDates <- strptime(c("01 April 1955", "01 July 1980"), "%d %B %Y")
difftime(EventDates, StartDate)

So, there are 61 months between 01 March 1950 and 01 April 1955. There are
364 months between 01 March 1950 and 01 July 1980. What I want is for there
to be a "months" argument to units in difftime. Anybody have a bright idea?
Is there a better way to approach this than difftime?

Thanks in advance, Andy
_
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    0.0
year     2004
month    10
day      04
language R
#
On Wed, 17 Nov 2004, Dan Bebber wrote:

            
Probably yes (but p values of 9% and 1% are not that different, and in 
both cases you are looking at a few p values).

But since both summary.lme and anova.lme use Wald tests, I would use a 
LRT, using anova on two fits (and I would use ML fits to get a genuine 
LRT but that is perhaps being cautious).

To  Dimitris Rizopoulos: as this is the last term in the sequential anova, 
it is the correct Wald test.
#
On Wed, 17 Nov 2004, Andy Bunn wrote:

            
Ah, but months are of variable length.
Pretty easy: convert to POSIXlt, then use something like

12*x$year + x$month

and subtract those.  You could set up a class for "months" and have 
as.months and a `-' method ....

  
    
#
Andy Bunn <abunn <at> whrc.org> writes:

: 
: Is there a way to calculate the number of months between dates?
: 
: StartDate <- strptime("01 March 1950", "%d %B %Y")
: EventDates <- strptime(c("01 April 1955", "01 July 1980"), "%d %B %Y")
: difftime(EventDates, StartDate)
: 
: So, there are 61 months between 01 March 1950 and 01 April 1955. There are
: 364 months between 01 March 1950 and 01 July 1980. What I want is for there
: to be a "months" argument to units in difftime. Anybody have a bright idea?
: Is there a better way to approach this than difftime?

1. There are an average of 365.25/12 days per month so the following
expression gives the number of months between d1 and d2:

   # test data
   d1 <- as.Date("01 March 1950", "%d %B %Y")
   d2 <- as.Date(c("01 April 1955", "01 July 1980"), "%d %B %Y")

   # calculation
   round((d2 - d1)/(365.25/12))

2. Another possibility is to get the length of seq.Dates like this:

   as.Date.numeric <- function(x) structure(floor(x+.001), class = "Date")
   sapply(d2, function(d2) length(seq(d1, as.Date(d2), by = "month")))-1
#
For anyone following this thread in the future:
Following Prof. Ripley's advice, I compared models fitted with ML, with and
without treatment as a predictor:
Model df       AIC       BIC   logLik   Test L.Ratio p-value
mconc.lme1     1 10 -1366.184 -1327.240 693.0919                       
mconc.lme2     2 16 -1363.095 -1300.785 697.5475 1 vs 2 8.91124  0.1786

I can't reject the null hypothesis of no effect of treatment.

Many thanks.
Dan Bebber

Department of Plant Sciences
University of Oxford
South Parks Road
Oxford OX1 3RB
UK
Tel. 01865 275000