/
psfmi_CoxModels.Rmd
174 lines (126 loc) · 5.25 KB
/
psfmi_CoxModels.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
title: "Pooling and Selection of Cox Regression Models"
author: "Martijn W Heymans"
date: "`r Sys.Date()`"
output:
rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Pooling and Selection of Cox Regression Models}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
# Introduction
With the `psfmi` package you can pool Cox regression models by using
the following pooling methods: RR (Rubin's Rules), D1, D2, and MPR
(Median R Rule). You can also use forward or backward selection from
the pooled model. This vignette show you examples of how to apply these
procedures.
# Examples
* [Cox regression]
+ [Pooling without BW and method D1]
+ [Pooling with FW and method MPR]
+ [Pooling with FW including interaction terms and method D1]
+ [Pooling with BW including spline coefficients and method D1]
+ [Pooling with FW including spline coefficients and method MPR]
+ [Pooling with BW for a stratified Cox model]
## Pooling without BW and method D1
If you set p.crit at 1 than no selection of variables takes place.
Either using direction = "FW" or direction = "BW" will produce the same
result.
```{r}
library(psfmi)
pool_coxr <- psfmi_coxr(data=lbpmicox, nimp=5, impvar="Impnr",
formula = Surv(Time, Status) ~ Duration + Radiation + Onset +
Function + Age + Previous + Tampascale + JobControl +
JobDemand + Social + factor(Expect_cat), p.crit=1,
method="D1", direction = "BW")
pool_coxr$RR_model
pool_coxr$multiparm
```
Back to [Examples]
## Pooling with FW and method MPR
```{r, eval=TRUE}
library(psfmi)
pool_coxr <- psfmi_coxr(data=lbpmicox, nimp=5, impvar="Impnr",
formula = Surv(Time, Status) ~ Duration + Radiation + Onset +
Function + Age + Previous + Tampascale + JobControl +
JobDemand + Social + factor(Expect_cat), p.crit=0.05,
method="D1", direction = "FW")
pool_coxr$RR_model_final
pool_coxr$multiparm_final
pool_coxr$predictors_in
```
Back to [Examples]
## Pooling with FW including interaction terms and method D1
Pooling Cox regression models over 5 imputed datasets with backward selection
using a p-value of 0.05 and as method D1 including interaction terms with
a categorical predictor and forcing the predictor Tampascale in the models
during backward selection.
```{r}
library(psfmi)
pool_coxr <- psfmi_coxr(data=lbpmicox, nimp=5, impvar="Impnr",
formula = Surv(Time, Status) ~ Duration + Radiation + Onset +
Function + Age + Previous + Tampascale + factor(Expect_cat) +
factor(Satisfaction) + Tampascale:Radiation +
factor(Expect_cat):Tampascale, keep.predictors = "Tampascale",
p.crit=0.05, method="D1", direction = "FW")
pool_coxr$RR_model_final
pool_coxr$multiparm_final
pool_coxr$predictors_in
```
Back to [Examples]
## Pooling with BW including spline coefficients and method D1
Pooling Cox regression models over 5 imputed datasets with backward selection
using a p-value of 0.05 and as method D1 including a restricted cubic spline
predictor and forcing Tampascale in the models during backward selection.
```{r}
library(psfmi)
pool_coxr <- psfmi_coxr(data=lbpmicox, nimp=5, impvar="Impnr",
formula = Surv(Time, Status) ~ Duration + Radiation + Onset +
Function + Previous + rcs(Tampascale, 3) +
factor(Satisfaction) + rcs(Tampascale, 3):Radiation,
keep.predictors = "Tampascale",
p.crit=0.05, method="D1", direction = "BW")
pool_coxr$RR_model_final
pool_coxr$multiparm_final
pool_coxr$predictors_in
```
Back to [Examples]
## Pooling with FW including spline coefficients and method MPR
Pooling Cox regression models over 5 imputed datasets with forward selection
using a p-value of 0.05 and as method MPR including a restricted cubic spline
predictor and forcing Tampascale in the models during forward selection.
```{r}
library(psfmi)
pool_coxr <- psfmi_coxr(data=lbpmicox, nimp=5, impvar="Impnr",
formula = Surv(Time, Status) ~ Duration + Radiation + Onset +
Function + Previous + rcs(Tampascale, 3) +
factor(Satisfaction) + rcs(Tampascale, 3):Radiation,
keep.predictors = "Tampascale",
p.crit=0.05, method="MPR", direction = "FW")
pool_coxr$RR_model_final
pool_coxr$multiparm_final
pool_coxr$predictors_in
```
Back to [Examples]
## Pooling with BW for a stratified Cox model
Pooling Cox regression models over 5 imputed datasets with backward selection
using a p-value of 0.05 and as method MPR for a stratified Cox model.
```{r}
library(psfmi)
pool_coxr <- psfmi_coxr(data=lbpmicox, nimp=5, impvar="Impnr",
formula = Surv(Time, Status) ~ Duration + Onset +
Function + Previous + rcs(Tampascale, 3) +
factor(Satisfaction) + strata(Radiation),
p.crit=0.05, method="MPR", direction = "BW")
pool_coxr$RR_model_final
pool_coxr$multiparm_final
pool_coxr$formula_step
```
Back to [Examples]