exercises for Wed Oct 13

1. On Wed Oct 6 we discussed Nils Exercises 22, 23, with the gamma-normal prior setups for nornal data and for normal linear regression. I've uploaded R scripts com37a and com38a for these analyses, with x = cigarette consumption and y = lung cancer death rates per 100,000 people. You should carry out similar analyses for the other y given in the cigarette consumption dataset.

2. We went through the essence of Ch 4, with emphasis on "the lazy Bayesian" recipe: use \theta given data approximately distributed as N_p(\hat\theta_\ml, \hat J_\total^{-1}), with the ML estimator and the inverse information matrix, \hat J_\total being minus the 2nd derivate matrix of the log-lik function computed at the ML.

3. Let y_1, ..., y_n come from a Poisson (\theta), with \theta having a Gamma(a,b) prior. Find the exact posterior, and compare with the "lazy Bayesian" normal approximation.

4. I've uploaded "egypt_data", life-lengths for 82 men and 59 women, from the Roman Era old Egypt, 2100 years ago. Fit Weibull models to these two datasets, with F(y) = 1 - \exp(-(y/a)^b), parameters (a_m,b_m) for men, (a_w,b_w) for women. For this you need to programme the logL functions, and maximise these numerically; see a few lines below. Then carry out "lazy Bayesian" analyses, (a) for prob = Pr(live longer than 40.0 years), men and women; (b) for median_men and median_women, and the difference delta = median_men - median_women.

Notes: use library(MASS) in R to have the "mvrnorm" on board, simulating from a given multinormal distribution. Also, try this, with variations: Weibull model log-likelihood, finding ML and the information matrix, here with "yym" as the 82 lifelengths for men.

logLm <- function(ab)
{
a <- ab[1]
b <- ab[2]
auxm <- -(yym/a)^b + log(b) + (b-1)*log(yym) - b*log(a)
sum(auxm)
}

minuslogLm <- function(ab)
{-logLm(ab)}

nilsm <- nlm(minuslogLm,c(10,1),hessian=T)
MLm <- nilsm$estimate
Jhatm <- nilsm$hessian
Sigmam <- solve(Jhatm)

Published Oct. 7, 2021 12:41 PM - Last modified Oct. 7, 2021 12:41 PM