| Title: | Hierarchical Air Pollution Model |
|---|---|
| Description: | Fits hierarchical functional case-crossover models for air pollution health effects, with hierarchical structures and case-crossover designs built on the adlaplace Laplace approximation framework. |
| Authors: | Patrick Brown [aut, cre, cph] |
| Maintainer: | Patrick Brown <[email protected]> |
| License: | MPL-2.0 |
| Version: | 0.5.2 |
| Built: | 2026-07-17 23:39:34 UTC |
| Source: | https://github.com/eborgnine/adlaplace |
Dirichlet-multinomial case-crossover response term
dirichlet_multinom(x, by, init = 0.001, lower = 0, upper = Inf, parscale = 1)dirichlet_multinom(x, by, init = 0.001, lower = 0, upper = Inf, parscale = 1)
x |
Outcome variable name. |
by |
Character vector of stratification variables (e.g. |
init |
Initial value for overdispersion |
lower |
Lower bound for |
upper |
Upper bound for |
parscale |
Parameter scale for optimization. |
A dirichlet_multinom object.
Model term for the case-crossover Dirichlet-multinomial log density
registered as dirichlet_multinomial.
## S4 method for signature 'dirichlet_multinom' elgm_matrix(term, data) ## S4 method for signature 'dirichlet_multinom' design(term, data) ## S4 method for signature 'dirichlet_multinom' precision(term, data) ## S4 method for signature 'dirichlet_multinom' theta_info(term) ## S4 method for signature 'dirichlet_multinom' beta_info(term, data) ## S4 method for signature 'dirichlet_multinom' random_info(term, data)## S4 method for signature 'dirichlet_multinom' elgm_matrix(term, data) ## S4 method for signature 'dirichlet_multinom' design(term, data) ## S4 method for signature 'dirichlet_multinom' precision(term, data) ## S4 method for signature 'dirichlet_multinom' theta_info(term) ## S4 method for signature 'dirichlet_multinom' beta_info(term, data) ## S4 method for signature 'dirichlet_multinom' random_info(term, data)
term |
A |
data |
Analysis-ready data frame. |
Sparse ngCMatrix mapping observations to strata columns.
elgm_matrix(dirichlet_multinom): Case-crossover stratum map for AD shards.
design(dirichlet_multinom): Design method (not used).
precision(dirichlet_multinom): Precision method (not used).
theta_info(dirichlet_multinom): Theta info for overdispersion sd.
beta_info(dirichlet_multinom): Beta info method (not used).
random_info(dirichlet_multinom): Random info method (not used).
byCharacter vector of stratification variables for the case-crossover design.
model)ad_funCharacter scalar "dirichlet_multinomial".
ad_kindCharacter scalar "observations".
packageCharacter scalar "hpolcc".
ad_fun_ptr in this package's shared library.Build observation-shard ad_fun_ptr in this package's shared library.
get_ad_fun_raw_obs(model, config, name)get_ad_fun_raw_obs(model, config, name)
model |
|
config |
Model configuration list. |
name |
Observation density name (e.g. |
External pointer of class ad_fun_ptr.
ad_fun_ptr in this package's shared library.Build parameters-shard ad_fun_ptr in this package's shared library.
get_ad_fun_raw_parameters(model, config, name)get_ad_fun_raw_parameters(model, config, name)
model |
|
config |
Model configuration list. |
name |
Parameters density name (e.g. |
External pointer of class ad_fun_ptr.
Fits a hierarchical case-crossover model with a dirichlet_multinom response
term, using adlaplace automatic differentiation and Laplace approximation.
hnlm( formula, data, config = list(transform_theta = TRUE), control = list(maxit = 1000, trace = 3, REPORT = 1), control_inner = list(report.level = 0), for_dev = FALSE, ... )hnlm( formula, data, config = list(transform_theta = TRUE), control = list(maxit = 1000, trace = 3, REPORT = 1), control_inner = list(report.level = 0), for_dev = FALSE, ... )
formula |
Model formula with a |
data |
Data frame containing variables referenced in |
config |
Configuration list passed to adlaplace. Common entries:
|
control |
Control list passed to outer |
control_inner |
Control list passed to inner optimization. |
for_dev |
If |
... |
Unused. |
When for_dev = TRUE, a development bundle of class c("hnlm_dev", "hnlm").
Otherwise a fitted object of class hnlm with primary slots
coefficients, log_lik, optim, converged,
extra (Laplace output), hessian, info, optional
sample, and call (fit metadata including config,
terms, and the original match.call).
This function removes holidays from a dataset based on the specified type.
remove_holidays(data, type = "rm_all")remove_holidays(data, type = "rm_all")
data |
A data frame containing a 'date' column. |
type |
A character string specifying the type of holiday removal. Options are "rm_none", "rm_all". |
A data frame with holidays removed according to the specified type.
hnlm fitsReturns coefficients$parameters from the fit, including mle and
se (when the outer Hessian was available at fit time).
## S3 method for class 'hnlm' summary(object, ...) ## S3 method for class 'summary.hnlm' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'hnlm' summary(object, ...) ## S3 method for class 'summary.hnlm' print(x, digits = max(3L, getOption("digits") - 3L), ...)
object |
A fitted |
... |
Not used. |
x |
A |
digits |
Number of significant digits to print. |
An object of class summary.hnlm with the parameters table,
variance matrix, log-likelihood, and convergence flag.
Inverse of the outer Hessian from profile likelihood optimization
(hessian$outer). Falls back to a Moore-Penrose inverse with a
warning if the Hessian is singular.
## S3 method for class 'hnlm' vcov(object, ...)## S3 method for class 'hnlm' vcov(object, ...)
object |
A fitted |
... |
Not used. |
Variance-covariance matrix on the optimization scale of
optim$par.