The functions the Shiny app uses, available for analyses in R scripts: build a column mapping, prepare the data, fit and compare Models 1-10, predict population trajectories, and read the diagnostics, the interpretation notes and the reproducible code.
Usage
disappr_mapping(...)
disappr_prepare(data, mapping, dup_action = "keep")
disappr_fit(
x,
models = MODEL_IDS,
age_function = "Quadratic",
family = "gaussian",
...
)
disappr_compare(fit)
disappr_predict(fit, model, ages = NULL, by = NULL)
disappr_diagnose(fit)
disappr_interpret(fit)
disappr_code(fit, x, source_label = "your_data.csv")
disappr_simulate(...)
disappr_read(path)
disappr_example(key)
disappr_provenance(fit)Arguments
- ...
For
disappr_mapping(): column roles (id,age,trait,alr,life,entry,covars,cov_factor,cov_age,group,group2,random, ...) andtrait_specific_ages(defaultTRUE: automatic ALR and AFR are the last and first ages with a trait value;FALSE: of any record). Fordisappr_fit(): further settings passed to the model suite (random_slope,standardise,zi_str,among,include_invalid,extra). Fordisappr_simulate(): simulation settings (n_id,seed,sd_type,missingness,form, ...).- data
A data frame with one row per record.
- mapping
A column mapping from
disappr_mapping().- dup_action
What to do with repeated individual-by-age records:
"keep"(default) keeps every row;"mean"collapses rows identical in every mapped column into one (nothing is averaged; the name is kept for compatibility).- x
Prepared data from
disappr_prepare().- models
Model identifiers,
"M1"to"M10".- age_function
Ageing function:
"Linear","Quadratic","Cubic","Logarithmic"or"Asymptotic exponential".- family
Error family, e.g.
"gaussian","poisson","nbinom2","binomial".- fit
A fitted comparison from
disappr_fit().- model
One model identifier, e.g.
"M4".- ages
Ages at which to predict (default: a fine grid over the observed ages).
- by
Optional categorical covariate whose levels get separate predictions.
- source_label
File name the exported script reads.
- path
Path to a CSV or other delimited text file.
- key
Name of a bundled example, e.g.
"bouwhuis"(seenames(disappR:::EXAMPLES)).
Value
disappr_mapping(): a mapping list. disappr_prepare(): a list with data and meta.
disappr_fit(): the model comparison (AIC table, coefficients, fits, validity). disappr_compare(): the AIC
table. disappr_predict(): predicted population trajectory. disappr_diagnose(): validity, status, dropped
rows and notes. disappr_interpret(): interpretation notes. disappr_code(): an R script as a string.
disappr_simulate(): a simulated data set.
Examples
if (FALSE) { # \dontrun{
sim <- disappr_simulate(n_id = 150, seed = 1, sd_type = "both")
map <- disappr_mapping(id = "ID", age = "age", trait = "body_mass", life = "lifespan")
x <- disappr_prepare(sim, map)
fit <- disappr_fit(x, models = c("M1", "M2", "M4"))
disappr_compare(fit)
} # }
