Question on lm(): When does R-squared come out as NA?
On Wed, Sep 28, 2005 at 08:23:59AM +0100, Prof Brian Ripley wrote:
I've not seen a reply to this, nor ever seen it. Please make a reproducible example available (do see the posting guide).
It was a mistake on my part. Just in case others are able to recognise the situation, what was going on was that all the objects being used in the lm() call were zoo objects. It is a mystery to me as to why everything should work correctly but the R2 should break, but that happened. I found that when I switched to coredata(z) all was well. Gabor reminded me that I should really be using his dyn package so as to avoid such situations. Sorry for the false alarm, -ans.
lm(formula = rj ~ rM + rM.1 + rM.2 + rM.3 + rM.4)
Residuals:
1990-06-04 1994-11-14 1998-08-21 2002-03-13 2005-09-15
-5.64672 -0.59596 -0.04143 0.55412 8.18229
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.003297 0.017603 -0.187 0.851
rM 0.845169 0.010522 80.322 <2e-16 ***
rM.1 0.116330 0.010692 10.880 <2e-16 ***
rM.2 0.002044 0.010686 0.191 0.848
rM.3 0.013181 0.010692 1.233 0.218
rM.4 0.009587 0.010525 0.911 0.362
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.044 on 3532 degrees of freedom
Multiple R-Squared: NA, Adjusted R-squared: NA
F-statistic: NA on 5 and 3532 DF, p-value: NA
rM.1, rM.2, etc. are lagged values of rM. The OLS seems fine in every
respect, except that there is an NA as the multiple R-squared. I will
be happy to give sample data to someone curious about what is going
on. I wondered if this was a well-known pathology. The way I know it,
if the data allows computation of (X'X)^{-1}, one can compute the R2.
Ajay Shah Consultant ajayshah at mayin.org Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi