Description Usage Arguments Value Author(s) References Examples

Provides the degrees of freedom for flexible continuous covariates in multivariate additive Cox models.

1 2 |

`time` |
For right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval. |

`time2` |
Ending time of the interval for interval censored or counting process data only. Intervals are assumed to be open on the left and closed on the right, (start, end]. For counting process data, event indicates whether an event occurred at the end of the interval. |

`status` |
The status indicator, normally 0=alive, 1=dead. Other choices are TRUE/FALSE (TRUE = death) or 1/2 (2=death). For interval censored data, the status indicator is 0=right censored, 1=event at time, 2=left censored, 3=interval censored. Although unusual, the event indicator can be omitted, in which case all subjects are assumed to have an event. |

`nl.predictors` |
Vector with covariates to be introduced in the additive Cox model with a nonlinear effect. |

`other.predictors` |
Vector with remaining covariates to be introduced in the additive Cox model. This will include qualitative covariates or continuous covariates with a linear effect. |

`smoother` |
Smoothing method to be used in the additive Cox model. Possible options are ‘ns’ for natural spline smoothing or ‘pspline’ for penalized spline smoothing. |

`method` |
The desired method to obtain the optimal degrees of freedom. If method ="AIC", then the AIC = (loglik -df) is used to choose the "optimal" degrees of freedom. The corrected AIC of Hurvich et. al. (method="AICc") and the BIC criterion (method = "BIC") can also be used. |

`mindf` |
Vector with minimum degrees of freedom for each nonlinear predictor. By default this value is a vector of of the same length of nl.predictors all with value 1, if smoother is 'ns'; a vector with the same length of nl.predictors all with value 1.5, if smoother is 'pspline'. |

`maxdf` |
Vector with maximum degrees of freedom for each nonlinear predictor. By default, when penalized spline is used (smoother='pspline'), the corrected AIC from Hurvich obtained in the corresponding univariate additive Cox model is used. When penalized spline is used (smoother='ns') a vector with the same length of nl.predictors all with values 1.5. |

`ntimes` |
Internel procedure which involves repetion of some convergence steps to attain the optimal degrees of freedom. By deafault is 5. |

`data` |
A data.frame in which to interpret the variables named in the arguments |

An object of class `list`

, basically a list including the elements:

`df` |
Degrees of freedom of the 'nl.predictors'. |

`AIC` |
Akaike’s Information Criterion score of the fitted model. |

`AICc` |
Corrected Akaike’s Information Criterion score of the fitted model. |

`BIC` |
Bayesian Information Criterion score of the fitted model. |

`myfit` |
Fitted (additive Cox) model based on the chosen degrees of freedom. |

`method` |
The method used for obtaining the degrees of freedom. |

`nl.predictors` |
Vector with the nonlinear predictors. |

Artur Araújo and Luís Meira-Machado

Eilers, Paul H. and Marx, Brian D. (1996). Flexible smoothing with B-splines and penalties. Statistical Science, 11, 89-121.

Hurvich, C.M. and Simonoff, J.S. and Tsai, Chih-Ling (1998). Smoothing parameter selection in nonparametric regression using an improved Akaike information criterion, JRSSB, volume 60, 271–293.

1 2 3 4 5 6 7 8 9 10 11 | ```
# Example 1
library(survival)
data(whas500)
mydf_ns <- dfmacox(time="lenfol", status="fstat", nl.predictors=c("los", "bmi"),
other.predictors=c("age", "hr", "gender", "diasbp"), smoother="ns", data=whas500)
print(mydf_ns)
# Example 2
mydf_ps <- dfmacox(time="lenfol", status="fstat", nl.predictors=c("los", "bmi"),
other.predictors=c("age", "hr", "gender", "diasbp"), smoother="pspline", data=whas500)
print(mydf_ps)
``` |

```
Loading required package: survival
Loading required package: splines
Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights, :
Loglik converged before variable 1,2,3,4,5,6,7,8,9,10 ; beta may be infinite.
$df
[1] 10 3
$AIC
[1] 2273.898
$AICc
[1] 2279.388
$BIC
[1] 2331.199
$myfit
Call:
coxph(formula = covar, data = data, x = TRUE)
coef exp(coef) se(coef) z p
ns(los, df = 10)1 -1.14e+01 1.12e-05 8.17e+02 -0.01 0.98886
ns(los, df = 10)2 7.25e+01 3.08e+31 6.99e+03 0.01 0.99172
ns(los, df = 10)3 -4.27e+01 2.76e-19 3.72e+03 -0.01 0.99083
ns(los, df = 10)4 1.47e+01 2.45e+06 1.63e+03 0.01 0.99281
ns(los, df = 10)5 1.52e+01 3.99e+06 1.63e+03 0.01 0.99257
ns(los, df = 10)6 1.52e+01 3.96e+06 1.63e+03 0.01 0.99258
ns(los, df = 10)7 1.50e+01 3.34e+06 1.63e+03 0.01 0.99266
ns(los, df = 10)8 3.51e+00 3.35e+01 2.95e+02 0.01 0.99049
ns(los, df = 10)9 4.11e+01 7.38e+17 4.42e+03 0.01 0.99258
ns(los, df = 10)10 -6.08e+00 2.30e-03 1.80e+02 -0.03 0.97306
ns(bmi, df = 3)1 -1.35e+00 2.60e-01 3.68e-01 -3.67 0.00025
ns(bmi, df = 3)2 -1.64e+00 1.95e-01 9.86e-01 -1.66 0.09697
ns(bmi, df = 3)3 1.95e-01 1.21e+00 7.12e-01 0.27 0.78454
age 5.80e-02 1.06e+00 6.70e-03 8.66 < 2e-16
hr 1.51e-02 1.02e+00 2.94e-03 5.13 2.9e-07
gender -1.68e-01 8.45e-01 1.51e-01 -1.11 0.26655
diasbp -1.21e-02 9.88e-01 3.58e-03 -3.38 0.00071
Likelihood ratio test=215 on 17 df, p=0
n= 500, number of events= 215
$method
[1] "AIC"
$nl.predictors
[1] "los" "bmi"
$df
[1] 5.706318 2.341832
$AIC
[1] 2277.054
$AICc
[1] 2280.871
$BIC
[1] 2317.581
$myfit
Call:
coxph(formula = covar, data = data, x = TRUE)
coef se(coef) se2 Chisq DF p
pspline(los, df = 5.7), l 0.01216 0.01474 0.01461 0.68089 1.00 0.40928
pspline(los, df = 5.7), n 14.12705 4.71 0.01201
pspline(bmi, df = 2.3), l -0.04164 0.01470 0.01466 8.02234 1.00 0.00462
pspline(bmi, df = 2.3), n 6.58479 1.34 0.01725
age 0.05686 0.00666 0.00665 72.84808 1.00 < 2e-16
hr 0.01350 0.00284 0.00283 22.53556 1.00 2.1e-06
gender -0.24893 0.14445 0.14407 2.96997 1.00 0.08482
diasbp -0.01190 0.00356 0.00355 11.17489 1.00 0.00083
Iterations: 4 outer, 14 Newton-Raphson
Theta= 0.263
Theta= 0.867
Degrees of freedom for terms= 5.7 2.3 1.0 1.0 1.0 1.0
Likelihood ratio test=202 on 12 df, p=0 n= 500
$method
[1] "AIC"
$nl.predictors
[1] "los" "bmi"
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.