Solved – How to compute goodness of fit for a linear model in R

goodness of fitrregression

I have fit a linear model using the lm function in R…

model <- lm(trans.baseline.CD4 ~ hiv$Julian.Date)

… and I would like to assess the quality of the model's fit. Is there a function in R that will do this? Alternatively, I found a formula for goodness-of-fit involving the sum of squared residuals given the null and alternative hypotheses, but I don't know how to get these values either. Any pointers?

Thanks!

Best Answer

It all starts with

 summary(model)

after your fit. There are numerous commands to assess the fit, test commands, compare alternative models, ... in base R as well as in add-on packages on CRAN.

But you may want to do some reading, for example with Dalgaard's book or another introduction to statistics with R.