Question: The code chunk below fits each of the candidate models to the full dataset. The piecewise linear model is nested in the linear model and

The code chunk below fits each of the candidate models to the full dataset. The piecewise linear model is nested in the linear model and could be assessed using statistical significance, but the smooth model is not nested in anything else. (Also, comparing a piecewise model with a changepoint at 7 to a piecewise model with a changepoint at 8 would be a non-nested comparison...) linear_mod = lm(armc ~ weight, data = child_growth) pwl_mod = lm(armc ~ weight + weight_cp7, data = child_growth) smooth_mod = gam(armc ~ s(weight), data = child_growth) As before, I'll plot the three models to get intuition for goodness of fit. child_growth |> gather_predictions(linear_mod, pwl_mod, smooth_mod) |> mutate(model = fct_inorder(model)) |> ggplot(aes(x = weight, y = armc)) + geom_point(alpha = .5) + geom_line(aes(y = pred), color = "red") + facet_grid(~model) It's not clear which is best - the linear model is maybe too simple, but the piecewise and non-linear models are pretty similar! Better check prediction errors using the same process as before - again, since I want to fit a gam model, I have to convert the resample objects produced by crossv_mc to dataframes, but wouldn't have to do this if I only wanted to compare the linear and piecewise models

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!