Re: R-alpha: R 0.14 : summary(lm(...)) -- patch

Martin Maechler (maechler@stat.math.ethz.ch)
Mon, 2 Dec 96 12:28:04 +0100


Date: Mon, 2 Dec 96 12:28:04 +0100
Message-Id: <9612021128.AA07091@>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: Peter Dalgaard <pd@kubism.ku.dk>
In-Reply-To: <x2afrxfcq6.fsf@bush.kubism.ku.dk> (message from Peter Dalgaard
Subject: Re: R-alpha: R 0.14 : summary(lm(...)) -- patch

Peter, "as always" you are right;

But I think there are more problems:

 Shouldn't the d.f. of the  fstatistic also be corrected
	 for the  'no intercept case' ??

 probably just using   (p - attr(z$terms, "intercept")) 
	  instead  of  (p-1)				 [[ in 2 locations]]

 The F-statistic and  DF  should be the same in the outputs of
	 anova(lm.wg1)
 and
	summary(lm.wg1)

 in the AUGMENTED example of  demos/models/lm+glm :

 ## Plant Weight Data (Page 9)
 ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
 trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
 group <- gl(2,10,20,labels=c("Ctl","Trt"))
 weight <- c(ctl,trt)
 anova(lm.wg  <- lm(weight~group))
 summary(lm.wg)
 anova(lm.wg1 <- lm(weight~group-1))
 summary(lm.wg1)


Here is the current patch (apply in  $RHOME/src/library/base/funs ) :

--- lm.~1~	Sun Nov 24 23:42:25 1996
+++ lm	Mon Dec  2 12:23:57 1996
@@ -224,9 +224,12 @@
 	ans$sigma <- sqrt(resvar)
 	ans$df <- c(p, n-p, NCOL(z$qr$qr))
 	if(p != attr(z$terms,"intercept")) {
+	  	df.int <- if(attr(z$terms,"intercept")) 1 else 0
 		ans$r.squared <- mss/(mss+rss)
-		ans$adj.r.squared <- 1-(1-ans$r.squared)*(n/(n-p))
-		ans$fstatistic <- c((mss/(p-1))/(rss/(n-p)),p-1,n-p)
+		ans$adj.r.squared <- 1-(1-ans$r.squared)*	
+		  ((n - df.int) / (n - p))	#0.14 :	(n/(n-p))
+		ans$fstatistic <- c((mss/(p-df.int))/(rss/(n-p)),p-df.int,n-p)
+ 		#0.14: ans$fstatistic <- c((mss/(p-1))/(rss/(n-p)),p-1,n-p)
 		names(ans$fstatistic) <- c("value","numdf","dendf")
 	}
 	ans$cov.unscaled <- R

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-