Generate common metrics for regression model results
ff_metrics(.data)
# S3 method for lm
ff_metrics(.data)
# S3 method for lmlist
ff_metrics(.data)
# S3 method for glm
ff_metrics(.data)
# S3 method for glmlist
ff_metrics(.data)
# S3 method for lmerMod
ff_metrics(.data)
# S3 method for glmerMod
ff_metrics(.data)
# S3 method for coxph
ff_metrics(.data)
# S3 method for coxphlist
ff_metrics(.data)
Model output.
Model metrics vector for output.
library(finalfit)
# glm
fit = glm(mort_5yr ~ age.factor + sex.factor + obstruct.factor + perfor.factor,
data=colon_s, family="binomial")
fit %>%
ff_metrics()
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#>
#> Number in dataframe = 929, Number in model = 894, Missing = 35, AIC = 1230.7, C-statistic = 0.56, H&L = Chi-sq(8) 5.69 (p=0.682)
# glmlist
explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
dependent = "mort_5yr"
colon_s %>%
glmmulti(dependent, explanatory) %>%
ff_metrics()
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#>
#> Number in dataframe = 929, Number in model = 894, Missing = 35, AIC = 1230.7, C-statistic = 0.56, H&L = Chi-sq(8) 5.69 (p=0.682)
# glmerMod
explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
random_effect = "hospital"
dependent = "mort_5yr"
colon_s %>%
glmmixed(dependent, explanatory, random_effect) %>%
ff_metrics()
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
#>
#> Number in model = 894, Number of groups = 5, AIC = 933.8, C-statistic = 0.815
# lm
fit = lm(nodes ~ age.factor + sex.factor + obstruct.factor + perfor.factor,
data=colon_s)
fit %>%
ff_metrics()
#>
#> Number in dataframe = 929, Number in model = 890, Missing = 39, Log-likelihood = -2394.25, AIC = 4802.5, R-squared = 0.0092, Adjusted R-squared = 0.0036
# lmerMod
explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
random_effect = "hospital"
dependent = "nodes"
colon_s %>%
lmmixed(dependent, explanatory, random_effect) %>%
ff_metrics()
#>
#> Number in model = 890, Number of groups = 5, Log likelihood = -2317.13, REML criterion = 4634.3
# coxphlist
explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
dependent = "Surv(time, status)"
colon_s %>%
coxphmulti(dependent, explanatory) %>%
ff_metrics()
#>
#> Number in dataframe = 929, Number in model = 908, Missing = 21, Number of events = 441, Concordance = 0.543 (SE = 0.014), R-squared = 0.011( Max possible = 0.998), Likelihood ratio test = 9.862 (df = 5, p = 0.079)
# coxph
fit = survival::coxph(survival::Surv(time, status) ~ age.factor + sex.factor +
obstruct.factor + perfor.factor,
data = colon_s)
fit %>%
ff_metrics()
#>
#> Number in dataframe = 929, Number in model = 908, Missing = 21, Number of events = 441, Concordance = 0.543 (SE = 0.014), R-squared = 0.011( Max possible = 0.998), Likelihood ratio test = 9.862 (df = 5, p = 0.079)