G'day Glenn, On Tue, 2 Dec 2008 17:02:26 +1100 <[EMAIL PROTECTED]> wrote:
> Obviously the code is functioning properly then, but do you consider > this the best way of computing R^2 for a zero intercept? The way R does. What else would I say. ;-) That formula compares the variance explained by the model to the null-model in which all covariates are removed. > I just checked what excel and genstat do in this situation and the > R^2 they come up with reduces for a zero intercept rather than > increases. I am not surprised that excel does the wrong thing; just one more example where it misbehaves. But I am surprised to hear that genstat does the same, I thought that genstat was developed by statisticians.... > This seems more logical to me since fixing the intercept leads to a > model that, at least in appearance, explains less of the variance in > the data. If you use the formula for models with an intercept on models without an intercept then it may happen that you end up with a negative R^2. Try to explain that to a user; that a quantity that is called R-squared is negative. My only gripe is that if one does something like: fm <- lm(Y ~ A/x - 1, data) where A is a factor, R will handle this model as a no intercept term. Although it has implicitly an intercept and I just choose to use this formula since I was interested in parameterisation implied by this formula. But, you can always be subversive and say something like attributes(fm$terms)$intercept <- 1 before calling summary(fm) if you want to use the formula for models with intercept. Of course, in future versions (and past if you use an older one), it would be advisable to study summary.lm first to see if this trick will work; in R 2.8.0 it does. Cheers, Berwin ______________________________________________ R-help@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.