Markov Chain Monte Carlo

Part 1

The R data set in the file

loaded by R command

load(url("http://www.stat.umn.edu/geyer/8054/hw/hw12/pois.rda"))
is data for Poisson regression.

The model of interest is fit by the command

out <- glm(y ~ (v1 + v2 + v3 + v4 + v5 + v6)^3,
    family = poisson, data = dat, x = TRUE)
the argument x = TRUE saying that the model matrix should be returned as part of the object, that is, as out$x.

Use the R function metrop in the mcmc library to simulate the posterior distribution of the regression coefficients for this model when a flat prior is used (flat on the regression coefficient scale).

Part 2

Redo part 1 with everything the same except now we wish to simulate conditional on the Intercept regression coefficient being zero, as would be appropriate when the sampling distribution is assumed multinomial rather than Poisson.

The Intercept is the first regression coefficient, as can be seen by looking at colnames(out$x).