Skip to content

a question regarding leaps

2 messages · Rajarshi Guha, John Fox

#
Hi,
  I'm using regsubsets from the leaps package to select subsets of
variables. I'm calling the function as

 lp <- regsubsets(x,y,nbest=5,nvmax=9)

Then I call plot to see which variables turned up in the models. I use
the R^2 scale and see my best model had a R^2 of 0.62.

However when I make a linear model using lm() with the same x my R^2 is
0.45. Should'nt I be seeing the same value of R^2?

I must be making a mistake somewhere but I'm not sure where - could
anybody provide a pointer as to what I'm doing wrong?

Thanks,

-------------------------------------------------------------------
Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------
If you believe in telekinesis, raise my hand.
#
Dear Rajarshi,
At 06:43 PM 1/29/2004 -0500, Rajarshi Guha wrote:
It's hard to know exactly from your description what the source of the 
problem is, but I'd guess that it's due to missing data: That is, the 
models fit by regsubsets() likely removed observations that were present 
when you fit the model by lm(). If this is the case, then you could make 
the two results consistent by filtering the missing data before using lm().

I hope that this helps,
  John

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox