Skip to contents

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.

Usage

egg_correlations(
  fit,
  period = c(0, 0.5, 1.5, 3.5, 6.5, 10, 12, 17),
  knots = c(1, 8, 12),
  start = 0.25,
  end = 10,
  step = 0.01,
  filter = NULL
)

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 to method.

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 through compute_apar() (see predict_bmi()). Default is NULL.

Value

A data.table object with correlations between each intervals derived parameters.

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.859252125   0.2700883  0.04034632
#>  2:   auc_1.5--3.5  0.85925212  1.000000000   0.7246147  0.54580347
#>  3:    auc_6.5--10  0.27008830  0.724614715   1.0000000  0.97294864
#>  4:     auc_12--17  0.04034632  0.545803466   0.9729486  1.00000000
#>  5:   slope_0--0.5 -0.25795663  0.272589824   0.8605788  0.95496221
#>  6: slope_1.5--3.5 -0.25795663  0.272589824   0.8605788  0.95496221
#>  7:  slope_6.5--10 -0.25795663  0.272589824   0.8605788  0.95496221
#>  8:   slope_12--17 -0.25795663  0.272589824   0.8605788  0.95496221
#>  9:    AP_ageyears -0.13447702 -0.027491854   0.1436239  0.18508442
#> 10:    AR_ageyears  0.11381106  0.008036503  -0.1520585 -0.18841085
#> 11:         AP_bmi  0.04998238  0.203225927   0.3332056  0.33380622
#> 12:         AR_bmi  0.02613407  0.211353846   0.3847213  0.39375324
#>     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.2579566     -0.2579566    -0.2579566   -0.2579566 -0.13447702
#>  2:    0.2725898      0.2725898     0.2725898    0.2725898 -0.02749185
#>  3:    0.8605788      0.8605788     0.8605788    0.8605788  0.14362395
#>  4:    0.9549622      0.9549622     0.9549622    0.9549622  0.18508442
#>  5:    1.0000000      1.0000000     1.0000000    1.0000000  0.22028245
#>  6:    1.0000000      1.0000000     1.0000000    1.0000000  0.22028245
#>  7:    1.0000000      1.0000000     1.0000000    1.0000000  0.22028245
#>  8:    1.0000000      1.0000000     1.0000000    1.0000000  0.22028245
#>  9:    0.2202824      0.2202824     0.2202824    0.2202824  1.00000000
#> 10:   -0.2167862     -0.2167862    -0.2167862   -0.2167862 -0.98172755
#> 11:    0.3028107      0.3028107     0.3028107    0.3028107 -0.19277901
#> 12:    0.3677929      0.3677929     0.3677929    0.3677929  0.07898946
#>      AR_ageyears      AP_bmi      AR_bmi
#>            <num>       <num>       <num>
#>  1:  0.113811056  0.04998238  0.02613407
#>  2:  0.008036503  0.20322593  0.21135385
#>  3: -0.152058462  0.33320556  0.38472126
#>  4: -0.188410854  0.33380622  0.39375324
#>  5: -0.216786218  0.30281065  0.36779288
#>  6: -0.216786218  0.30281065  0.36779288
#>  7: -0.216786218  0.30281065  0.36779288
#>  8: -0.216786218  0.30281065  0.36779288
#>  9: -0.981727551 -0.19277901  0.07898946
#> 10:  1.000000000  0.19568510 -0.08802460
#> 11:  0.195685103  1.00000000  0.95865751
#> 12: -0.088024597  0.95865751  1.00000000