I am having some issues creating adjusted cumulative incidence function using Kaplan Meier estimator after mice. I repeatedly get an error and, being fairly new to R, I am not sure what it means.
When I run the below code I get the following error:
#IPTW KM using WeightIt on each imputed dataset
install.packages("adjustedCurves")
treatment_model <- with(data=imp, exp=glm(pe ~edu_cat + bmi_cat + mbr_gdm + p_inpatient
+ year_cat + age_cat + smoke, family="binomial"(link="logit"), subset=(pop==1) ))
adj<- adjustedsurv(data=imp,
variable="pe",
ev_time= "timetoprimary",
event="egfr59",
method = "iptw_km",
treatment_model = treatment_model,
conf_int=TRUE,
bootstrap=FALSE)
Error in if (est == "surv" & last_est == 0) { :
argument is of length zero
In addition: Warning message:
In max(time_vec) : no non-missing arguments to max; returning -Inf
Here is a sample dataset
droplevels(data[1:4, ])
# A tibble: 4 × 102
pin p_date b_date ga_weeks preg_no female dob dodsdat migr_date
<dbl> <date> <date> <dbl> <fct> <fct> <date> <date> <date>
1 1000013 2005-05-02 2006-01-23 38 1 1 1961-10-01 NA NA
2 1000018 2018-04-21 2019-01-26 40 1 1 1990-08-01 NA NA
3 1000019 2017-07-02 2018-04-08 40 1 1 1984-04-01 NA NA
4 1000044 2015-06-04 2016-02-25 38 1 1 1984-02-01 NA NA
# ℹ 93 more variables: egfr_baseline <dbl>, albu_baseline <dbl>, egfr59_date <date>,
# egfr <fct>, albu_date <date>, a_cat <fct>, b_year <dbl>, b_age <dbl>, origin <fct>,
# edu <fct>, weight_kg <dbl>, length_cm <dbl>, bw_grams <dbl>, sga <fct>,
# smoke <fct>, parity <fct>, mbr_dm <fct>, mbr_gdm <dbl>, mbr_ht <fct>,
# mbr_sle <fct>, mbr_glom <fct>, mbr_tbi <fct>, mbr_ckd <fct>, mbr_ckd_glom <fct>,
# mbr_ckd_other <fct>, mbr_ckd_sec <fct>, mbr_ckd_uns <fct>, mbr_ckd_self <fct>,
# mbr_pe <fct>, p_pe <fct>, p_pe_date <date>, p_dm <fct>, p_ht <fct>, p_sle <fct>, …
Thank you
I am not sure what is causing this and would appreciate your help/insights.
My ev_time is a numeric variable in days.
New contributor
Jennifer Yo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.