I want to select models using regsubsetsregsubsets()
. I have a dataframe called olympiadaten (data uploaded: http://www.sendspace.com/file/8e27d0). I first attach this dataframe and then start to analyze, my code is:
attach(olympiadaten)
library(leaps)
a<-regsubsets(Gesamt ~ CommunistSocialist + CountrySize + GNI + Lifeexp +
Schoolyears + ExpMilitary + Mortality +
PopPoverty + PopTotal + ExpEdu + ExpHealth, data=olympiadaten, nbest=2)
summary(a)
plot(a,scale="adjr2")
summary(lm(Gesamt~ExpHealth))
screenshot of the plot: http://tinypic.com/r/2pq8agy/6
The graphic says, it should have an adjusted R squared of about 0.14, but when I look at the output, I get a value of 0.06435.
Here is the output of summary(lm(Gesamt~ExpHealth))
: summary(lm(Gesamt~ExpHealth))
I don't know what I might have done wrong, any help would be appreciated, thanks. (I could not attach both files correctly, maybe a moderator can attach them correctly, thanks).
And last but not least, some more questions: What is the difference between selecting models by AIC and by the adj. R squared? Both measure the fit and recognize the number of variables, so isn't the best model choosen by AIC also the model with the highest adj. r squared?
When I have 12 variables, this means, there are 2^12 possibilites of models, right? So does the regsubsets command calculate each model and shows the two best (nbest=2) of each size? If so do I really get the 'best' model? And when I do AIC using backwards selection (starting with the model which contains all variables), does this also end up with the same model that regsubsets says is the best?
- What is the difference between selecting models by AIC and by the adj. R squared?
- Both measure the fit and recognize the number of variables, so isn't the best model chosen by AIC also the model with the highest adj. r squared?
- When I have 12 variables, this means, there are $2^12$ possibilities of models, right?
- So does the
regsubsets()
command calculate each model and show the two best (nbest=2
) of each size? - If so, do I really get the 'best' model?
- And when I do AIC using backwards selection (starting with the model which contains all variables), does this also end up with the same model that
regsubsets()
says is the best?