anpan_subjectwise_pglmm | R Documentation |
If you have a dataset where multiple samples come from the same individual, running a PGLMM on all the samples without accounting for this will return a strong spurious signal because samples from the same individual will (usually) be right next to each other on the tree and all show the same outcome value. This function uses a subject-sample map input to aggregate samples by subject, derive a subject-wise correlation matrix, then run a PGLMM on that.
anpan_subjectwise_pglmm(
tree_file,
meta_file,
subject_sample_map,
outcome,
offset = NULL,
covariates = NULL,
out_dir = NULL,
trim_pattern = NULL,
omit_na = FALSE,
ladderize = TRUE,
family = "gaussian",
show_plot_cor_mat = TRUE,
show_plot_tree = TRUE,
show_post = TRUE,
show_yrep = FALSE,
save_object = FALSE,
verbose = TRUE,
loo_comparison = TRUE,
reg_noise = TRUE,
reg_gamma_params = c(1, 2),
plot_ext = "pdf",
beta_sd = NULL,
sigma_phylo_scale = 0.333,
...
)
tree_file |
either a path to a tree file readable by |
meta_file |
either a data frame or a file. Can provide covariate and outcome variables for either subjects or samples. |
subject_sample_map |
a data frame giving a mapping between sample_id (which must match the leaves of the tree up to the trim_pattern) and subject_id |
outcome |
the name of the outcome variable |
offset |
a variable to include as an offset |
covariates |
covariates to account for (as a vector of strings) |
out_dir |
if saving, directory where to save |
trim_pattern |
optional pattern to trim from tip labels of the tree |
omit_na |
logical indicating whether to omit incomplete cases of the metadata |
ladderize |
logical indicating whether to run |
family |
string giving the name of the distribution of the outcome variable (usually "gaussian" or "binomial") |
show_plot_cor_mat |
show a plot of the correlation matrix derived from the tree |
show_plot_tree |
show a plot of the tree overlaid with the outcome. |
show_post |
show a plot of the tree overlaid with the outcome and posterior distribution on phylogenetic effects. |
show_yrep |
show a plot of the tree overlaid with the outcome and the posterior predictive distribution for each observation if plotting the tree |
save_object |
logical indicating whether to save the model fit object |
loo_comparison |
logical indicating whether to compare the phylogenetic model against a base
model (without the phylogenetic term) using |
reg_noise |
logical indicating whether to regularize the ratio of sigma_phylo to sigma_resid with a Gamma prior |
reg_gamma_params |
the shape and rate parameters of the Gamma prior on the noise term ratio. Default: c(1,2) |
plot_ext |
extension to use when saving plots |
beta_sd |
prior standard deviation parameters on the normal distribution for each covariate in the GLM component |
sigma_phylo_scale |
standard deviation of half-normal prior on |
... |
other arguments to pass to |
The meta_file
must contain at least one column named "sample_id" or "subject_id".
If the metadata is inferred to be provided by sample, representative covariate and outcome
variable values are selected for each subject in the manner described in
?anpan_repeated_measures()
anpan_pglmm()
anpan_repeated_measures()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.