Assignment 3 Survival Analysis SVA 2020 Due date: 11.55pm 18 May 2020 Survival Analysis Assignment XXXXXXXXXX Rules for assignment submission are given in the document BCA Assessment Guide, which has...

1 answer below »
I need this done really well please by an expert really adept in R and or STATA please



Assignment 3 Survival Analysis SVA 2020 Due date: 11.55pm 18 May 2020 Survival Analysis Assignment 3 2020 1 Rules for assignment submission are given in the document BCA Assessment Guide, which has been mailed to you and is also on the Course Notes page in iLearn. While this document has been written for BCA students, it applies equally to Macquarie students. Please note you should include your name and the page number in a header or footer on each page. Question 1 [14 marks] The data file framing3.csv contains data from a subset of the Framingham Study. The study collected data at up to 3 visits and the file contains data for all available visits. I have arranged the data in single record per subject form with time2 and time3 the time of the second and third visits (there is no time1 as it is always 0) and cursmoke1, cursmoke2 and cursmoke3 the smoking status at each visit. We are interested in time to cardiovascular event. For each subject the final time is either of the cardiovascular event or censoring, that is there is only a single event possible for each subject. Name Description randid patient id time2 Start time of period 2 (years) time3 Start time of period 3 (years) sex Sex (1=Male, 2=Female) age Age at baseline (years) cursmoke1 Smoking status at start of period 1 (0=No,1=Yes) cursmoke2 Smoking status at start of period 2 (0=No,1=Yes) cursmoke3 Smoking status at start of period 3 (0=No,1=Yes) totchol Total Cholesterol (mg/dL) at baseline cvd Cardiovascular (CVD) event occurred (0=censored,1=yes) timecvd Time of CVD event (years) Note that no preliminary data analysis is required. Interest is just in application of the time- dependent covariates. a. Fit a model with covariates sex, age, totchol and rather than using smoking at baseline, allow for smoking status to change at each visit. Assume that smoking status doesn’t change between visits. Note: Assume that the covariates don’t need any transformation and ignore the violation of the proportional hazards assumption, as that is covered in part (d). This should be performed using the single record method. First test if the effect of current smoking changes at each period. b. Repeat part (a) using the multiple record method. That is first divide each record into records for each period and fit the data. c. Explain any problems that may occur with interpretation of the effect of current smoking. d. There is a problem with the proportional hazards assumption for total cholesterol. A variation of the model described on pages 178-9 of HL&M is to use a time dependent covariate with an interaction between total cholesterol and log(t+1), so that the coefficient for predictor j becomes βj(t) = βj + γj log(t + 1). This has the advantage over just log Survival Analysis Assignment 3 2020 2 that it is defined at t = 0. Add this interaction to the model in either (a) or (b), as results should be the same, summarise the results in a way that is meaningful to a clinician and explain. Tip: either log(x) or ln(x) will return the natural log of x in Stata. Question 2 [12 marks] The data file pstd.csv contains data from a fictitious study on PTSD (post traumatic stress disorder). The event is admission to hospital for PTSD. While the data is fictitious it is based on a real study. The following variables are given: Name Description id patient id event Event number (1=first event,etc.) trt Treatment group (0=Control, 1=Active treatment) age Age (in years) at study entry tstart Time observation started tstop Time observation stopped for event or censoring status Status at end of observation period (0=censored,1=event) Note that no preliminary data analysis is required. Interest is only in the application of the recurrent event models. a. Fit a model with treatment and age (at start of study) as covariates (no interaction) and a conditional risk set model (PWP-CP), with time from entry. Explain the model and what assumptions it makes about PSTD. b. Fit a model with treatment and age (at start of study for first period or at previous event) as covariates (no interaction) and a conditional risk set model (PWP-GT), with time from previous event. Explain the model and what assumptions it makes about PSTD. c. Using the model in (b) test whether the effect of treatment is different for events after the first event. d. Plot predicted survival for the first three events using the model in (b), for both treatments and mean age. What caution (together with any justification) should be made about interpreting these.
Answered Same DayMay 20, 2021

Answer To: Assignment 3 Survival Analysis SVA 2020 Due date: 11.55pm 18 May 2020 Survival Analysis Assignment...

Bezawada Arun answered on May 23 2021
130 Votes
#installing the required packages
install.packages("survminer")
library(dplyr)
library(survival)
library(survminer)
#reading the dataset
framing <- read.csv('fram
ing3.csv')
head(framing)
#Exploratory Data Analytics
miss <- function(x) return(sum(is.na(x)))
t(data.frame(apply(framing,2,miss)))
mi_re <- function(x,fuc)
{
y = x[!is.na(x)]
if(fuc=='mode')
{
m = unique(y)[which.max(tabulate(match(y,unique(y))))]
x = ifelse(is.na(x)==TRUE,m,x)
return(x)
}else if(fuc=='mean')
{
x = ifelse(is.na(x)==TRUE,mean(y),x)
return(x)
}

}
#passing connection to replace null values with mean and mode
framing1 = framing %>% mutate(totchol = mi_re(totchol,'mean'),
age = mi_re(age,'mean'),
cursmoke1 = mi_re(cursmoke1,'mode'),
cursmoke2 = mi_re(cursmoke2,'mode'),
time1 = rep(0.01,nrow(framing)),
time2 = mi_re(time2,'mean'),
cursmoke3 = mi_re(cursmoke3,'mode'),
time3 = mi_re(time3,'mean'))
head(framing1)
# ---------------------- 1.A ---------------------------------------------
#Building the model for time period 1
model.cox1 <- coxph(Surv(time1,cursmoke1)~age+sex+totchol,data = framing1)
model.cox1
summary(model.cox1)
survfit(model.cox1)
#Building model for time period 2
model.cox2 <- coxph(Surv(time2,cursmoke2)~age+sex+totchol,data = framing1)
model.cox2
summary(model.cox2)
survfit(model.cox2)
#Building model for time period 3
model.cox3 <- coxph(Surv(time3,cursmoke3)~age+sex+totchol,data =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here