View source: R/diagnostics_generic.R
| post_hoc_lm | R Documentation |
Useful for exploring drivers of occupancy/detection/abundance variation after model fitting. Fits a weighted linear model and optionally generates bootstrap confidence intervals.
post_hoc_lm(
formula,
data,
weights = NULL,
n_boot = 1000L,
probs = c(0.025, 0.975)
)
## S3 method for class 'post_hoc_lm'
print(x, ...)
formula |
Model formula (e.g., |
data |
A data.frame with response and predictors. |
weights |
Optional weights (e.g., inverse of standard errors). |
n_boot |
Number of bootstrap replicates for CI (default 1000, 0 to skip). |
probs |
Quantile probabilities for bootstrap CI (default 0.025, 0.975). |
x |
A |
... |
Ignored. |
A list of class "post_hoc_lm" with:
data.frame of coefficient estimates and CIs
the underlying lm object
matrix of bootstrap coefficient samples (if n_boot > 0)
R-squared from the fitted model
# Explore drivers of per-site estimates after fitting a model.
site <- data.frame(
psi_hat = c(0.2, 0.5, 0.8, 0.4, 0.6, 0.3),
se = c(0.05, 0.04, 0.06, 0.05, 0.03, 0.05),
trait = c(1.0, 2.5, 3.8, 1.9, 3.1, 1.2)
)
fit <- post_hoc_lm(psi_hat ~ trait, data = site,
weights = 1 / site$se^2, n_boot = 200L)
fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.