Search code examples
rplotspline

How to obtain the QQ plot of a spline model R


I have a model that I've fitted using splines:

ssfit.3 <- smooth.spline(anage$lifespan ~ log(anage$Metabolic.by.mass), 
                         df = 3)

I'm trying to obtain the model diagnostics such as the residual plot and the QQ plot for this model. I know for a linear model you can do

plot(lm)

which outputs all the different plots. How can I do this with spline models since plot(ssfit.3) does not output the same?


Solution

  • Extract the residuals and use qqnorm()/qqline().

    example(smooth.spline) ## to get a model to work with
    qqnorm(residuals(s2m))
    qqline(residuals(s2m))