How to do it...

Perform the following steps to visualize the generalized additive model:

  1. Generate a scatter plot using the nox and dis variables:
        > plot(nox, dis)  
Scatter plot of variable nox against dis
  1. Add the regression to the scatter plot:
        > x = seq(0, 1, length = 500)
        > y = predict(fit, data.frame(nox = x))
        > lines(x, y, col = "red", lwd = 2) 
Fitted regression of gam on a scatter plot
  1. Alternatively, you can plot the fitted model using the plot function:
        > plot(fit)  
Plot of fitted gam
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset