estim_NLS function

Internal estimation function for estimating autoregressive and weight parameters of STVAR models by the method of nonlinear least squares.

Internal estimation function for estimating autoregressive and weight parameters of STVAR models by the method of nonlinear least squares.

estim_NLS estimates the autoregressive and weight parameters of STVAR models by the method of least squares (relative_dens weight function is not supported).

estim_NLS( data, p, M, weight_function = c("relative_dens", "logistic", "mlogit", "exponential", "threshold", "exogenous"), weightfun_pars = NULL, cond_dist = c("Gaussian", "Student", "ind_Student", "ind_skewed_t"), parametrization = c("intercept", "mean"), AR_constraints = NULL, mean_constraints = NULL, weight_constraints = NULL, penalized = TRUE, penalty_params = c(0.05, 0.2), min_obs_coef = 3, sparse_grid = FALSE, use_parallel = TRUE, ncores = 2 )

Arguments

  • data: a matrix or class 'ts' object with d>1 columns. Each column is taken to represent a univariate time series. Missing values are not supported.

  • p: a positive integer specifying the autoregressive order

  • M: a positive integer specifying the number of regimes

  • weight_function: What type of transition weights αm,t\alpha_{m,t} should be used?

    • "relative_dens":: c("alpham,t=\n\\alpha_{m,t}=\n", "fracalphamfm,dp(yt1,...,ytp+1)sumn=1Malphanfn,dp(yt1,...,ytp+1) \\frac{\\alpha_mf_{m,dp}(y_{t-1},...,y_{t-p+1})}{\\sum_{n=1}^M\\alpha_nf_{n,dp}(y_{t-1},...,y_{t-p+1})}"), where αm(0,1)\alpha_m\in (0,1) are weight parameters that satisfy m=1Mαm=1\sum_{m=1}^M\alpha_m=1 and fm,dp()f_{m,dp}(\cdot) is the dpdp-dimensional stationary density of the mmth regime corresponding to pp

       consecutive observations. Available for Gaussian conditional distribution only.
      
    • "logistic":: M=2M=2, α1,t=1α2,t\alpha_{1,t}=1-\alpha_{2,t}, and α2,t=[1+exp{γ(yitjc)}]1\alpha_{2,t}=[1+\exp\lbrace -\gamma(y_{it-j}-c) \rbrace]^{-1}, where yitjy_{it-j} is the lag jj

       observation of the $i$th variable, $c$ is a location parameter, and $\gamma > 0$ is a scale parameter.
      
    • "mlogit":: c("alpham,t=fracexplbracegammamzt1rbrace\n\\alpha_{m,t}=\\frac{\\exp\\lbrace \\gamma_m'z_{t-1} \\rbrace}\n", "sumn=1Mexplbracegammanzt1rbrace {\\sum_{n=1}^M\\exp\\lbrace \\gamma_n'z_{t-1} \\rbrace}"), where γm\gamma_m are coefficient vectors, γM=0\gamma_M=0, and zt1z_{t-1} (k×1)(k\times 1) is the vector containing a constant and the (lagged) switching variables.

    • "exponential":: M=2M=2, α1,t=1α2,t\alpha_{1,t}=1-\alpha_{2,t}, and α2,t=1exp{γ(yitjc)}\alpha_{2,t}=1-\exp\lbrace -\gamma(y_{it-j}-c) \rbrace, where yitjy_{it-j} is the lag jj

       observation of the $i$th variable, $c$ is a location parameter, and $\gamma > 0$ is a scale parameter.
      
    • "threshold":: αm,t=1\alpha_{m,t} = 1 if rm1<yitjrmr_{m-1}<y_{it-j}\leq r_{m} and 00 otherwise, where r0<r1<<rM1<rM-\infty\equiv r_0<r_1<\cdots <r_{M-1}<r_M\equiv\infty are thresholds yitjy_{it-j} is the lag jj

       observation of the $i$th variable.
      
    • "exogenous":: Exogenous nonrandom transition weights, specify the weight series in weightfun_pars.

    See the vignette for more details about the weight functions.

  • weightfun_pars: - If weight_function == "relative_dens":: Not used.

    • If weight_function %in% c("logistic", "exponential", "threshold"):: a numeric vector with the switching variable i{1,...,d}i\in\lbrace 1,...,d \rbrace in the first and the lag j{1,...,p}j\in\lbrace 1,...,p \rbrace in the second element.

    • If weight_function == "mlogit":: a list of two elements:

       - **The first element `$vars`:**: a numeric vector containing the variables that should used as switching variables in the weight function in an increasing order, i.e., a vector with unique elements in $\lbrace 1,...,d \rbrace$.
       - **The second element `$lags`:**: an integer in $\lbrace 1,...,p \rbrace$ specifying the number of lags to be used in the weight function.
      
    • If weight_function == "exogenous":: a size (nrow(data) - p x M) matrix containing the exogenous transition weights as [t, m] for time tt and regime mm. Each row needs to sum to one and only weakly positive values are allowed.

  • cond_dist: specifies the conditional distribution of the model as "Gaussian", "Student", "ind_Student", or "ind_skewed_t", where "ind_Student" the Student's tt distribution with independent components, and "ind_skewed_t" is the skewed tt distribution with independent components (see Hansen, 1994).

  • parametrization: "intercept" or "mean" determining whether the model is parametrized with intercept parameters ϕm,0\phi_{m,0} or regime means μm\mu_{m}, m=1,...,M.

  • AR_constraints: a size (Mpd2×q)(Mpd^2 \times q) constraint matrix CC specifying linear constraints to the autoregressive parameters. The constraints are of the form (φ1,...,φM)=Cψ(\varphi_{1},...,\varphi_{M}) = C\psi, where φm=(vec(Am,1),...,vec(Am,p)) (pd2×1), m=1,...,M\varphi_{m} = (vec(A_{m,1}),...,vec(A_{m,p})) \ (pd^2 \times 1),\ m=1,...,M, contains the coefficient matrices and ψ\psi (q×1)(q \times 1) contains the related parameters. For example, to restrict the AR-parameters to be the identical across the regimes, set C=C =

    [I:...:I]' (Mpd2×pd2)(Mpd^2 \times pd^2) where I = diag(p*d^2).

  • mean_constraints: Restrict the mean parameters of some regimes to be identical? Provide a list of numeric vectors such that each numeric vector contains the regimes that should share the common mean parameters. For instance, if M=3, the argument list(1, 2:3) restricts the mean parameters of the second and third regime to be identical but the first regime has freely estimated (unconditional) mean. Ignore or set to NULL if mean parameters should not be restricted to be the same among any regimes. This constraint is available only for mean parametrized models; that is, when parametrization="mean".

  • weight_constraints: a list of two elements, RR in the first element and rr in the second element, specifying linear constraints on the transition weight parameters α\alpha. The constraints are of the form α=Rξ+r\alpha = R\xi + r, where RR is a known (a×l)(a\times l)

    constraint matrix of full column rank (aa is the dimension of α\alpha), rr is a known (a×1)(a\times 1) constant, and ξ\xi is an unknown (l×1)(l\times 1) parameter. Alternatively , set R=0R=0 to constrain the weight parameters to the constant rr (in this case, α\alpha is dropped from the constrained parameter vector).

  • penalized: Perform penalized LS estimation that minimizes penalized RSS in which estimates close to breaking or not satisfying the usual stability condition are penalized? If TRUE, the tuning parameter is set by the argument penalty_params[2], and the penalization starts when the eigenvalues of the companion form AR matrix are larger than 1 - penalty_params[1].

  • penalty_params: a numeric vector with two positive elements specifying the penalization parameters: the first element determined how far from the boundary of the stability region the penalization starts (a number between zero and one, smaller number starts penalization closer to the boundary) and the second element is a tuning parameter for the penalization (a positive real number, a higher value penalizes non-stability more).

  • min_obs_coef: the smallest accepted number of observations (times variables) from each regime relative to the number of parameters in the regime. For models with AR constraints, the number of AR matrix parameters in each regimes is simplisticly assumed to be ncol(AR_constraints)/M.

  • sparse_grid: should the grid of weight function values in LS/NLS estimation be more sparse (speeding up the estimation)?

  • use_parallel: employ parallel computing? If FALSE, does not print anything.

  • ncores: the number CPU cores to be used in parallel computing.

Returns

Returns the estimated parameters in a vector of the form (ϕ1,0,...,ϕM,0,φ1,...,φM,α(\phi_{1,0},...,\phi_{M,0},\varphi_1,...,\varphi_M,\alpha, where

  • ϕm,0=\phi_{m,0} = the (d×1)(d \times 1) intercept vector of the mmth regime.

  • φm=(vec(Am,1),...,vec(Am,p))\varphi_m = (vec(A_{m,1}),...,vec(A_{m,p})) (pd2×1)(pd^2 \times 1).

  • α\alpha is the vector of the weight parameters:

    • weight_function="relative_dens":: α=(α1,...,αM1)\alpha = (\alpha_1,...,\alpha_{M-1})

        $(M - 1 \times 1)$, where $\alpha_m$ $(1\times 1), m=1,...,M-1$ are the transition weight parameters.
      
    • weight_function="logistic":: α=(c,γ)\alpha = (c,\gamma)

        $(2 \times 1)$, where $c\in\mathbb{R}$ is the location parameter and $\gamma \>0$ is the scale parameter.
      
    • weight_function="mlogit":: α=(γ1,...,γM)\alpha = (\gamma_1,...,\gamma_M) ((M1)k×1)((M-1)k\times 1), where γm\gamma_m (k×1)(k\times 1), m=1,...,M1m=1,...,M-1 contains the multinomial logit-regression coefficients of the mmth regime. Specifically, for switching variables with indices in I{1,...,d}I\subset\lbrace 1,...,d\rbrace, and with p~{1,...,p}\tilde{p}\in\lbrace 1,...,p\rbrace lags included, γm\gamma_m contains the coefficients for the vector zt1=(1,z~min{I},...,z~max{I})z_{t-1} = (1,\tilde{z}_{\min\lbrace I\rbrace},...,\tilde{z}_{\max\lbrace I\rbrace}), where z~i=(yit1,...,yitp~)\tilde{z}_{i} =(y_{it-1},...,y_{it-\tilde{p}}), iIi\in I. So k=1+Ip~k=1+|I|\tilde{p}

       where $|I|$ denotes the number of elements in $I$.
      
    • weight_function="exponential":: α=(c,γ)\alpha = (c,\gamma)

        $(2 \times 1)$, where $c\in\mathbb{R}$ is the location parameter and $\gamma \>0$ is the scale parameter.
      
    • weight_function="threshold":: α=(r1,...,rM1)\alpha = (r_1,...,r_{M-1})

        $(M-1 \times 1)$, where $r_1,...,r_{M-1}$ are the thresholds.
      
    • weight_function="exogenous":: Omit α\alpha from the parameter vector.

For models with...

  • AR_constraints:: Replace φ1,...,φM\varphi_1,...,\varphi_M with ψ\psi as described in the argument AR_constraints.

  • weight_constraints:: If linear constraints are imposed, replace α\alpha with ξ\xi as described in the argument weigh_constraints. If weight functions parameters are imposed to be fixed values, simply drop α\alpha

     from the parameter vector.
    

Details

Used internally in the multiple phase estimation procedure proposed by Virolainen (2025). The weight function relative_dens is not supported. Mean constraints are not supported. Only weight constraints that specify the weight parameters as fixed values are supported. Only intercept parametrization is supported.

References

  • Hubrich K., Teräsvirta. T. 2013. Thresholds and Smooth Transitions in Vector Autoregressive Models. CREATES Research Paper 2013-18, Aarhus University.
  • Virolainen S. 2025. Identification by non-Gaussianity in structural threshold and smooth transition vector autoregressive models. Unpublished working paper, available as arXiv:2404.19707.
  • Maintainer: Savi Virolainen
  • License: GPL-3
  • Last published: 2025-02-27

Downloads (last 30 days):