HohNumbis
HohNumbis

Reputation:

Residuals but no fitted values from a regression model in R

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

Answers (1)

miura
miura

Reputation: 195

  1. You could make your problem more reproducible by adding data=olympiadaten to your code
  2. summary.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
  3. In general you can check out what an object consists of in R by str()

Upvotes: 5

Related Questions