Practical Computing Exercise for Week 2 :Reworking of the Deer Jaw example

Download the template R markdown file for this workshop.

Aims of this practical exercise

In this exercise you will:

  • rework some aspects of the example given in ELMER, and the associated exercise,
  • get some practice using R markdown

Before you undertake this exercise…

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(Jaw, package="ELMER")
str(Jaw)
'data.frame':   10 obs. of  5 variables:
 $ Age      : Factor w/ 10 levels "<1","1+","2+",..: 1 2 3 4 5 6 7 8 9 10
 $ Midage   : num  0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5
 $ Number   : int  71 250 210 59 44 34 12 9 8 7
 $ JawLength: num  186 232 255 272 272 ...
 $ SD       : num  21.2 16.6 15.3 11.1 12.9 ...

Fit all possible models

Replicate the model fitting done by Brook & Arnold (1985) as shown in ELMER. Make sure you fit jaw length to the log of age, with and without using weights, and provide a graph to show the model.

Hint: Use weight=Number/SD^2 to get the weighted model.

Exercise

Use the value k=0.67 to fit the weighted and unweighted models taking the form:

\[y = A - B e^{-kt} \]

where t is the age of the deer.

Use these models to predict jaw length for the range of ages and plot JawLength against Age with the fitted curves added.

Optional extra task

Vary the value of k to see if the model can be made to fit the data better.

Solutions

You should compare your work with the solutions for this workshop.