Download the template R markdown file for this workshop.
In this exercise you will:
You need to have installed R, RStudio, and the necessary packages for
the course, including the ELMER
package. See how to
get set up for this course
data(TreeVols, package="ELMER")
str(TreeVols)
'data.frame': 31 obs. of 3 variables:
$ Volume: num 0.29 0.29 0.28 0.46 0.53 0.55 0.44 0.63 0.56 0.68 ...
$ Height: num 21.3 19.8 19.2 21.9 24.6 25.2 20.1 24.3 22.8 24 ...
$ Girth : int 210 218 223 266 271 274 279 281 284 287 ...
Fit y to x1 and x2.
Fit \(\ln y\) to \(\ln x_1\) and \(\ln x_2\). Is this model definitely better than the first model?
Fit \(y^*(\lambda)\) to \(x_1\) and \(x_2\). Estimate the value of \(\lambda\) by maximum likelihood. Is this model definitely better than the first model?
Hint: Use the boxcox()
function in the MASS
package.
library(MASS)
= boxcox(Volume ~ Height + Girth, data =TreeVols)
TreeVols.bc # to get exact value of lambda:
= TreeVols.bc$"x"[which.max(TreeVols.bc$"y")]
Lambda Lambda
Finally, which model would be expected to fit best, based on a physical model?
You should compare your work with the solutions for this workshop.