---
title: "LDA_TP2"
output: html_notebook
---
# EXERCICE 1 (Parametric Regression model)
# 1) Study of "tongue" dataset
By using the data set *tongue* in *KMsurv* package, perform the following analyses.
## a) Test (Logrank and Gehan-Wilcoxon procedures) equality of the distributions on the dataset stratified by the covariate *type*.
```{r}
```
## b) Using the function survreg, consider a Weilbull regression model and a lognormal regression model. Are these models better than a model without covariates? Is the covariate type significant for the lifetime under consideration?
```{r}
```
# 2) Study of *larynx* dataset
## a) Test (Logrank and Gehan-Wilcoxon procedures) equality of the distributions on the dataset jointly stratified by the covariates *stage* and *age*.
## b) Consider a Weilbull regression model. Don't forget to specify that the variable \textsf{stage} is ordinal. Is this model better than a model without covariates? Specify the significant covariate(s). What is the effect of the covariate \textsf{stage=4} on the lifetime? What is the estimate of the shape parameter of the Weibull distribution (have a look on the help of survreg). What is your conclusion on the shape of the hazard function?
## c) Consider now a lognormal regression model. Do you obtain the same set of significant covariates?
# EXERCICE 2 (Semiparametric Regression model)
The function *coxph* allows to carry out a semiparametric inference under the Cox's model. We still consider the *larynx* dataset.
## 1) Try a cox's regression with two covariates in the model: \textsf{stage} and *age*. Consider the two options: *method=breslow* and *method=efron*. Comment your results. Is this model better than a model without covariates? What is(are) the significant covariate(s)? Do you find the same effect than in the parametric regression models of Exercise 1? What is the effect of the covariate *\textsf{*stage=4* on the lifetime?
## 2) Redo the inference keeping the only significant covariate.
## 3) Using *survfit* on the object obtained by the semiparametric inference of Question 2, draw the baseline Reliability function and its pointwise 95\% confidence interval.
# EXERCICE 3 (Semiparametric Regression model)
Load the package *JM* and the dataset *pbc2.id*. Consider *years* as the lifetime and *status2* as censoring indicator. You can use help R-function to learn about this dataset.
## 1) Carry out a Cox's semiparametric inference *sex* and *age* as covariates. Are the covariates significant? Specify the effect of the covariate *sex* and the difference between two individuals with one 10 years older than the other one.
## 2) Create a dataframe with two males and two females of age 40 and 50.
## 3) Using the *survfit* function with the above fitted semiparametric model, plot the survival estimates for the 4 different individuals.