This problem makes use of the following table.

You can create the table in R as follows:
df <- data.frame(observation = rep(c(26.5, 37.2, 57.3, 90.8, 20.2, 89.8)),
censoring = rep(c(1, 1, 1, 0, 0, 0)),
covariate = rep(c(0.1, 11, -0.3, 2.8, 1.8, 0.4)), stringsAsFactors = T)
ifelse() and as.factor() functions to add a new column to the
dataframe, named group, containing factor levels "Group 1" and "Group 2".fit.km. Be sure to label the curves so that it is clear
which curve corresponds to which group. By eye, does there appear to be a
difference between the two groups’ survival curves? Answer the
question below.
group indicator
as a covariate, store the model in the variable fit.cox. Inspect the output of the model and answer the following question.
logrank.test.
Verify that the log-rank test statistic equals the score statistic
for the Cox model and answer the following question.
NOTE: the outputs of
logrank.testandsummary(fit.cox)return rounded \(p\)-values. In order to compare the exact \(p\)-values, inspect the appropriate attributes of the objects.
Assume that:
ISLR2 library has been loaded.survival library has been loaded.