Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MATH5885 Longitudinal Data Analysis

Term 2 2022

Assignment 1

Question 1) Assume we have longitudinal data for which a linear model for the response over time holds:

Yij  = β0 + β1tij  + εij                                                                                              (1)

for i = 1, . . . ,N and j = 1, . . . ,n, where the measurement times tj  are common to all N individuals (tij  = tj ) and all planned measurements have been collected. We can also write

Yi  = Xi β + εi

for the vector of measurements for individual i and

Y = Xβ + ε

for the vector of measurements for all individuals, for suitably chosen design matrices Xi  and X .  We denote, for the zero-mean vector ϵ, its block-diagonal matrix as V, with blocks denoted as Vi ,i  = 1, . . . ,N. We investigate the properties of two estimators for β:  the ordinary least squares estimator βˆOLS  = (XT X)1XT Y , and the generalized least squares estimator βˆGLS  = (XT V 1X)1XT V 1Y .

1. Write down the design matrices Xi  and X .

2. Derive expressions for the covariance matrices of the two competitive estimators:  the ordinary least squares estimator βˆOLS  = (XT X)1XT Y , and the generalized least squares estimator βˆGLS  = (XT V 1X)1XT V 1Y in terms of X and V .

3. Assume we have n = 5 and measurement times −2, −1, 0, 1, 2. Suppose that the (j,k) element of Σi  corresponds to an autoregressive covariance structure:

σ 2        

(1 − ϕ2 )

where ϕ ∈ ( −1, 1). Write out Σi  in full.

4. Derive explicit expressions for the covariance matrices of βˆOLS  and βˆGLS  under covariance model

(2), by proving (or checking) that

   1        ϕ          0            0         0   

1       ϕ    1 + ϕ2           ϕ           0          0     

Σi(−)1  =            0        ϕ      1 + ϕ2         ϕ        0       ,

   0        0           0         ϕ       1   

Your answer should involve the quantities N,σ 2  and ϕ .

5. Assuming that σ 2  = 1,n = 5 and measurement times −2, −1, 0, 1, 2, derive expressions for the relative efficiencies of the estimators, that is, derive

var(βˆk,GLS )

var(βˆk,OLS ) ,        k = 0, 1,

where, for example, βˆ0,GLS   denotes the GLS estimator and βˆ0,OLS   denotes the OLS estimator of β0 .  Write a simple R function which calculates the relative efficiency for a given argument ϕ . Using this function, calculate for ϕ = −0.9, −0.8, . . . 0, 0.1, 0.2, . . . , 0.9 the relative efficiencies, put these in a table (again using R). Comment on your findings about the behavior of the efficiency gains as a function of ϕ ∈ ( −0.9, 0.9).

6. Prepare two smooth” graphs in R (as ρ ranges in (-0.9,0.9) in small increments)-one graph for k = 0 and one for k = 1.

Hint: In your answer, you will need to show that

Xi(T)ΣiXi  =       !

You will also need to show that

Xi(T)Σi(−)1Xi  =

5 − 8ϕ + 3ϕ2 0

2(5 4ϕ(0) + ϕ2 ) !

Question 2) The comma-delimited text file assigone .txt on the course web page gives data from a randomised, placebo controlled, double-blind clinical trial of depression treatment for men.   The outcome of interest is a measure of depression with higher values corresponding to a greater level of depression. Men taking part in the trial were rated on this scale on two occasions prior to randomization, and then monthly for four consecutive months after treatment commenced. The variables in the dataset are six measurements taken at monthly intervals:  two baseline measurements, base1 and base2, and four post-baseline measurements month1, month2, month3 and month4. The first 20 patients (20 rows) belong to the placebo group, with the remaining 20 patients being treated with the depression drug.

1.  Calculate the mean of the two baseline measurements and the mean of the four post-baseline mea-    surements for each patient. For the patients with missing measurements, calculate the mean for    the available measurements only (use na .rm=T in R to achieve this, as in apply(x,1,mean,na .rm=T)). (This is known as an available case analysis).  Add these as new column to the data set (data    frame), and print out the first 6 rows to confirm the enhanced structure of your data.

2. Analyse the data using linear regression, with the mean post-baseline measurement as the re- sponse, with treatment group the only explanatory variable. Use the lm function in R  . If neces- sary, use the help of the function. (This analysis is equivalent to a two-sample t-test). Comment on the significance of the treatment effect when using level of significance α = 0.05. Also comment on the model’s r-square R2 .

3. Analyse the data using the difference  (mean post-baseline measurement minus mean baseline measurement) as the response, with treatment group the only explanatory variable.   (This is equivalent to a one-sample t-test on the pair-wise differences).  Comment on the significance of the treatment effect, and on the model R2 . Use α = 0.05.

4. Again using lm, analyse the mean post-baseline measurement as the response by using the treat- ment group and the two baseline measurements in the linear model. This is a covariance analysis model since it includes both qualitative and quantitative regressor variables but lm deals equally well with it. Interpret the treatment effect. Comment on the quality of the obtained model.

5. Analyse the data again.  Use the analysis of covariance, with the mean post-baseline measure- ment as the response.   In addition to treatment group, include the  mean of the two  baseline measurements in the model.

6. The two analyses  (in 4) and 5)) produce different results.   Intuitively, using the mean of the baseline measurements would be a reasonable strategy if the correlations of the baselines with the outcome measurement are the same. If, however, there were appreciable differences between the various correlations between baselines and outcomes then there might be some value in fitting the baselines separately. By considering the pooled correlation matrix calculated in the Exercises to Lecture 2, Week 1, examine whether this statement might explain some of the differences in the results from the two analyses.

7. Perform a summary measures analysis based on slopes. To this end, first use the lm function to calculate an estimated slope for each of the 40 patients, using the second baseline and subsequent measurements in fitting the regressions (i.e. omit the first baseline measurement in calculating the slope). Code the time points as −2, −1, 0, 1, 2. At the second stage, fit a regression model to the estimated slopes, including the first baseline measurement as an explanatory variable. Comment.

8. Use generalized least squares to fit the model

Yij  = β0 + β1 base1i + β2tj  + β3treati + β4tj  ∗ treati + εij

where Yij  are the measurements excluding the first baseline, tj  are the measurement times, taken to be  −2, −1, 0, 1, 2, base1i   is the first baseline measurement, treati   is a treatment indicator. Note that you may need to reshape the data in a long” form. You can follow the example in the Lecture 2 of week 1 or simply reshape using the as .vector applied on your data frame. Assume a compound symmetry covariance structure.  Check the help of the R function gls, part of the nlme package which you will need to load using library(nlme). The syntax is

gls(y~x,correlation=corCompSymm(form=~1 |id),na .action=na .omit)