Compute the derived parameters correlations from a cubic splines mixed-effects model by egg_model()
.
Source: R/egg_correlations.R
egg_correlations.Rd
Based on computed area under the curves (i.e., egg_aucs()
)
and slopes (i.e., egg_slopes()
) for several intervals using
a model fitted by egg_model()
, compute the correlations between
each intervals derived parameters.
Arguments
- fit
A model object from a statistical model such as from a call to
egg_model()
.- period
The intervals knots on which slopes are to be computed.
- knots
The knots as defined
fit
and according tomethod
.- start
The start of the time window to compute AP and AR.
- end
The end of the time window to compute AP and AR.
- step
The step to increment the sequence.
- filter
A string following
data.table
syntax for filtering on"i"
(i.e., row elements), e.g.,filter = "source == 'A'"
. Argument pass throughcompute_apar()
(seepredict_bmi()
). Default isNULL
.
Examples
data("bmigrowth")
res <- egg_model(
formula = log(bmi) ~ age,
data = bmigrowth[bmigrowth[["sex"]] == 0, ],
id_var = "ID",
random_complexity = 1
)
#> Fitting model:
#> nlme::lme(
#> fixed = log(bmi) ~ gsp(age, knots = c(1, 8, 12), degree = rep(3, 4), smooth = rep(2, 3)),
#> data = data,
#> random = ~ gsp(age, knots = c(1, 8, 12), degree = rep(1, 4), smooth = rep(2, 3)) | ID,
#> na.action = stats::na.omit,
#> method = "ML",
#> control = nlme::lmeControl(opt = "optim", niterEM = 25, maxIter = 500, msMaxIter = 500)
#> )
egg_correlations(
fit = res,
period = c(0, 0.5, 1.5, 3.5, 6.5, 10, 12, 17),
knots = c(1, 8, 12)
)
#> term auc_0--0.5 auc_1.5--3.5 auc_6.5--10 auc_12--17
#> <char> <num> <num> <num> <num>
#> 1: auc_0--0.5 1.00000000 0.8592521 0.2700883 0.04034632
#> 2: auc_1.5--3.5 0.85925212 1.0000000 0.7246147 0.54580347
#> 3: auc_6.5--10 0.27008830 0.7246147 1.0000000 0.97294864
#> 4: auc_12--17 0.04034632 0.5458035 0.9729486 1.00000000
#> 5: slope_0--0.5 -0.25795663 0.2725898 0.8605788 0.95496221
#> 6: slope_1.5--3.5 -0.25795663 0.2725898 0.8605788 0.95496221
#> 7: slope_6.5--10 -0.25795663 0.2725898 0.8605788 0.95496221
#> 8: slope_12--17 -0.25795663 0.2725898 0.8605788 0.95496221
#> 9: AP_ageyears -0.28781211 0.1467279 0.7909131 0.92641596
#> 10: AR_ageyears 0.29075211 -0.1464326 -0.7950653 -0.93170497
#> 11: AP_bmi 0.99381038 0.9399620 0.4353792 0.16688346
#> 12: AR_bmi 0.92589813 0.9953601 0.6674790 0.43382020
#> slope_0--0.5 slope_1.5--3.5 slope_6.5--10 slope_12--17 AP_ageyears
#> <num> <num> <num> <num> <num>
#> 1: -0.25795663 -0.25795663 -0.25795663 -0.25795663 -0.28781211
#> 2: 0.27258982 0.27258982 0.27258982 0.27258982 0.14672789
#> 3: 0.86057876 0.86057876 0.86057876 0.86057876 0.79091312
#> 4: 0.95496221 0.95496221 0.95496221 0.95496221 0.92641596
#> 5: 1.00000000 1.00000000 1.00000000 1.00000000 0.99129588
#> 6: 1.00000000 1.00000000 1.00000000 1.00000000 0.99129588
#> 7: 1.00000000 1.00000000 1.00000000 1.00000000 0.99129588
#> 8: 1.00000000 1.00000000 1.00000000 1.00000000 0.99129588
#> 9: 0.99129588 0.99129588 0.99129588 0.99129588 1.00000000
#> 10: -0.99742818 -0.99742818 -0.99742818 -0.99742818 -0.98172755
#> 11: -0.20272013 -0.20272013 -0.20272013 -0.20272013 -0.19277901
#> 12: 0.07743496 0.07743496 0.07743496 0.07743496 0.07898946
#> AR_ageyears AP_bmi AR_bmi
#> <num> <num> <num>
#> 1: 0.2907521 0.9938104 0.92589813
#> 2: -0.1464326 0.9399620 0.99536013
#> 3: -0.7950653 0.4353792 0.66747898
#> 4: -0.9317050 0.1668835 0.43382020
#> 5: -0.9974282 -0.2027201 0.07743496
#> 6: -0.9974282 -0.2027201 0.07743496
#> 7: -0.9974282 -0.2027201 0.07743496
#> 8: -0.9974282 -0.2027201 0.07743496
#> 9: -0.9817276 -0.1927790 0.07898946
#> 10: 1.0000000 0.1956851 -0.08802460
#> 11: 0.1956851 1.0000000 0.95865751
#> 12: -0.0880246 0.9586575 1.00000000