

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


22S:138, Bayesian Statistics
Fall 2008, Homework 7
starting point until an event occurs. The probability density function for a randomvariable Y drawn from an exponential distribution with parameter
λ
is
p(
y^
λ)
λ e
â λy
< y <
Researchers wish to compare 5 medications that reduce fever.
These medications
are all different formulations of the same drug (capsule, liquid, tablet, etc.).
The
experiment involves 30 patients, each with a temperature of at least 102 degrees. Sixpatients are randomly assigned to medication 1, six patients to medication 2, etc.After the patient takes the medication assigned to him, his temperature is monitoredcontinuously.
The outcome variable of interest is the time in hours from when the
medication is taken until the patientâs temperature goes below 99.5 degrees.Let
y
ij^
denote this time for patient
j
who received medication
i
The researchers will carry out a Bayesian analysis.
They assume that all the times
for patients receiving the same medication, say
i , follow an exponential distribution
with the same parameter
λ
.i
They believe that the
λ
s for different treatments are
different, but they have no idea of which ones will be larger or smaller.Below is WinBUGS code for fitting a 3-stage hierarchical model to their data. model {for (i in 1:N) {
for (j in 1:M) {
Y[i,j] ~ dexp( lambda[i])
lambda[i] ~ dgamma( alpha, beta)
} alpha ~ dgamma( 1,1)beta ~ dgamma(1,1)overall <- alpha / beta}^ (a) Draw a directed graph for this model.
You may either do this by hand or use
DoodleBUGS or any graphing software that you know. (b) Derive expressions proportional to the full conditional distributions for lambda[i],
alpha, and beta.
If any of them are standard distributions, identify them by
family and parameters. If any of them are not standard distributions, say so.
model {for (i in 1:N) {
for (j in 1:M) {
Y[i,j] ~ dexp( lambda[i])
lambda[i] ~ dgamma( alpha, beta)
} alpha ~ dgamma( a1, b1)beta ~ dgamma(a2, b2 )a1 ~ dexp(2)b1 ~ dexp(2)a2 ~ dexp(2)b2 ~ dexp(2)overall <- alpha / beta}^ (a) Will the full conditionals for the lambda[i]s change? Why or why not?(b) Derive expressions proportional to the full conditionals for alpha, beta, a1, and
b1. If possible, identify them as standard distributions.
You will fit a linear regression model to the temperature/heart rate data discussed in class.This dataset is available in WinBUGS format under âDatasetsâ on the course web pageas ânormtbug.dat.â You may copy it from there into a WinBUGS window.
We will con-
sider heart rate the response variable and body temperature the independent or predictorvariable.See the lab 5 handout for example code for fitting a regression model.
You will need to
change the variable names in the code to match the variable names in the data (i.e. âheartâinstead of âY,â etc.).You will use the noninformative priors from the example code.
mu[i] <- alpha + beta * (temp[i]-temp.bar) Run 3 separate 1000-iteration samplers.
Use the following initial values.
Monitor
alpha, beta, and sigma.
list(alpha = -100, beta = 5, tau = 1)list(alpha = 0, beta = 2.5, tau = .1)list(alpha = 100, beta = 0, tau = 10)
Look at history plots of all 3 chains together, as well as autocorrelation plots. Alsorun the Gelman and Rubin diagnostic. (The only plot you need to print is the historyplot for
α
Write a paragraph describing the plots and commenting on whether the samplers areconverging satisfactorily.
How many initial iterations should you throw out in order that the remainingiterations appear to be draws from the target distribution?
puting them starting at the first iteration that you do not throw out. Use the posteriormeans of
α
and
ÎČ
to hand-calculate the expected value of
heart
when
temp
Recall that the covariate has been centered.
linearity, or unequal variance, etc.
In the data list, change the last value of âheartâ to NA. Then fit the
model again. Run the same number of iterations as you threw out in a previous step.Then start monitoring heart[130] as well as alpha, beta, and sigma.
Obtain a 95%
prediction interval for heart[130].
fit to a dataset of body temperatures and heart rates measured on a different randomsample of 100 healthy adults. The predictor variable was centered in this analysis.
Model: MODEL
Dependent Variable: heart
Analysis of Variance
Sum of
Mean
Source
Squares
Square
F Value
Pr > F
Model
Error
Corrected Total
Root MSE
R-Square
Dependent Mean
Adj R-Sq
Coeff Var
The REG Procedure
Model: MODEL
Dependent Variable: heart
Parameter Estimates Parameter
Standard
Variable
Estimate
Error
t Value
Pr > |t|
Intercept
temp
(a) Write one choice of informative prior based on this previous analysis.(b) Would the posterior variance of the regression slope parameter be larger or
smaller if you fit a model using this prior rather than the vague prior previ-ously used? Why? (You do not have to refit the model to answer this question.)