Fit GAM for one element
analyseOneElement.gam.Rd
`analyseOneElement.gam` fits a GAM model for one element data, and returns requested model statistics.
Usage
analyseOneElement.gam(
i_element,
formula,
modelarray,
phenotypes,
scalar,
var.smoothTerms,
var.parametricTerms,
var.model,
num.subj.lthr,
num.stat.output = NULL,
flag_initiate = FALSE,
flag_sse = FALSE,
...
)
Arguments
- i_element
An integer, the i_th element, starting from 1. For initiating (flag_initiate = TRUE), use i_element=1
- formula
A formula (passed to `mgcv::gam()`)
- modelarray
ModelArray class
- phenotypes
A data.frame of the cohort with columns of independent variables and covariates to be added to the model
- scalar
A character. The name of the element-wise scalar to be analysed
- var.smoothTerms
The list of variables to save for smooth terms (got from broom::tidy(parametric = FALSE)). Example smooth term: age in formula "outcome ~ s(age)".
- var.parametricTerms
The list of variables to save for parametric terms (got from broom::tidy(parametric = TRUE)). Example parametric term: sex in formula "outcome ~ s(age) + sex".
- var.model
The list of variables to save for the model (got from broom::glance() and summary()).
- num.subj.lthr
The minimal number of subjects with valid value in input h5 file, i.e. number of subjects with finite values (defined by `is.finite()`, i.e. not NaN or NA or Inf) in h5 file >
num.subj.lthr
, then this element will be run normally; otherwise, this element will be skipped and statistical outputs will be set as NaN.- num.stat.output
The number of output stat metrics (for generating all NaN stat when # subjects does not meet criteria). This includes column `element_id`. This is required when flag_initiate = TRUE.
- flag_initiate
TRUE or FALSE, Whether this is to initiate the new analysis. If TRUE, it will return column names etc to be used for initiating data.frame; if FALSE, it will return the list of requested statistic values.
- flag_sse
TRUE or FALSE, Whether to calculate SSE (sum of squared error) for the model (`model.sse`). SSE is needed for calculating partial R-squared.
- ...
Additional arguments for `mgcv::gam()`