problem-12.8
problem-12.8
This model is actually done in the help page for the data set. We
can fit the model by running the command
> library(MASS) # load in help page
> example(wtloss)
> wtloss.fm
Nonlinear regression model
model: Weight ~ b0 + b1 * 2^(-Days/th)
data: wtloss
b0 b1 th
81.37 102.68 141.91
residual sum-of-squares: 39.24
> plot(Weight ~ Days, wtloss) # make scatterplot
> lines(predict(wtloss.fm) ~ Days, data = wtloss)
The value of b0 is the predicted long-term weight. If we want
the predicted amount after 365 days we have
> predict(wtloss.fm, newdata=data.frame(Days=365))
[1] 98.64
(Of course, predictions beyond the range of the data are not a good idea.)