pretty_mixed_effects_coxme: Fancy Table Output of Mixed effects COX PH model

Description Usage Arguments Value Examples

View source: R/pretty_mixed_models.R

Description

pretty_mixed_effects_coxme() Cox mixed effects model using the coxme() function. Hazard ratios are produced with confidence intervals. P values are also produced. For categorical variables with 3+ levels overall Type 3 p values are calculated, in addition to p values comparing to the first level (reference).

Usage

1

Arguments

fit

glmer fit

df

is data.frame or tibble used to create model fits. Used for capturing variable labels, if they exist

Value

A data.frame with: Variable, Level, HR (95% CI), P Value (for categorical variables comparing to reference), Overall P Value (for categorical variables with 3+ levels).

Examples

 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
# Mixed effect cox ph model example - random intercepts
library(magrittr)
library(ggeffects)
library(sjmisc)
library(lme4)
library(splines)
library(coxme)
library(car)
library(survival)
library(broom.mixed)
library(rlang)
library(kableExtra)
data(PDACdata)
set.seed(542542522)
#USE THIS ONE for 3 months to 2 years (24 months)
surv_months_obj <- survival::Surv(time = PDACdata$dx_lastcontact_death_months,
                                 event = PDACdata$puf_vital_status == 0)
   cactfit  <- coxme(surv_months_obj ~   
     caci3 + surgery_volume_recode +  (1|puf_facility_id),
     data = PDACdata,
                    control=coxme.control(eps = 1e-04, toler.chol = .Machine$double.eps^0.75,
                            iter.max = 200, inner.iter = Quote(max(4, fit0$iter+1)),
                            sparse.calc = NULL,
                            optpar = list(method = "BFGS", control=list(reltol = 1e-3)),
                            refine.df=4, refine.detail=FALSE, refine.method="control",
                            sparse=c(50, .02),
                            varinit=c(.02, .1, .4, .8)^2, corinit = c(0, .3))  )
 cactfitcmetable <-  pretty_mixed_effects_coxme(cactfit, PDACdata)
# for PDF output 
#  kable(cactfitcmetable , 'latex', escape = FALSE, longtable = T, booktabs = TRUE, linesep = '', 
#  caption = 'Full Mulitvariable Mixed effects Cox Proportional-Hazards Regression Model with 
#  interaction for Overall Survival2 to 10 years')

z2thet/MoffittFunctions documentation built on July 17, 2021, 9:51 a.m.