Hi,This assignment does not have any word limit. There are problems given in the document below and also you should use softwares like Rstudio & LaTeX
STA5ARM Assignment 1 Assignment 1 is due no later than 5pm Friday, 19th of April, 2019. In submitting your work, you are consenting that it may be copied and transmitted by the University for the detection of plagiarism. Submission is your guarantee that the below statement of originality is correct. “This is my own work. I have not copied any of it from anyone else.” NAME: Replace this text with your name. STUDENT NUMBER: Replace this text with your student number. Instructions for 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 3 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 100 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 3 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 post-treatment (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). • Treat: This is a factor (categorical) variable that identifies the treatment administered to the patient. It has 2 levels (0 = Placebo patch, 1 = Estrogen patch). • Time: This is a factor (categorical) variable that identifies the occasion the postnatal depression score was measured. It has 2 levels (0 = Pre-treatment, 1 = Post-treatment). • EPDS: The postnatal depression score which is treated as a continuous variable. The following criteria and marks are allocated for each question that requires the use of the R computer package: 1. R code that accurately produces the analysis required in the question. (2 marks) 2. R code that is easy to follow and commented clearly. (1 mark) Answer the following questions. 1Gregoire, 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. 1 https://lms.latrobe.edu.au/mod/folder/view.php?id=3316299 https://lms.latrobe.edu.au/mod/folder/view.php?id=3316299 https://lms.latrobe.edu.au/mod/folder/view.php?id=3316299 https://lms.latrobe.edu.au/mod/folder/view.php?id=3316299 1 Graphical analysis 1. Use the R computer package to produce a plot of the mean EPDS vs Time grouped by Treat. 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 Time and Treat should be included in the linear mixed model? Explain. (3 marks) Figure 1: Plot of mean EPDS vs Time grouped by Treat 5 10 15 20 25 0 1 Time EP DS _m ea n 2. Use the R computer package to produce a plot of the values of EPDS vs Time for each Patient grouped by Treat. 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 Time on EPDS should be included in the linear mixed model? Explain (2 marks). Do you think that the random intercept should be included in the linear mixed model? Explain. (2 marks) Figure 2: Plot of EPDS vs Time for each Patient grouped by Treat 0 1 0 1 0 1 0 10 20 30 Time EP DS 2 2 Describing the model The researchers in the study set up the following linear mixed model to analyze their research questions. EPDSti = β0 + β1 Timeti + β2 Treati + β3 Timeti × Treati + µ0i + µ1i Timeti + εti, (1) • where EPDSti is the postnatal depression score for patient i (i = 1, . . . , 61) at occasion t (t = 1, 2), • Timeti = 1 if the postnatal depression score for patient i is measured at post-treatment, and 0 otherwise, • Treati = 1 if patient i is administered the Estrogen patch, and 0 otherwise, • β0 is the fixed intercept, • β1 and β2 are the the fixed simple effects of Time and Treat, respectively, • β3 is the fixed interaction effect of Time× Treat, respectively, • µ0i is the random intercept specific to patient i, • µ1i is the random effect of Time on EPDS specific to patient i, • εti is the random error associated with measuring EPDS at occasion t, for patient i. 1. 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. (a) Write down the response vector, Yi, of model (1), for patient i. (2 marks) (b) Write down the matrix, Xi, of model (1), for patient i. (4 marks) (c) Write down the fixed effect vector, β, of model (1). (1 mark) (d) Write down the matrix, Zi, of model (1), for patient i. (2 marks) (e) Write down the random effect vector, µi, of model (1), for patient i. (2 marks) (f) Write down the random error vector, εi, of model (1), for patient i. (2 marks) 2. 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 = ñ ψ0 ψ01 ψ01 ψ1 ô , • 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 R = ñ θ 0 0 θ ô . • where θ denotes the constant variance of the random errors associated with patient i. For model (1), derive the variance-covariance matrix of the response vector, Yi, for patient i. Use the the same notation as above and show all workings. (5 marks) 3 3 Testing for random effects 1. The researchers would like to test whether the random effect of Time 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. (a) Write down the reference model for this test. (1 mark) (b) Write down the nested model for this test. (1 mark) (c) Use the R computer package to perform this test. What is the p-value for this test? (1 mark) (d) Which model would you choose (reference or nested) to continue your analysis? Explain. (2 marks) 2. The researchers would like to test whether the random intercept should be included in the model you chose in question 1 part (d) of section 3. They decide to test, at the 5% significance level, the null hypothesis H0 : ψ0 = 0 vs the alternative hypothesis H1 : ψ0 > 0 using the REML-based likelihood ratio test p-value. (a) Write down the reference model for this test. The reference model must be the model you chose in question 1 part (d) of section 3. (1 mark) (b) Write down the nested model for this test. (1 mark) (c) Use the R computer package to perform this test. What is the p-value for this test? (1 mark) (d) Which model would you choose (reference or nested) to continue your analysis? Explain. (2 marks) 4 Testing for fixed effects 1. The researchers would like to test whether the fixed interaction effect of Time×Treat should be included in the model you chose for question 2 part (d) of section 3. They decide to test, at the 5% significance level, the null hypothesis H0 : β3 = 0 vs the alternative hypothesis H1 : β3 6= 0 using the ML-based likelihood ratio test p-value. (a) Write down the reference model for this test. The reference model must be the model you chose in question 2 part (d) of section 3. (1 mark) (b) Write down the nested model for this test. (1 mark) (c) Use the R computer package to perform this test. What is the p-value for this test? (1 mark) (d) Which model would you choose (reference or nested) to continue your analysis? Explain. (2 marks) 4 5 Diagnostics of your final linear mixed model Use the following final linear mixed model to answer the questions in this section and in section 6, EPDSti = β0 + β1 Timeti + β2 Treati + β3 Timeti × Treati + µ0i + εti. (2) 1. Use the R computer package to produce a figure that checks the agreement over time between the predicted marginal values of EPDS (that come from fitting model (2) to the data) and the observed mean values of EPDS, for each level of Treat. Present this figure below and make sure the scale of the vertical and horizontal axes of your figure is identical to Figure 3 below. (2 marks) Figure 3: Predicted marginal and observed mean values of EPDS as a