Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
STAT 5060 Advanced Modeling and Data Analysis
Assignment
1. Consider a GLM with count data as follows: for i = 1, · · · , n,
yi ∼ Poisson(µi), log(µi) = xTi β, (1)
where β = (−1, 1, 1, 1)T , xi = (1, xi1, xi2, xi3)T , xi1 ∼ U(0, 1), and
(xit2, xit3) ∼ N(µ,Σ) with µ = (0, 0)T and Σ =
[
1 0.2
0.2 1
]
.
(a) Generate data using the above setting with sample size n = 500.
(b) Estimate β based on Model (1) and the generated data.
(c) Repeat steps (a) and (b) for 10 times and calculate the Bias and
RMS of the parameter estimates.
[Hint: (i) Bias of βˆ is given by ( 1S
∑S
j=1 βˆj) − β0, where β0 is the true
value of β, βˆj is the estimate of β at the jth replication, S is the number
of replications; RMSE of βˆ is given by
[
1
S
∑S
j=1(βˆj − β0)2
] 1
2 . (ii) The R
packages and the corresponding functions are marked in red. (iii) In this
problem, use the stats package, via the glm.fit function ]
2. Consider an extended GLM with nominal data as follows: for i = 1, · · · , n,
yi ∼ Categorical(pii1, · · · , pii4), piij = P (yi = j),
log
piij
pii4
= xTi βj , j = 1, 2, 3,
(2)
where β1 = (−1,−1, 1)T , β2 = (−1,−1, 1)T , β3 = (1,−1, 1)T , and xi =
(1, xi1, xi2)
T with xi1 ∼ U(0, 1) and xi2 ∼ N(0, 1).
1
(a) Generate data using the above setting with sample size n = 800.
(b) Estimate β based on Model (2) and the generated data.
(c) Repeat steps (a) and (b) for 10 times and calculate the Bias and
RMS of the parameter estimates.
[Hint: the nnet package, via the multinom function]
3. Consider a GLM with longitudinal binary data as follows: for i = 1, · · · , n,
t = 1, · · · , T ,
yit ∼ Bernoulli(piit), logit(piit) = xTitβ + ui, (3)
where β is a vector of regression coefficients, xit = (1, xit1, xit2)
T , xit1 ∼
Bernoulli(0.5), xit2 ∼ N(0, 1), ui is a subject-specific random effect, and
ui ∼ N(0, σ2). The true values of the parameters are β = (−1,−0.5,−0.5)T
and σ2 = 1.
(a) Generate data using the above setting with n = 500 and T = 5.
(b) Estimate β and σ2 based on Model (3) and the generated data.
(c) Repeat steps (a) and (b) for 10 times and calculate the Bias and
RMSE of the parameter estimates.
4. Reanalyze Example 3.3 using cumulative logit models with and without
random intercept ui and compare the results obtained from these two
competing models.
[Hint: the ordinal package, via the clmm and clmm2 functions; the
mixor package, via the mixor function; the MCMCglmm package, via
family=“ordinal”; the brms package, e.g. via family=“cumulative”]