Advanced Modeling in R

Non-linear, Bayesian, and mixed effect methods
R. Condit
Smithsonian Tropical Research Institute, 7-9 May 2012


CTFS & SIGEO

Assignments

  1. Fit a linear model with optim
  2. Fit a linear model with variable SD
  3. Fit a non-linear model to quantitative data
    1. Model types
      • treeheight: ht as a function of dbh (extract one species, eg quaras or tri2tu or pri2co)
      • Use data from a single species to estimate the 3 parameters using maximum likelihood and a Gaussian error.
      • y = Hmax(    −axb)
1 − e (it’s in teaching.functions.r)
        Hmax, a, and b are parameters, y is height and x is dbh.
    2. grwfull300: growth as a function of dbh
      • y x + log(x) (write yourself)
    3. Error functions
      • Try first with Gaussian error
      • For growth rates, then use log-normal or Gamma error (but beware that growth must then be > 0)

  4. Fit linear and non-linear models with Metropolis method
    1. Linear
      • Test function linearfit.Bayes in file modelfitBayes.intro.r with any linear model
      • Plot parameter runs
      • Find confidence limits
    2. Adapt linearfit.Bayes to asymptotic (or other model of your preference)
  5. Simulation: Create a simulated correlation and test how well lm fits the parameters

  6. Program a Gibbs sampler for tree height model
  7. Run lmer on growth data
  8. Run lmer on full growth data
  9. Run lmer on treemass data