Permuate explanatory variables to produce multiple output tables for common regression models

ff_permute(.data, dependent = NULL, explanatory_base = NULL,
  explanatory_permute = NULL, multiple_tables = FALSE,
  include_base_model = TRUE, include_full_model = TRUE,
  base_on_top = TRUE, ...)

finalfit_permute(.data, dependent = NULL, explanatory_base = NULL,
  explanatory_permute = NULL, multiple_tables = FALSE,
  include_base_model = TRUE, include_full_model = TRUE,
  base_on_top = TRUE, ...)

Arguments

.data

Data frame or tibble.

dependent

Character vector of length 1: quoted name of dependent variable. Can be continuous, a binary factor, or a survival object of form Surv(time, status).

explanatory_base

Character vector of any length: quoted name(s) of base model explanatory variables.

explanatory_permute

Character vector of any length: quoted name(s) of explanatory variables to permute through models.

multiple_tables

Logical. Multiple model tables as a list, or a single table including multiple models.

include_base_model

Logical. Include model using explanatory_base variables only.

include_full_model

Logical. Include model using all explanatory_base and explanatory_permute variables.

base_on_top

Logical. Base variables at top of table, or bottom of table.

...

Other arguments to finalfit

Value

Returns a list of data frame with the final model table.

Examples

explanatory_base = c("age.factor", "sex.factor") explanatory_permute = c("obstruct.factor", "perfor.factor", "node4.factor") # Linear regression colon_s %>% finalfit_permute("nodes", explanatory_base, explanatory_permute)
#> Dependent is not a factor and will be treated as a continuous variable
#> Dependent is not a factor and will be treated as a continuous variable
#> Dependent is not a factor and will be treated as a continuous variable
#> Dependent is not a factor and will be treated as a continuous variable
#> Dependent is not a factor and will be treated as a continuous variable
#> Dependent is not a factor and will be treated as a continuous variable
#> Dependent: nodes Mean (sd) Coefficient (univariable) #> 1 Age <40 years 4.7 (4.5) - #> 2 40-59 years 3.6 (3.3) -1.14 (-2.08 to -0.21, p=0.016) #> 3 60+ years 3.6 (3.6) -1.19 (-2.10 to -0.28, p=0.010) #> 4 Sex Female 3.7 (3.6) - #> 5 Male 3.6 (3.6) -0.14 (-0.60 to 0.33, p=0.565) #> 6 Obstruction No 3.7 (3.7) - #> 7 Yes 3.5 (3.2) -0.24 (-0.83 to 0.36, p=0.435) #> 8 Perforation No 3.7 (3.6) - #> 9 Yes 3.9 (2.8) 0.24 (-1.13 to 1.61, p=0.735) #> 10 >4 positive nodes No 2.0 (1.1) - #> 11 Yes 8.2 (4.1) 6.19 (5.84 to 6.53, p<0.001) #> Coefficient (multivariable) 1 Coefficient (multivariable) 2 #> 1 - - #> 2 -1.14 (-2.07 to -0.20, p=0.017) -1.21 (-2.16 to -0.26, p=0.012) #> 3 -1.18 (-2.09 to -0.27, p=0.011) -1.25 (-2.17 to -0.33, p=0.008) #> 4 - - #> 5 -0.12 (-0.58 to 0.35, p=0.626) -0.07 (-0.54 to 0.40, p=0.779) #> 6 - - #> 7 - -0.30 (-0.90 to 0.30, p=0.327) #> 8 - - #> 9 - - #> 10 - - #> 11 - - #> Coefficient (multivariable) 3 Coefficient (multivariable) 4 #> 1 - - #> 2 -1.14 (-2.07 to -0.20, p=0.017) -0.63 (-1.24 to -0.02, p=0.042) #> 3 -1.18 (-2.09 to -0.27, p=0.011) -0.47 (-1.06 to 0.13, p=0.123) #> 4 - - #> 5 -0.12 (-0.58 to 0.35, p=0.627) 0.10 (-0.20 to 0.40, p=0.527) #> 6 - - #> 7 - - #> 8 - - #> 9 0.24 (-1.13 to 1.60, p=0.736) - #> 10 - - #> 11 - 6.18 (5.84 to 6.52, p<0.001) #> Coefficient (multivariable) 5 #> 1 - #> 2 -0.64 (-1.26 to -0.02, p=0.043) #> 3 -0.48 (-1.08 to 0.12, p=0.119) #> 4 - #> 5 0.13 (-0.17 to 0.44, p=0.391) #> 6 - #> 7 -0.13 (-0.53 to 0.26, p=0.500) #> 8 - #> 9 0.50 (-0.40 to 1.39, p=0.277) #> 10 - #> 11 6.19 (5.84 to 6.54, p<0.001)
# Cox proportional hazards regression colon_s %>% finalfit_permute("Surv(time, status)", explanatory_base, explanatory_permute)
#> Dependent: Surv(time, status) all #> 1 Age <40 years 70 (100.0) #> 2 40-59 years 344 (100.0) #> 3 60+ years 515 (100.0) #> 4 Sex Female 445 (100.0) #> 5 Male 484 (100.0) #> 6 Obstruction No 732 (100.0) #> 7 Yes 176 (100.0) #> 8 Perforation No 902 (100.0) #> 9 Yes 27 (100.0) #> 10 >4 positive nodes No 674 (100.0) #> 11 Yes 255 (100.0) #> HR (univariable) HR (multivariable) 1 #> 1 - - #> 2 0.76 (0.53-1.09, p=0.132) 0.76 (0.53-1.08, p=0.129) #> 3 0.93 (0.66-1.31, p=0.668) 0.93 (0.66-1.31, p=0.660) #> 4 - - #> 5 1.01 (0.84-1.22, p=0.888) 1.02 (0.85-1.23, p=0.847) #> 6 - - #> 7 1.29 (1.03-1.62, p=0.028) - #> 8 - - #> 9 1.17 (0.70-1.95, p=0.556) - #> 10 - - #> 11 2.60 (2.15-3.14, p<0.001) - #> HR (multivariable) 2 HR (multivariable) 3 #> 1 - - #> 2 0.79 (0.55-1.13, p=0.198) 0.76 (0.53-1.08, p=0.127) #> 3 0.98 (0.69-1.40, p=0.931) 0.92 (0.65-1.31, p=0.656) #> 4 - - #> 5 1.02 (0.85-1.24, p=0.803) 1.02 (0.85-1.22, p=0.854) #> 6 - - #> 7 1.31 (1.04-1.64, p=0.022) - #> 8 - - #> 9 - 1.18 (0.70-1.97, p=0.535) #> 10 - - #> 11 - - #> HR (multivariable) 4 HR (multivariable) 5 #> 1 - - #> 2 0.85 (0.59-1.22, p=0.379) 0.90 (0.63-1.30, p=0.590) #> 3 1.09 (0.77-1.55, p=0.615) 1.19 (0.83-1.69, p=0.346) #> 4 - - #> 5 1.04 (0.87-1.26, p=0.647) 1.05 (0.87-1.27, p=0.597) #> 6 - - #> 7 - 1.35 (1.07-1.70, p=0.011) #> 8 - - #> 9 - 1.16 (0.69-1.94, p=0.581) #> 10 - - #> 11 2.64 (2.18-3.19, p<0.001) 2.68 (2.21-3.26, p<0.001)
# Logistic regression colon_s %>% finalfit_permute("mort_5yr", explanatory_base, explanatory_permute)
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Dependent: Mortality 5 year Alive Died #> 1 Age <40 years 31 (46.3) 36 (53.7) #> 2 40-59 years 208 (61.4) 131 (38.6) #> 3 60+ years 272 (53.4) 237 (46.6) #> 4 Sex Female 243 (55.6) 194 (44.4) #> 5 Male 268 (56.1) 210 (43.9) #> 6 Obstruction No 408 (56.7) 312 (43.3) #> 7 Yes 89 (51.1) 85 (48.9) #> 8 Perforation No 497 (56.0) 391 (44.0) #> 9 Yes 14 (51.9) 13 (48.1) #> 10 >4 positive nodes No 431 (65.0) 232 (35.0) #> 11 Yes 80 (31.7) 172 (68.3) #> OR (univariable) OR (multivariable) 1 #> 1 - - #> 2 0.54 (0.32-0.92, p=0.023) 0.54 (0.32-0.92, p=0.023) #> 3 0.75 (0.45-1.25, p=0.270) 0.75 (0.45-1.25, p=0.273) #> 4 - - #> 5 0.98 (0.76-1.27, p=0.889) 0.99 (0.76-1.28, p=0.925) #> 6 - - #> 7 1.25 (0.90-1.74, p=0.189) - #> 8 - - #> 9 1.18 (0.54-2.55, p=0.672) - #> 10 - - #> 11 3.99 (2.94-5.46, p<0.001) - #> OR (multivariable) 2 OR (multivariable) 3 #> 1 - - #> 2 0.57 (0.34-0.98, p=0.041) 0.54 (0.32-0.92, p=0.023) #> 3 0.81 (0.48-1.36, p=0.427) 0.75 (0.45-1.25, p=0.273) #> 4 - - #> 5 0.98 (0.75-1.28, p=0.903) 0.99 (0.76-1.28, p=0.926) #> 6 - - #> 7 1.26 (0.90-1.76, p=0.177) - #> 8 - - #> 9 - 1.18 (0.54-2.56, p=0.671) #> 10 - - #> 11 - - #> OR (multivariable) 4 OR (multivariable) 5 #> 1 - - #> 2 0.61 (0.35-1.06, p=0.080) 0.66 (0.37-1.16, p=0.147) #> 3 0.90 (0.52-1.55, p=0.705) 1.00 (0.57-1.73, p=0.988) #> 4 - - #> 5 1.04 (0.79-1.37, p=0.787) 1.03 (0.78-1.37, p=0.823) #> 6 - - #> 7 - 1.34 (0.94-1.91, p=0.103) #> 8 - - #> 9 - 1.21 (0.54-2.71, p=0.634) #> 10 - - #> 11 4.05 (2.97-5.56, p<0.001) 4.15 (3.03-5.73, p<0.001)
# Logistic regression with random effect (glmer) # colon_s %>% # finalfit_permute("mort_5yr", explanatory_base, explanatory_permute, # random_effect = "hospital")