Compute area under the curves for several intervals using a model fitted by time_model()
.
Source: R/compute_aucs.R
compute_aucs.Rd
Compute area under the curves for "clubic slope", "linear splines" and "cubic splines"
fitted using time_model()
.
Arguments
- fit
A model object from a statistical model such as from a call to
time_model()
.- method
The type of model provided in
fit
, i.e., one of"cubic_slope"
,"linear_splines"
or"cubic_splines"
.- period
The intervals knots on which AUCs are to be computed.
- knots
The knots as defined
fit
and according tomethod
.
Examples
data("bmigrowth")
ls_mod <- time_model(
x = "age",
y = "log(bmi)",
cov = NULL,
data = bmigrowth[bmigrowth[["sex"]] == 0, ],
method = "linear_splines"
)
#> nlme::lme(
#> fixed = log(bmi) ~ gsp(age, knots = c(0.75, 5.5, 11), degree = rep(1, 4), smooth = rep(0, 3)),
#> data = data,
#> random = ~ gsp(age, knots = c(0.75, 5.5, 11), degree = rep(1, 4), smooth = rep(0, 3)) | ID,
#> na.action = stats::na.omit,
#> method = "ML",
#> control = nlme::lmeControl(opt = "optim", maxIter = 500, msMaxIter = 500)
#> )
head(compute_aucs(
fit = ls_mod,
method = "linear_splines",
period = c(0, 0.5, 1.5, 3.5, 6.5, 10, 12, 17)#,
# knots = list(
# "cubic_slope" = NULL,
# "linear_splines" = c(0.75, 5.5, 11),
# "cubic_splines" = c(1, 8, 12)
# )[[method]]
))
#> ID auc_0--0.5 auc_1.5--3.5 auc_6.5--10 auc_12--17
#> 001 001 1.411971 6.179849 11.67305 18.53235
#> 004 004 1.341466 5.835608 11.16576 17.68861
#> 005 005 1.358373 5.762464 11.26893 18.24248
#> 006 006 1.312805 5.545659 10.71672 17.09600
#> 007 007 1.320790 6.168538 11.79039 18.53175
#> 009 009 1.376196 5.669445 10.90937 17.51368