Reconstruct an hspec object from the coefficients and parameter map saved by
hfit(). The original specification and fit are not modified.
Arguments
- fit
A result from the current
hfit().
Details
The saved map preserves matrix sharing under both reduced settings and named
parameters shared between functions. Function bodies and environments are
retained; their param defaults are updated. Fixed constants remain fixed.
The original kernel mapping, rmark, and rresidual are retained. Named default
parameters in these generators are updated when they match coefficient names;
other generator parameters keep their original defaults.
With optimizer = "maxLik", the fit keeps its maxLik classes and methods;
reading these fits requires maxLik. The "stats" optimizer returns an
emhawkes_stats_fit with its own coefficient, likelihood, covariance and
summary methods, requiring no maxLik API. Its emhawkes attribute stores
a versioned list with specification, parameter_map, initial_state,
reduced, and custom_loglik. New fits also retain constraints and final
diagnostics, available through fit_diagnostics(). New calculation records
are in fit_diagnostics(fit)$computation. Fits without the original model
metadata cannot be
reconstructed by this function. Function environments remain references to
the original environments; external state is not frozen.
Use saveRDS() and readRDS() to retain the fit's metadata between sessions.
Supply observations again to logLik() and keep them separately. The stored
optimization objective can retain data in its function environment.
Restoration does not assert convergence or stationarity. Check the fit's
convergence information and whether the model is suitable for simulation.
A custom mylogLik is not part of the restored hspec.
Examples
h <- new("hspec", mu = 0.3, alpha = 0, beta = 1)
fit <- hfit(h, c(0, 0.2, 0.3, 0.5, 1), lambda_component0 = 0,
fixed = c(FALSE, TRUE, TRUE))
estimated <- fitted_hspec(fit)
initial <- fit_initial_state(fit)
do.call(logLik, c(list(object = estimated,
inter_arrival = c(0, 0.2, 0.3, 0.5, 1)), initial))
#> loglikelihood
#> -1.227411