[go: up one dir, main page]

0% found this document useful (0 votes)
64 views2 pages

Inverse Gamma & ANCOVA Exercises

Uploaded by

pulak.pk.kuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views2 pages

Inverse Gamma & ANCOVA Exercises

Uploaded by

pulak.pk.kuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Exercises for the lecture

Institute for Statistics


Linear Models Daniel Ochieng
MZH, Room 7240
E-Mail: dochieng@[Link]
Summer Semester 2024

Exercise 05

Tasks
13. Inverse gamma distribution.
As is known, the gamma distribution with parameters α > 0 and r > 0 has a Lebesgue
density fα,r , given by

αr r−1
fα,r (x) = x exp(−αx) 1[0,∞) (x).
Γ(r)

where Γ denotes Euler’s gamma function, defined by


Z ∞
Γ(r) = y r−1 exp(−y)dy, r > 0.
0

(a) From this derive the Lebesgue density of the inverse gamma distribution.
Hint: If Z ∼ Gamma(α, r), then the distribution of Z −1 is called inverse gamma distri-
bution with parameters α and r.
(b) Calculate the first two moments of the inverse gamma distribution. For which values of
(α, r) does the expected value or variance exist in R>0 ?
14. A posteriori distribution of the parameters of the ANCOVA model.

Assume that y = (y1 , . . . , yn )⊤ is an n×1 vector of independent observations that depends on


xi which is a p×1 vector. The regression model is y = X β +ϵϵ, where now X = (x x⊤ ⊤ ⊤
1 , . . . , xn )
is the n × p matrix of regressors with x ⊤ i as the i th
-row and is assumed fixed, β are the
regression coefficients and ϵ = (ϵ1 , . . . , ϵn ) are the error terms such that ϵi ∼ N (0, σ 2 ) and
ϵ ∼ M V N (00, σ 2I n ). Using the priors

β , σ 2 ) = p(β|σ 2 )p(σ 2 ) = N (µ
p(β µβ , σ 2V β ) × IG(a, b) = N IG(µ
µβ , V β,a,b ),

where IG denotes the Inverse Gamma distribution and NIG is the Normal-Inverse Gamma
distribution. Prove that the posterior distribution also belongs to the NIG distribution and
hence this is a conjugate prior distribution.
15. Programming task-Normal linear model.
Suppose we are interested in predicting a baby’s birthweight Yi based on the gestational
age Ai and the gender Gi of the baby. This data is named birthweight in the R package
LearnBayes. For the standard linear model assume that

yi = β0 + β1 ai + β2 gi + ϵ,

for which the ϵi are i.i.d N (0, σ 2 ).

1
(a) Use the R function lm to fit this model by least-squares. From the output, assess if
the effects age A and gender G are significant, and if they are significant, describe the
effects of each covariate on birthweight.
(b) Suppose a uniform prior is placed on the regression parameter vector β = (β0 , β1 , β2 ).
Use the function blinreg to simulate a sample of 5000 draws from the joint posterior
distribution of (β, σ 2 ). From the simulated sample, compute the posterior means and
standard deviations of β1 and β2 . Check the consistency of the posterior means and
standard deviations with the least-squares estimates and associated standard errors
from the lm run.
(c) Suppose one is interested in estimating the expected birthweight for the male and
female babies of gestational weeks 36 and 40. From the simulated draws of the posterior
distribution and function binregexpected, construct 90% interval estimates for 36-week
males, 36-week females, 40-week males, and 40-week females.
(d) Suppose instead that one wishes to predict the birthweight for a 36-week male, a 36-
week female, a 40-week male, and a 40-week female. Use the function blinregpred and
the simulated posterior sample to construct 90% prediction intervals for the birthweight
for each type of baby.

You might also like