Skip to contents

Perform Daymont's quality-control for BMI, fit a cubic splines mixed model regression with linear splines as random effect, save model object, generates residuals figures fot model validity, derived area under the curve and slopes for male and femal. This function is a wrapper around egg_model(), egg_slopes() and egg_aucs().

Usage

run_eggla_lmm(
  data,
  id_variable,
  age_days_variable,
  age_years_variable,
  weight_kilograms_variable,
  height_centimetres_variable,
  sex_variable,
  covariates,
  male_coded_zero = FALSE,
  random_complexity = "auto",
  use_car1 = FALSE,
  knots = c(1, 8, 12),
  period = c(0, 0.5, 1.5, 3.5, 6.5, 10, 12, 17),
  start = 0.25,
  end = 10,
  step = 0.01,
  filter = NULL,
  outlier_method = "iqr",
  outlier_threshold = list(iqr = 2),
  outlier_exclude = TRUE,
  parallel = FALSE,
  parallel_n_chunks = 1,
  working_directory = getwd(),
  quiet = FALSE,
  clean = TRUE
)

Arguments

data

Phenotypes data that inherits from data.frame class.

id_variable

Name of the column where sample/individual IDs are stored.

age_days_variable

Name of the column where age in days is stored. NULL if age in days is not available.

age_years_variable

Name of the column where age in years is stored. NULL if age in years is not available.

weight_kilograms_variable

Name of the column where weight in kilograms is stored.

height_centimetres_variable

Name of the column where height in centimetres is stored.

sex_variable

Name of the column where sex is stored.

covariates

A vector of columns' names to be used as covariates. NULL if there are no covariates to add.

male_coded_zero

Is male coded "0" (and female coded "1")?

random_complexity

A numeric (1-3) indicating the complexity of the random effect term. Default, "auto" will try from the more complex to the less complex if no success.

use_car1

A logical indicating whether to use continuous auto-correlation, i.e., CAR(1) as correlation structure.

knots

The knots defining the splines.

period

The intervals knots on which slopes are to be computed.

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.

outlier_method

The outlier detection method(s). Default is "iqr". Can be "cook", "pareto", "zscore", "zscore_robust", "iqr", "ci", "eti", "hdi", "bci", "mahalanobis", "mahalanobis_robust", "mcd", "ics", "optics" or "lof". See performance::check_outliers() https://easystats.github.io/performance/reference/check_outliers.html for details.

outlier_threshold

A list containing the threshold values for each method (e.g., list('mahalanobis' = 7, 'cook' = 1)), above which an observation is considered as outlier. If NULL, default values will be used (see 'Details'). If a numeric value is given, it will be used as the threshold for any of the method run. See performance::check_outliers() https://easystats.github.io/performance/reference/check_outliers.html for details.

outlier_exclude

Whether or not the values/individuals flagged as being outliers should be excluded. Default is TRUE.

parallel

Determines if growthcleanr::cleangrowth() function shoud be run in parallel. Defaults to FALSE.

parallel_n_chunks

Specify the number of batches (in growthcleanr::cleangrowth()) to run in parallel. Only applies if parallel is set to TRUE. Defaults to the number of workers returned by the getDoParWorkers function in the foreach package.

working_directory

Directory in which computation will occur and where output files will be saved.

quiet

A logical indicating whether to suppress the output.

clean

A logical indicating whether to clean working_directory once the archives are created.

Value

Path to zip archives.

Examples

if (interactive()) {
  data("bmigrowth")
  fwrite(
    x = bmigrowth,
    file = file.path(tempdir(), "bmigrowth.csv")
  )
  res <- run_eggla_lmm(
    data = fread(file.path(tempdir(), "bmigrowth.csv")),
    id_variable = "ID",
    age_days_variable = NULL,
    age_years_variable = "age",
    weight_kilograms_variable = "weight",
    height_centimetres_variable = "height",
    sex_variable = "sex",
    covariates = NULL,
    random_complexity = 1,
    working_directory = tempdir()
  )
}