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

ff_permute(.data, dependent = NULL, explanatory_base = NULL,
  explanatory_permute = NULL, ...)

finalfit_permute(.data, dependent = NULL, explanatory_base = NULL,
  explanatory_permute = NULL, ...)

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.

...

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
#> [[1]] #> Dependent: nodes Mean (sd) Coefficient (univariable) #> 4 Obstruction No 3.7 (3.7) - #> 5 Yes 3.5 (3.2) -0.24 (-0.83 to 0.36, p=0.435) #> 2 Age <40 years 4.7 (4.5) - #> 1 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) #> 6 Sex Female 3.7 (3.6) - #> 7 Male 3.6 (3.6) -0.14 (-0.60 to 0.33, p=0.565) #> Coefficient (multivariable) #> 4 - #> 5 -0.30 (-0.90 to 0.30, p=0.327) #> 2 - #> 1 -1.21 (-2.16 to -0.26, p=0.012) #> 3 -1.25 (-2.17 to -0.33, p=0.008) #> 6 - #> 7 -0.07 (-0.54 to 0.40, p=0.779) #> #> [[2]] #> Dependent: nodes Mean (sd) Coefficient (univariable) #> 4 Perforation No 3.7 (3.6) - #> 5 Yes 3.9 (2.8) 0.24 (-1.13 to 1.61, p=0.735) #> 2 Age <40 years 4.7 (4.5) - #> 1 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) #> 6 Sex Female 3.7 (3.6) - #> 7 Male 3.6 (3.6) -0.14 (-0.60 to 0.33, p=0.565) #> Coefficient (multivariable) #> 4 - #> 5 0.24 (-1.13 to 1.60, p=0.736) #> 2 - #> 1 -1.14 (-2.07 to -0.20, p=0.017) #> 3 -1.18 (-2.09 to -0.27, p=0.011) #> 6 - #> 7 -0.12 (-0.58 to 0.35, p=0.627) #> #> [[3]] #> Dependent: nodes Mean (sd) Coefficient (univariable) #> 4 >4 positive nodes No 2.0 (1.1) - #> 5 Yes 8.2 (4.1) 6.19 (5.84 to 6.53, p<0.001) #> 2 Age <40 years 4.7 (4.5) - #> 1 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) #> 6 Sex Female 3.7 (3.6) - #> 7 Male 3.6 (3.6) -0.14 (-0.60 to 0.33, p=0.565) #> Coefficient (multivariable) #> 4 - #> 5 6.18 (5.84 to 6.52, p<0.001) #> 2 - #> 1 -0.63 (-1.24 to -0.02, p=0.042) #> 3 -0.47 (-1.06 to 0.13, p=0.123) #> 6 - #> 7 0.10 (-0.20 to 0.40, p=0.527) #>
# Cox proportional hazards regression colon_s %>% finalfit_permute("Surv(time, status)", explanatory_base, explanatory_permute)
#> [[1]] #> Dependent: Surv(time, status) all #> 4 Obstruction No 732 (80.6) #> 5 Yes 176 (19.4) #> 2 Age <40 years 70 (7.5) #> 1 40-59 years 344 (37.0) #> 3 60+ years 515 (55.4) #> 6 Sex Female 445 (47.9) #> 7 Male 484 (52.1) #> HR (univariable) HR (multivariable) #> 4 - - #> 5 1.29 (1.03-1.62, p=0.028) 1.31 (1.04-1.64, p=0.022) #> 2 - - #> 1 0.76 (0.53-1.09, p=0.132) 0.79 (0.55-1.13, p=0.198) #> 3 0.93 (0.66-1.31, p=0.668) 0.98 (0.69-1.40, p=0.931) #> 6 - - #> 7 1.01 (0.84-1.22, p=0.888) 1.02 (0.85-1.24, p=0.803) #> #> [[2]] #> Dependent: Surv(time, status) all #> 4 Perforation No 902 (97.1) #> 5 Yes 27 (2.9) #> 2 Age <40 years 70 (7.5) #> 1 40-59 years 344 (37.0) #> 3 60+ years 515 (55.4) #> 6 Sex Female 445 (47.9) #> 7 Male 484 (52.1) #> HR (univariable) HR (multivariable) #> 4 - - #> 5 1.17 (0.70-1.95, p=0.556) 1.18 (0.70-1.97, p=0.535) #> 2 - - #> 1 0.76 (0.53-1.09, p=0.132) 0.76 (0.53-1.08, p=0.127) #> 3 0.93 (0.66-1.31, p=0.668) 0.92 (0.65-1.31, p=0.656) #> 6 - - #> 7 1.01 (0.84-1.22, p=0.888) 1.02 (0.85-1.22, p=0.854) #> #> [[3]] #> Dependent: Surv(time, status) all #> 4 >4 positive nodes No 674 (72.6) #> 5 Yes 255 (27.4) #> 2 Age <40 years 70 (7.5) #> 1 40-59 years 344 (37.0) #> 3 60+ years 515 (55.4) #> 6 Sex Female 445 (47.9) #> 7 Male 484 (52.1) #> HR (univariable) HR (multivariable) #> 4 - - #> 5 2.60 (2.15-3.14, p<0.001) 2.64 (2.18-3.19, p<0.001) #> 2 - - #> 1 0.76 (0.53-1.09, p=0.132) 0.85 (0.59-1.22, p=0.379) #> 3 0.93 (0.66-1.31, p=0.668) 1.09 (0.77-1.55, p=0.615) #> 6 - - #> 7 1.01 (0.84-1.22, p=0.888) 1.04 (0.87-1.26, p=0.647) #>
# 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...
#> [[1]] #> Dependent: Mortality 5 year Alive Died #> 4 Obstruction No 408 (82.1) 312 (78.6) #> 5 Yes 89 (17.9) 85 (21.4) #> 2 Age <40 years 31 (6.1) 36 (8.9) #> 1 40-59 years 208 (40.7) 131 (32.4) #> 3 60+ years 272 (53.2) 237 (58.7) #> 6 Sex Female 243 (47.6) 194 (48.0) #> 7 Male 268 (52.4) 210 (52.0) #> OR (univariable) OR (multivariable) #> 4 - - #> 5 1.25 (0.90-1.74, p=0.189) 1.26 (0.90-1.76, p=0.177) #> 2 - - #> 1 0.54 (0.32-0.92, p=0.023) 0.57 (0.34-0.98, p=0.041) #> 3 0.75 (0.45-1.25, p=0.270) 0.81 (0.48-1.36, p=0.427) #> 6 - - #> 7 0.98 (0.76-1.27, p=0.889) 0.98 (0.75-1.28, p=0.903) #> #> [[2]] #> Dependent: Mortality 5 year Alive Died #> 4 Perforation No 497 (97.3) 391 (96.8) #> 5 Yes 14 (2.7) 13 (3.2) #> 2 Age <40 years 31 (6.1) 36 (8.9) #> 1 40-59 years 208 (40.7) 131 (32.4) #> 3 60+ years 272 (53.2) 237 (58.7) #> 6 Sex Female 243 (47.6) 194 (48.0) #> 7 Male 268 (52.4) 210 (52.0) #> OR (univariable) OR (multivariable) #> 4 - - #> 5 1.18 (0.54-2.55, p=0.672) 1.18 (0.54-2.56, p=0.671) #> 2 - - #> 1 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) #> 6 - - #> 7 0.98 (0.76-1.27, p=0.889) 0.99 (0.76-1.28, p=0.926) #> #> [[3]] #> Dependent: Mortality 5 year Alive Died #> 4 >4 positive nodes No 431 (84.3) 232 (57.4) #> 5 Yes 80 (15.7) 172 (42.6) #> 2 Age <40 years 31 (6.1) 36 (8.9) #> 1 40-59 years 208 (40.7) 131 (32.4) #> 3 60+ years 272 (53.2) 237 (58.7) #> 6 Sex Female 243 (47.6) 194 (48.0) #> 7 Male 268 (52.4) 210 (52.0) #> OR (univariable) OR (multivariable) #> 4 - - #> 5 3.99 (2.94-5.46, p<0.001) 4.05 (2.97-5.56, p<0.001) #> 2 - - #> 1 0.54 (0.32-0.92, p=0.023) 0.61 (0.35-1.06, p=0.080) #> 3 0.75 (0.45-1.25, p=0.270) 0.90 (0.52-1.55, p=0.705) #> 6 - - #> 7 0.98 (0.76-1.27, p=0.889) 1.04 (0.79-1.37, p=0.787) #>
# Logistic regression with random effect (glmer) colon_s %>% finalfit_permute("mort_5yr", explanatory_base, explanatory_permute, random_effect = "hospital")
#> 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...
#> [[1]] #> Dependent: Mortality 5 year Alive Died #> 4 Obstruction No 408 (82.1) 312 (78.6) #> 5 Yes 89 (17.9) 85 (21.4) #> 2 Age <40 years 31 (6.1) 36 (8.9) #> 1 40-59 years 208 (40.7) 131 (32.4) #> 3 60+ years 272 (53.2) 237 (58.7) #> 6 Sex Female 243 (47.6) 194 (48.0) #> 7 Male 268 (52.4) 210 (52.0) #> OR (univariable) OR (multilevel) #> 4 - - #> 5 1.25 (0.90-1.74, p=0.189) 1.23 (0.82-1.83, p=0.315) #> 2 - - #> 1 0.54 (0.32-0.92, p=0.023) 0.75 (0.39-1.44, p=0.383) #> 3 0.75 (0.45-1.25, p=0.270) 1.03 (0.55-1.96, p=0.916) #> 6 - - #> 7 0.98 (0.76-1.27, p=0.889) 0.80 (0.58-1.11, p=0.181) #> #> [[2]] #> Dependent: Mortality 5 year Alive Died #> 4 Perforation No 497 (97.3) 391 (96.8) #> 5 Yes 14 (2.7) 13 (3.2) #> 2 Age <40 years 31 (6.1) 36 (8.9) #> 1 40-59 years 208 (40.7) 131 (32.4) #> 3 60+ years 272 (53.2) 237 (58.7) #> 6 Sex Female 243 (47.6) 194 (48.0) #> 7 Male 268 (52.4) 210 (52.0) #> OR (univariable) OR (multilevel) #> 4 - - #> 5 1.18 (0.54-2.55, p=0.672) 1.08 (0.45-2.63, p=0.862) #> 2 - - #> 1 0.54 (0.32-0.92, p=0.023) 0.69 (0.36-1.32, p=0.266) #> 3 0.75 (0.45-1.25, p=0.270) 0.95 (0.50-1.78, p=0.869) #> 6 - - #> 7 0.98 (0.76-1.27, p=0.889) 0.81 (0.59-1.12, p=0.206) #> #> [[3]] #> Dependent: Mortality 5 year Alive Died #> 4 >4 positive nodes No 431 (84.3) 232 (57.4) #> 5 Yes 80 (15.7) 172 (42.6) #> 2 Age <40 years 31 (6.1) 36 (8.9) #> 1 40-59 years 208 (40.7) 131 (32.4) #> 3 60+ years 272 (53.2) 237 (58.7) #> 6 Sex Female 243 (47.6) 194 (48.0) #> 7 Male 268 (52.4) 210 (52.0) #> OR (univariable) OR (multilevel) #> 4 - - #> 5 3.99 (2.94-5.46, p<0.001) 2.06 (1.42-2.97, p<0.001) #> 2 - - #> 1 0.54 (0.32-0.92, p=0.023) 0.72 (0.37-1.38, p=0.321) #> 3 0.75 (0.45-1.25, p=0.270) 1.03 (0.54-1.95, p=0.933) #> 6 - - #> 7 0.98 (0.76-1.27, p=0.889) 0.84 (0.61-1.16, p=0.300) #>