Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Instructions for assignment: Please use the latest version of R (Version 4

Instructions for assignment: Please use the latest version of R (Version 4

Statistics

Instructions for assignment: Please use the latest version of R (Version 4.1.3) and RStudio (Version 2022.02.0) to complete this assignment. You will need to submit two documents for this assignment. The first document is a pdf document named Assign1 StNo.pdf which will provide all your analysis and solutions for this assignment. To produce this pdf document you will need to use LaTeX. The LaTeX document which was used to produce this assignment is named Assign1 StNo.tex and is located in the Assignment 1 folder in the Topic 4 section of LMS. You can use LaTeX online via Overleaf which is a website dedicated to producing documents from LaTeX. To use LaTeX, follow the instructions in the Overleaf.pdf document located in the Assignment 1 folder. The second document that you will need to submit is an R document named Assign1 R StNo.R which is located in the Assignment 1 folder. This document should provide the R code you used to perform all your data manipulation and analysis.

Assessment information for assignment: There are a total of 50 marks for this assignment.

Description of assignment: The data and information presented in this assignment is adapted from a clinical trial presented in Gregoire et al. (1996)[1] and is stored in the file named Postnatal.csv located in the Assignment 1 folder in the Topic 4 section of LMS. Women with major depression which began within 3 months of child-birth were randomly assigned to the treatment group or to the placebo group. The treatment group consisted of patients using the Estrogen patch and the placebo group was made up of patients using the Placebo patch. The women were assessed pre-treatment (directly before administration of the treatment) and at post-treatment (1 month, 2 months, 3 months, 4 months, 5 months and 6 months after the administration of the treatment), using the Edinburgh postnatal depression scale (EPDS). This scale ranges from 0 to 30 and a score of at least 10 is regarded as possible depression. The variables of interest for Assignment 1 are:

  • Patient: This is a factor variable that identifies the patient (woman).
  • P: This is the pre-treatment postnatal depression score less the mean pre-treatment postnatal depression score. This variable is treated as a continuous variable.
  • T: This is a factor (categorical) variable that identifies the treatment administered to the patient. It has 2 levels (0 = Placebo patch, 1 = Estrogen patch).
  • M: This is the number of months after treatment less one month. It is treated as a continuous variable.
  • E: The postnatal depression score which is treated as a continuous variable.

2 marks are allocated for each question that requires the use of the R computer package. These marks are awarded using the following criterion:

1. R code that accurately produces the analysis/output required in the question.

Answer the following questions.

Graphical analysis

  1. Use the R computer package to produce a plot of the mean E vs M grouped by T. The scale of the vertical and horizontal axes of your figure should be identical to Figure 1 below (2 marks). Do you think that the interaction effect between T and M should be included in the linear mixed model? Explain.

(3 marks)

Figure 1: Plot of mean E vs M grouped by T

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

30

25

20

 

E_mean

15

 

10

5

0

                                     0                                                                                                             1                                                                                                              2                                                                                                             3                                                                                                             4                                                                                                              5

M

  1. Use the R computer package to produce a plot of the values of E vs M for each Patient grouped by T. The scale of the vertical and horizontal axes of your figure should be identical to Figure 2 below (2 marks). Do you think that the random effect of M on E should be included in the linear mixed model? Explain (3 marks). Do you think that the random intercept should be included in the linear mixed model? Explain. (3 marks)

Figure 2: Plot of E vs M for each Patient grouped by T

 

0

1

0

1

2

3

4

5

0

1

2

3

4

5

0

5

10

15

20

25

30

M

E

 

Describing the model

The researchers in the study set up the following linear mixed model to analyze their research questions.

Eti = β0 + β1 Pi + β2 Ti + β3 Mti + β4 Pi × Ti + β5 Pi × Mti + β6 Ti × Mti

                                                     + µ0i + µ1i Mti + εti,                                                                                                       (1)

  • where Eti is the postnatal depression score for patient i (i = 1,...,61) at occasion t (t = 1,2,...,6),
  • Pi is the pre-treatment postnatal depression score for patient i less the mean pre-treatment postnatal depression score (averaged over patients),
  • Ti = 1 if patient i is administered the Estrogen patch, and 0 otherwise,
  • Mti is the number of months after treatment less one month, for patient i at occasion t,
  • β0 is the fixed intercept,
  • β1, β2 and β3 are the the fixed simple effects of P, T and M, respectively,
  • β4, β5 and β6 is the fixed interaction effects of P × T, P × M and T × M respectively,
  • µ0i is the random intercept specific to patient i,
  • µ1i is the random effect of M on E specific to patient i,
  • εti is the random error associated with measuring E at occasion t, for patient i.

For model (1), the researchers choose an unstructured structure for the variance-covariance matrix of the random effect vector, µi. That is, the variance-covariance matrix of the random effect vector, µi, is

                                                                                                                   ñ ψ        ψ ô

                                                                                                         D

     ,

 

  • where ψ0 and ψ1 denotes the variance of the random effects µ0i and µ1i, respectively,
  • ψ01 denotes the covariance between the random effects µ0i and µ1i.

Also for model (1), the researchers choose a diagonal structure for the variance-covariance matrix of the random error vector, εi. That is, the variance-covariance matrix of the random error vector, εi, is

? θ

? 0

?

? 0

R = ?? ? 0

? ? 0

?

0

0 θ 0

0

0

0

0

0 θ 0

0

0

0 0

0 θ 0

0

0

0 0

0 θ 0

0 ?

0 ?

?

0 ??.

0 ??

? 0 ?? θ

  • where θ denotes the constant variance of the random errors associated with patient i.

3. The researchers would like to express model (1) in matrix form, Yi = Xi β + Zi µi + εi, where Yi represents the response vector for patient i, Xi represents a matrix, for patient i, that contains the values of the predictors associated with the fixed effects of model (1), β is the fixed effect vector, Zi is a matrix, for patient i, that contains the values of the predictors associated with the random effects of model (1), µi is the random effect vector for patient i and εi is the random error vector for patient i. Answer the following questions.

  1. Write down the response vector, Yi, of model (1), for patient i. (2 marks)
  2. Write down the matrix, Xi, of model (1), for patient i. (5 marks) (c) Write down the fixed effect vector, β, of model (1). (1 mark)
  1. Write down the matrix, Zi, of model (1), for patient i. (2 marks)
  2. Write down the random effect vector, µi, of model (1), for patient i. (1 mark)
  3. Write down the random error vector, εi, of model (1), for patient i. (2 marks)

Testing for random effects

4. The researchers would like to test whether the random effect of M should be included in model (1). They decide to test, at the 5% significance level, the null hypothesis H0 : ψ1 = 0 vs the alternative hypothesis H1 : ψ1 > 0 using the REML-based likelihood ratio test p-value.

  1. Write down the reference model for this test. (1 mark)
  2. Write down the nested model for this test. (1 mark)
  3. Use the R computer package to perform this test. What is the p-value for this test? (1 mark)
  4. Which model would you choose (reference or nested) to continue your analysis? Explain. (2 marks)
  1. Fixed effect estimates for your final linear mixed model
  1. Use the R computer package to produce a table that lists the estimates of the fixed effects in model (1), together with their corresponding standard errors, degrees of freedom, observed test statistics and p-values. Present this table below. (2 marks)
  2. Interpret the estimates of β0, β2 and β6. (9 marks)
 

[1] Gregoire, A. J. P., Kumar, R., Everitt, B. S., Henderson, A. F., &Studd, J. W. W. (1996). Transdermal oestrogen for the treatment of severe postnatal depression. Lancet, 347: 930–933.

Option 1

Low Cost Option
Download this past answer in few clicks

18.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE