Delta Method

FW8051 Statistics for Ecologists

Learning Objectives

Understand how we can use the delta method to calculate SEs for functions of parameters

See also:

Picture of the following paper by Larkin Powell, "Approximating variance of demographic parameters using the delta method. A reference for avian biologists. published in The Condor.

Application: Growth of black bears

Code
library(Data4Ecologists)
data(beargrowth)
beargrowth <- beargrowth %>% filter(sex=="Female")
ggplot(beargrowth, aes(age, wtkg)) + 
  geom_point() + geom_smooth() + ylab("Weight (kg)") + xlab("Age (years)")+
  theme_bw() + 
  theme(axis.title = element_text(size = 22))
Black bear weight versus age data

\[Weight_i \sim N(\mu_i, \sigma^2_i)\] \[\mu_i = L_{\infty}(1-e^{-K(Age_i-t_0)})\] \[\sigma^2_i = \sigma^2|\mu_i|^{2\theta}\]

Want to quantify uncertainty in \(\hat{\mu}_i\)!

To quantify uncertainty in,

\[\mu_i = L_\infty(1-\exp(-k Age_i))\]

we have 3 options:

  • Bootstrap
  • Delta method
  • Baysian inference

\[\mu_i = L_\infty(1-\exp(-k Age_i))\]

If we estimate \(\theta =(L_\infty, k)\) using Maximum likelihood, and our sample size is large, we know:

\[\hat{\theta} \sim MVN(\theta, I^{-1}(\theta)) \text{ with: }\]

  • I(\(\theta) = \left[-\frac{\partial^2 logL(\theta)}{\partial \theta^2}\right]\) is the Hessian matrix associated with the negative log likelihood.

This will allow us to calculate confidence intervals for \(L_{\infty}\) and \(k\).

But, what about:

\(var(\mu_i) = var[f(\hat{L}_\infty, \hat{k})] = var(\hat{L}_\infty(1-\exp(-\hat{k} Age_i)))\)?

In the GLS section, we learned how to calculate the variance of a linear function of our paramters, \(var(\hat{\beta}_0 + X_i\hat{\beta}_1)\), using matrix multiplication:

\[\text{var}(X\beta) = X\Sigma X^T\]

where \(X\) is our design matrix, \(\Sigma\) is the var/cov matrix of our parameters:

\(X = \begin{bmatrix} 1 & X_1\\ 1 & X_2\\ \vdots & \vdots\\ 1 & X_n\\ \end{bmatrix}\) \(\Sigma = \begin{bmatrix} \sigma^2_{\hat{\beta}_0} & \sigma^2_{\hat{\beta}_0,\hat{\beta}_1}\\ \sigma^2_{\hat{\beta}_0,\hat{\beta}_1} & \sigma^2_{\hat{\beta}_1} \\ \end{bmatrix}\)

  • \(\sigma^2_{\hat{\beta}_0}, \sigma^2_{\hat{\beta}_1}\) = variance of \(\hat{\beta}_0\), \(\hat{\beta}_1\), respectively
  • \(\sigma^2_{\hat{\beta}_0,\hat{\beta}_1}\) = covariance of \(\hat{\beta}_0\) and \(\hat{\beta}_1\)

But, we have a non-linear function of our parameters:

\(\hat{\mu}_i = \hat{L}_\infty(1-\exp(-\hat{k} Age_i))\)

Delta Method

We can use a Taylors series (linear) approximation of the function we are interested in:

\(f(\hat{\theta}) \approx f(\theta) + f'(\theta)(\theta - \hat{\theta})\) \(\implies \widehat{var}(f(\hat{\theta})) \approx f'(\theta)\Sigma f'(\theta)^T |_{\theta=\hat{\theta}}\)

where \(\Sigma\) = the variance of \(\hat{\theta}\) (when \(\theta\) is a single parameter) or the variance/covariance matrix of \(\hat{\theta}\) when \(\theta\) is a vector.


Consider a simple example where we want to estimate \(f(\beta) = 1/\beta\). You are given \(\hat{\beta}\) and its standard error.1

How would we estimate \(var(1/\hat{\beta})\)?

  • \(f'(\beta) = -1/(\beta^2)\)

  • \(\widehat{var}(1/\hat{\beta}) = [-1/(\beta^2)](\widehat{var}(\hat{\beta}))[-1/(\beta^2)]\) = \(\frac{\widehat{var}(\hat{\beta})}{\hat{\beta}^4}\)

Black bear example

Let:

  • \(f(L_\infty, k) = L_\infty(1-\exp(-k Age_i))\)
  • \(f'(L_\infty, k) = (\frac{\partial f}{\partial L_\infty}, \frac{\partial f}{\partial k}) = (1-\exp(-k Age_i), L_\infty Age_i \exp(-kAge_i))\)
  • \(\Sigma\) be the asympototic variance/covariance matrix of \((L_\infty, k)\) given by the inverse of the Hessian matrix

Delta Method

\(var(\hat{L}_\infty(1-\exp(-\hat{k} Age_i))) \approx f'(\hat{L}_\infty, \hat{k})\Sigma f'(L_\infty, k)^T|_{L_\infty = \hat{L}_\infty, k=\hat{k}}\)

Implementation

In R:

  • use the deltavar function in the emdbook package to calculate the derivatives and variance; see Section 10.8 in the book
  • or, calculate the derivatives yourself (or using https://www.symbolab.com/solver/derivative-calculator), then roll your own with %*% for matrix multiplication.

Derivatives

Screenshot of online derivative calculator.