Reputation:
I did a simple regression analysis and wanted to plot the residuals against the fitted values to see their behaviour. Afterwards I wanted to check if the residuals are normally distributed. So I did:
summary(lm(Gesamt~PopTotal+HDI))
residuen<-summary(lm(Gesamt~PopTotal+HDI))$residuals
fitted<-summary(lm(Gesamt~PopTotal+HDI))$fitted.values
plot(fitted,residuen)
The problem is, that,
summary(lm(Gesamt~PopTotal+HDI))$fitted.values
gives NULL
as a result, so does that mean there are no fitted values? I guess this is due to some missing values, but I don't know. And how can R calculate residudals but not the fitted values?
My data set can be found here: http://www.sendspace.com/file/8e27d0
Upvotes: 2
Views: 3791
Reputation: 195
data=olympiadaten
to your codesummary.lm()
, the method the generic summary()
calls when its argument is of class lm
, doesn't have $fitted.values
, but lm()
does. Try changing summary(lm(Gesamt~PopTotal+HDI))$fitted.values
to
lm(Gesamt~PopTotal+HDI, data=olympiadaten)$fitted.values
str()
Upvotes: 5