From pdalgd at gmail.com  Sun May  8 10:15:20 2011
From: pdalgd at gmail.com (peter dalgaard)
Date: Sun, 8 May 2011 10:15:20 +0200
Subject: [Rd] anova.lm fails with test="Cp"
In-Reply-To: <0E28A214-9F72-45A2-AAA2-E1D7EC46C6B1@anu.edu.au>
References: <0E28A214-9F72-45A2-AAA2-E1D7EC46C6B1@anu.edu.au>
Message-ID: <AA81EAC1-22CD-4550-BFCA-C04F42F8FB3A@gmail.com>


On May 8, 2011, at 09:25 , John Maindonald wrote:

> Here is an example, modified from the help page to use test="Cp":
> 
> --------------------------------------------------------------------------------
>> fit0 <- lm(sr ~ 1, data = LifeCycleSavings)
>> fit1 <- update(fit0, . ~ . + pop15)
>> fit2 <- update(fit1, . ~ . + pop75)
>> anova(fit0, fit1, fit2, test="Cp")
> Error in `[.data.frame`(table, , "Resid. Dev") : 
> undefined columns selected

Yes, the "Resid. Dev" column is only there in analysis of deviance tables. For the lm() case, it looks like you should have "RSS". 

This has probably been there "forever". Just goes to show how often people use these things...

Also, now that I'm looking at it, are we calculating it correctly in any case? We have

        cbind(table, Cp = table[, "Resid. Dev"] + 2 * scale * 
            (n - table[, "Resid. Df"]))

whereas all the references I can find have Cp=RSS/MS-N+2P, so the above would actually be scale*Cp+N. 


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] anova.lm fails with test="Cp"
peter dalgaard