To conveniently view model results or make tables, it is useful to extract the coefficients in a useable format. This function extracts coefficients for ds.glm, ds.glmSLMA and ds.lmerSLMA objects.
Usage
dh.lmTab(
model = NULL,
type = NULL,
coh_names = NULL,
direction = NULL,
ci_format = NULL,
family = "gaussian",
digits = 2,
exponentiate = FALSE,
extract_random = FALSE
)
Arguments
- model
Object returned from either ds.glm, ds.glmSLMA or ds.lmerSLMA functions.
- type
Character specifying type of object provided in
model
. Can be either "glm_ipd", "glm_slma" or "lmer_slma".- coh_names
Character vector of cohorts included in
model
. Note this must be in the same order as the cohorts were included in the model.- direction
Character specifying the output format. Can be either "wide" or "long". See "Value" for more details.
- ci_format
format for the confidence intervals when direction is "wide". If "separate", upper and lower confidence intervals are displayed as columns. If "paste", confidence intervals are returned in the same column as the coefficient within brackets. Option "paste" is only available if
ci_format
is "wide"- family
Specifies the family used in the analysis where type is "glm_ipd" or "glm_slma". Options are "gaussian" or "binomial", with default "gaussian".
- digits
Optionally, the number of decimal places to round output to. Default is 2.
- exponentiate
Optionally, specify whether estimates from binomial models should be exponentiated, ie returned as odds ratios. This argument is ignored if
type
is "gaussian".- extract_random
Optionally, specify whether to return random effects in mixed effects models.
Value
A tibble. When direction
is "wide" & ci_format
is "paste", this
contains five columns:
variable
est
lowci
uppci
pvalue
When direction
is "long", a tibble with three columns is returned:
variable
coefficient (containing values "est", "lowci", "uppci", "pvalue")
value
When type
is "lmer_slma", a list of 2 elements where the first element
is as described as above, and the second element is a tibble of random
effects with 5 columns: "cohort", "group", "var1", "var2", "stddev".
"stddev" gives either the
#' Extracts the random effects from an lmer_slma model. Returns tibble containing, for each cohort, the standard deviation of the random terms and the standard deviation of the residual error. If two or more random terms are included, it also returns the correlation between the terms.
See also
Other descriptive functions:
dh.anyData()
,
dh.classDiscrepancy()
,
dh.createTableOne()
,
dh.getStats()
,
dh.meanByGroup()