Full_Name: Joaquin Diaz-Saiz Version: 1.3.0 OS: Windows Submission from: (NULL) (129.7.120.106) The lm() function applied to a particular data set produces a negative value for the adjusted R-square. See the output below. ======================================================R : Copyright 2001, The R Development Core Team Version 1.3.0 (2001-06-22) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type `license()' or `licence()' for distribution details. R is a collaborative project with many contributors. Type `contributors()' for more information. Type `demo()' for some demos, `help()' for on-line help, or `help.start()' for a HTML browser interface to help. Type `q()' to quit R. [Previously saved workspace restored]> w<-read.table("accres.txt") > wV1 V2 1 9 1 2 3 1 3 8 1 4 7 1 5 12 1 6 4 0 7 13 0 8 10 0 9 9 0 10 9 0 11 6 0> x<-w$V1 > t<-w$V2 > x[1] 9 3 8 7 12 4 13 10 9 9 6> t[1] 1 1 1 1 1 0 0 0 0 0 0> out<-lm(x~t) > summary(out)Call: lm(formula = x ~ t) Residuals: Min 1Q Median 3Q Max -4.80 -1.65 0.50 1.35 4.50 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 8.500 1.307 6.502 0.000111 *** t -0.700 1.939 -0.361 0.726443 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 3.202 on 9 degrees of freedom Multiple R-Squared: 0.01427, Adjusted R-squared: -0.09525 F-statistic: 0.1303 on 1 and 9 DF, p-value: 0.7264>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hola! This is not an error. If the r-squared is small, the formula defining "adjusted r-square" can give negative values, correctly. Kjetil Halvorsen. JDiaz-Saiz@uh.edu wrote:> > Full_Name: Joaquin Diaz-Saiz > Version: 1.3.0 > OS: Windows > Submission from: (NULL) (129.7.120.106) > > The lm() function applied to a particular data set produces a negative value for > the adjusted R-square. See the output below. > > ======================================================> R : Copyright 2001, The R Development Core Team > Version 1.3.0 (2001-06-22) > > R is free software and comes with ABSOLUTELY NO WARRANTY. > You are welcome to redistribute it under certain conditions. > Type `license()' or `licence()' for distribution details. > > R is a collaborative project with many contributors. > Type `contributors()' for more information. > > Type `demo()' for some demos, `help()' for on-line help, or > `help.start()' for a HTML browser interface to help. > Type `q()' to quit R. > > [Previously saved workspace restored] > > > w<-read.table("accres.txt") > > w > V1 V2 > 1 9 1 > 2 3 1 > 3 8 1 > 4 7 1 > 5 12 1 > 6 4 0 > 7 13 0 > 8 10 0 > 9 9 0 > 10 9 0 > 11 6 0 > > x<-w$V1 > > t<-w$V2 > > x > [1] 9 3 8 7 12 4 13 10 9 9 6 > > t > [1] 1 1 1 1 1 0 0 0 0 0 0 > > out<-lm(x~t) > > summary(out) > > Call: > lm(formula = x ~ t) > > Residuals: > Min 1Q Median 3Q Max > -4.80 -1.65 0.50 1.35 4.50 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 8.500 1.307 6.502 0.000111 *** > t -0.700 1.939 -0.361 0.726443 > --- > Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > > Residual standard error: 3.202 on 9 degrees of freedom > Multiple R-Squared: 0.01427, Adjusted R-squared: -0.09525 > F-statistic: 0.1303 on 1 and 9 DF, p-value: 0.7264 > > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Where's the bug? The adjusted R-squared is an approximately unbiased estimator of the true R^2. Like most unbiased estimators of positive parameters it can sometimes take on negative values. Most people will understand this, too, so I don't see much point in artificially replacing the result by zero if its value is negative. Bill Venables. -----Original Message----- From: JDiaz-Saiz@uh.edu [mailto:JDiaz-Saiz@uh.edu] Sent: Friday, 17 August 2001 3:31 AM To: r-devel@stat.math.ethz.ch Cc: R-bugs@biostat.ku.dk Subject: [Rd] lm() (PR#1059) Full_Name: Joaquin Diaz-Saiz Version: 1.3.0 OS: Windows Submission from: (NULL) (129.7.120.106) The lm() function applied to a particular data set produces a negative value for the adjusted R-square. See the output below. ======================================================R : Copyright 2001, The R Development Core Team Version 1.3.0 (2001-06-22) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type `license()' or `licence()' for distribution details. R is a collaborative project with many contributors. Type `contributors()' for more information. Type `demo()' for some demos, `help()' for on-line help, or `help.start()' for a HTML browser interface to help. Type `q()' to quit R. [Previously saved workspace restored]> w<-read.table("accres.txt") > wV1 V2 1 9 1 2 3 1 3 8 1 4 7 1 5 12 1 6 4 0 7 13 0 8 10 0 9 9 0 10 9 0 11 6 0> x<-w$V1 > t<-w$V2 > x[1] 9 3 8 7 12 4 13 10 9 9 6> t[1] 1 1 1 1 1 0 0 0 0 0 0> out<-lm(x~t) > summary(out)Call: lm(formula = x ~ t) Residuals: Min 1Q Median 3Q Max -4.80 -1.65 0.50 1.35 4.50 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 8.500 1.307 6.502 0.000111 *** t -0.700 1.939 -0.361 0.726443 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 3.202 on 9 degrees of freedom Multiple R-Squared: 0.01427, Adjusted R-squared: -0.09525 F-statistic: 0.1303 on 1 and 9 DF, p-value: 0.7264>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
To all the people involved: I incorrectly reported the negative value of the adjusted R-squared as a bug in the last version of R. I was not careful enough in checking the details and I apologize for the time that some people had to waste. I will be more careful next time. Some packages report values greater that or equal to zero and use zero when negative, but certainly this is not necessary. Joaquin Diaz-Saiz ----- Original Message ----- From: "Venables, Bill (CMIS, Cleveland)" <Bill.Venables@CMIS.CSIRO.AU> To: "'JDiaz-Saiz@uh.edu'" <JDiaz-Saiz@UH.EDU>; <r-devel@stat.math.ethz.ch> Cc: <R-bugs@biostat.ku.dk> Sent: Thursday, August 16, 2001 6:23 PM Subject: RE: [Rd] lm() (PR#1059)> Where's the bug? > > The adjusted R-squared is an approximately unbiased estimator of the true > R^2. Like most unbiased estimators of positive parameters it cansometimes> take on negative values. Most people will understand this, too, so Idon't> see much point in artificially replacing the result by zero if its valueis> negative. > > Bill Venables. > > -----Original Message----- > From: JDiaz-Saiz@uh.edu [mailto:JDiaz-Saiz@uh.edu] > Sent: Friday, 17 August 2001 3:31 AM > To: r-devel@stat.math.ethz.ch > Cc: R-bugs@biostat.ku.dk > Subject: [Rd] lm() (PR#1059) > > > Full_Name: Joaquin Diaz-Saiz > Version: 1.3.0 > OS: Windows > Submission from: (NULL) (129.7.120.106) > > > The lm() function applied to a particular data set produces a negativevalue> for > the adjusted R-square. See the output below. > > > ======================================================> R : Copyright 2001, The R Development Core Team > Version 1.3.0 (2001-06-22) > > R is free software and comes with ABSOLUTELY NO WARRANTY. > You are welcome to redistribute it under certain conditions. > Type `license()' or `licence()' for distribution details. > > R is a collaborative project with many contributors. > Type `contributors()' for more information. > > Type `demo()' for some demos, `help()' for on-line help, or > `help.start()' for a HTML browser interface to help. > Type `q()' to quit R. > > [Previously saved workspace restored] > > > w<-read.table("accres.txt") > > w > V1 V2 > 1 9 1 > 2 3 1 > 3 8 1 > 4 7 1 > 5 12 1 > 6 4 0 > 7 13 0 > 8 10 0 > 9 9 0 > 10 9 0 > 11 6 0 > > x<-w$V1 > > t<-w$V2 > > x > [1] 9 3 8 7 12 4 13 10 9 9 6 > > t > [1] 1 1 1 1 1 0 0 0 0 0 0 > > out<-lm(x~t) > > summary(out) > > Call: > lm(formula = x ~ t) > > Residuals: > Min 1Q Median 3Q Max > -4.80 -1.65 0.50 1.35 4.50 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 8.500 1.307 6.502 0.000111 *** > t -0.700 1.939 -0.361 0.726443 > --- > Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > > Residual standard error: 3.202 on 9 degrees of freedom > Multiple R-Squared: 0.01427, Adjusted R-squared: -0.09525 > F-statistic: 0.1303 on 1 and 9 DF, p-value: 0.7264 > > > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.> -.- > r-devel mailing list -- Readhttp://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html> Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.> _._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._