SSModelDynamicGompertz
and SSModelDynGompertzReinit
refer back
to this base class.Base class for estimating time-series growth curve models. Classes
SSModelDynamicGompertz
and SSModelDynGompertzReinit
refer back
to this base class.
estimate(sea.type = "trigonometric", sea.period = 7)
Estimates the dynamic Gompertz curve model when applied to an object of
class SSModelDynamicGompertz
or SSModelDynGompertzReinit
.
sea.type
Seasonal type. Options are
'trigonometric'
and 'none'
. 'trigonometric'
will
yield a model with a trigonometric seasonal component and
'none'
will yield a model with no seasonal component.
sea.period
The period of seasonality. For a
day-of-the-week effect with daily data, this would be 7. Not required
if sea.type = 'none'
.
An object of class FilterResults
containing the result output for the estimated dynamic Gompertz curve
model.
get_dynamic_gompertz_model(
y,
q = NULL,
sea.type = "trigonometric",
sea.period = 7,
a1 = NULL,
P1 = NULL,
Q = NULL,
H = NULL
)
Returns dynamic Gompertz curve model.
y
The cumulated variable
q
The signal-to-noise ratio (ratio of slope to irregular
variance). Defaults to 'NULL'
, in which case no signal-to-noise
ratio will be imposed. Instead, it will be estimated.
sea.type
Seasonal type. Options are 'trigonometric'
and 'none'
. 'trigonometric'
will yield a model with a
trigonometric seasonal component and 'none'
will yield a model
with no seasonal component.
sea.period
The period of seasonality. For a day-of-the-week
effect with daily data, this would be 7. Not required if
sea.type = 'none'
.
a1
Optional parameter specifying the prior mean of the
states. Defaults to 'NULL'
. Leave as 'NULL'
for a diffuse
prior (no prior information). If a proper prior is to be specified, both
a1
and P1
must be given.
P1
Optional parameter specifying the prior mean of the
states. Defaults to 'NULL'
. Leave as 'NULL'
for a diffuse
prior (no prior information). If a proper prior is to be specified,
both a1
and P1
must be given.
Q
Optional parameter specifying the state error variances
where these are to be imposed rather than estimated. Defaults to
'NULL'
which will see the variances estimated.
H
Optional parameter specifying the irregular variance
where this is to be imposed rather than estimated. Defaults to
'NULL'
which will see the variance estimated.
The dynamic Gompertz with an integrated random walk (IRW) trend is $$\ln g_{t}=\delta_{t}+\varepsilon_{t}, \;\;\;\; \varepsilon_{t}\sim NID(0,\sigma_{\varepsilon }^{2}), \;\;\;\; t=2,...,T, $$ where \(Y_t\) is the cumulated variable, \(y_t = \Delta Y_t\), \(\ln g_{t}=\ln y_{t}-\ln Y_{t-1}\) and $$\delta_{t} =\delta_{t-1}+\gamma_{t-1},$$ $$\gamma_{t} =\gamma_{t-1}+\zeta_{t}, \;\;\;\; \zeta_{t}\sim NID(0,\sigma_{\zeta }^{2}),$$ where the observation disturbances \(\varepsilon_{t}\) and slope disturbances \(\zeta_{t}\), are iid Normal and mutually independent. Note that, the larger the signal-to-noise ratio, \(q_{\zeta }=\sigma_{\zeta }^{2}/\sigma_{\varepsilon }^{2}\), the faster the slope changes in response to new observations. Conversely, a lower signal-to-noise ratio induces smoothness.
For the model without seasonal terms (sea.type = 'none'
) the are
priors are
$$\begin{pmatrix} \delta_1 \ \gamma_1 \end{pmatrix}
\sim N(a_1,P_1)$$.
The diffuse prior has \(P_1 = \kappa I_{2\times 2}\) with
\(\kappa \to \infty\). Implementation of the diffuse prior is handled
by the package KFAS
(Helske, 2017). Where the model has a seasonal
component (sea.type = 'trigonometric'
), the vector of prior means
\(a_1\) and the prior covariance matrix \(P_1\) are extended
accordingly.
See the vignette for details of the variance matrix \(Q\). \(H = \sigma^2_{\varepsilon}\).
update(pars, model, q, sea.type)
Update method for Kalman filter to implement the dynamic Gompertz curve model. A maximum of 3 parameters are used to set the observation noise (1 parameter), the transition equation slope and seasonal noise. If q (signal to noise ratio) is not null then the slope noise is set using this ratio.
pars
Vector of parameters.
model
KFS
model object.
q
The signal-to-noise ratio (ratio of slope to irregular
variance).
sea.type
Seasonal type. Options are
'trigonometric'
and 'none'
.
KFS
model object.
library(tsgc)
data(gauteng,package="tsgc")
idx.est <- zoo::index(gauteng) <= as.Date("2020-07-06")
# Specify a model
model <- SSModelDynamicGompertz$new(Y = gauteng[idx.est], q = 0.005)
# Estimate a specified model
res <- model$estimate()
Run the code above in your browser using DataLab