profile_par_lag | R Documentation |
hhh4_lag
model using profile likelihoodWrapper around hhh4_lag
to allow for profile likelihood estimation of the scalar parameter
governing the lag structure. hhh4_lag
can fit models with fixed lag decay parameter; profile_par_lag
re-fits the model for different values of par_lag
and finds the optimal value. See ?hhh4_lag
for details.
NOTE: fit_par_lag
serves essentially the same purpose, but is based on a grid of potential values for
par_lag
rather than optimization using optim
. profile_par_lag
is the recommended option, but
fit_par_lag
may be somethat quicker for complex models.
profile_par_lag(
stsObj,
control,
start_par_lag = NULL,
lower_par_lag = -10,
upper_par_lag = 10,
return_full_cov = FALSE,
reltol_par_lag = 1e-08,
check.analyticals = FALSE
)
stsObj, control, check.analyticals |
As in
|
start_par_lag |
A starting value for |
lower_par_lag, upper_par_lag |
lower and upper limits for the value of par_lag; defaults to -10, 10 |
return_full_cov |
logical: should the full covariance matrix of the parameter estimates (including |
reltol_par_lag |
the relative tolerance passed to the |
The standard hhh4
function only allows for models with
first lags i.e. of the form
mu_{it} = \lambda_{it}X_{i, t - 1} + \phi_{it}\sum_{j != i}w_{ji}X_{j, t - 1} + \nu_{it},
see ?hhh4
. The extension hhh4_lag
allows to specify
models of the form
mu_{it} = \lambda_{it}\sum_{q= 1}^Q u_q X_{i, t - q} + \phi_{it}\sum_{j\neq i}sum_{q= 1}^Q w_{ji}u_q X_{j, t - q} + \nu_{it}.
Here the first lags are now replaced by weighted sums of the Q
previous observations. The weights u_q, q = 1, ..., Q sum up to
1 and need to be parametrizable by a single scalar parameter. The value of this parameter needs to be passed as control$par_lag
.
Moreover, a function to obtain a vector of weights from par_lag
needs to be provided in control$funct_lag
.
Currently several such functions are implemented in the package:
Geometric lags (function geometric_lag
; the default).
These are specified as
u0_q = \alpha * (1 - \alpha)^{q - 1}
and u_q = u0_q / sum_{q = 1}^Q u0_q
for q = 1, ..., Q
. The par_lag
parameter corresponds to logit(\alpha
),
i.e. the un-normalized weight of the first lag.
Poisson lags (function poisson_lag
).
These are specified as
u0_q = \alpha^(q - 1)\exp(-\alpha)/(q - 1)!,
and u_q = u0_q / sum_{q = 1}^Q u0_q
for q = 1, ..., Q
. Note that he Poisson distribution is shifted by one to
achieve a positive support. The par_lag
parameter corresponds to log(\alpha
).
Linearly decaying weights (in function linear_lag
).
These are specified as
u0_q = max(1 - mq, 0)
and u_q = u0_q / sum_{q = 1}^Q u0_q
for q = 1, ..., Q
.
The par_lag
parameter corresponds to logit(m
).
A weighting only between first and second lags (in function ar2lag
), i.e.
u_1 = \alpha, u_2 = 1 - \alpha.
The par_lag
parameter corresponds to logit(\alpha
).
Unrestricted lag can be fitted using unrestricted_lag
. These are parameterized via
a multinomial logit transformation where the first lag is the reference category.
\itemDiscrete Weibull lags are implemented in discrete_weibull_lag
, see details there.
\itemDiscrete gamma lags are implemented in discrete_gamma_lag
, see details there.
\itemDiscretized log-normal lags are implemented in log_normal_lag
, see details there.
Users can specify their own weighting functions as long as they take the arguments described above and return a vector of weights.
If return_full_cov == FALSE
: an hhh4_lag
object. If return_full_cov == TRUE
A list with two
elements: best_mod
is the hhh4_lag
fit for the best value of par_lag
; cov
is an extended covariance matrix for the regression parameters
which also includes par_lag.
hhh4_lag
for fitting models with fixed par_lag
; fit_par_lag
for grid-based optimization.
## a simple univariate example:
data("salmonella.agona")
## convert old "disProg" to new "sts" data class
salmonella <- disProg2sts(salmonella.agona)
# specify and fit model: fixed geometric lag structure
control_salmonella <- list(end = list(f = addSeason2formula(~ 1)),
ar = list(f = addSeason2formula(~ 1)),
family = "NegBinM", subset = 6:312)
fit_salmonella <- profile_par_lag(salmonella, control_salmonella)
summary(fit_salmonella)
# 0.56 on first lag
#
# re-fit with Poisson lags:
control_salmonella2 <- control_salmonella
control_salmonella2$funct_lag = poisson_lag
fit_salmonella2 <- profile_par_lag(salmonella, control_salmonella2)
summary(fit_salmonella2)
# leads to somewhat different decay and very slightly better AIC
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.