get_varying_h: Get differences 'h' which are adjusted for overly large...

Description Usage Arguments Details Value

View source: R/numericalDifferentiation.R

Description

get_varying_h adjusts differences for overly large degrees of freedom parameters for finite difference approximation of the derivatives of the log-likelihood function.

Usage

1
get_varying_h(M, params, model = c("GMVAR", "StMVAR", "G-StMVAR"))

Arguments

M
For GMVAR and StMVAR models:

a positive integer specifying the number of mixture components.

For G-StMVAR models:

a size (2x1) integer vector specifying the number of GMVAR type components M1 in the first element and StMVAR type components M2 in the second element. The total number of mixture components is M=M1+M2.

params

a real valued vector specifying the parameter values.

For unconstrained models:

Should be size ((M(pd^2+d+d(d+1)/2+2)-M1-1)x1) and have the form θ = (υ_{1}, ...,υ_{M}, α_{1},...,α_{M-1},ν), where

  • υ_{m} = (φ_{m,0},φ_{m},σ_{m})

  • φ_{m} = (vec(A_{m,1}),...,vec(A_{m,p})

  • and σ_{m} = vech(Ω_{m}), m=1,...,M,

  • ν=(ν_{M1+1},...,ν_{M})

  • M1 is the number of GMVAR type regimes.

For constrained models:

Should be size ((M(d+d(d+1)/2+2)+q-M1-1)x1) and have the form θ = (φ_{1,0},...,φ_{M,0},ψ, σ_{1},...,σ_{M},α_{1},...,α_{M-1},ν), where

  • ψ (qx1) satisfies (φ_{1},..., φ_{M}) = C ψ where C is a (Mpd^2xq) constraint matrix.

For same_means models:

Should have the form θ = (μ,ψ, σ_{1},...,σ_{M},α_{1},...,α_{M-1},ν), where

  • μ= (μ_{1},...,μ_{g}) where μ_{i} is the mean parameter for group i and g is the number of groups.

  • If AR constraints are employed, ψ is as for constrained models, and if AR constraints are not employed, ψ = (φ_{1},...,φ_{M}).

For structural models:

Should have the form θ = (φ_{1,0},...,φ_{M,0},φ_{1},...,φ_{M}, vec(W),λ_{2},...,λ_{M},α_{1},...,α_{M-1},ν), where

  • λ_{m}=(λ_{m1},...,λ_{md}) contains the eigenvalues of the mth mixture component.

If AR parameters are constrained:

Replace φ_{1},..., φ_{M} with ψ (qx1) that satisfies (φ_{1},..., φ_{M}) = C ψ, as above.

If same_means:

Replace (φ_{1,0},...,φ_{M,0}) with (μ_{1},...,μ_{g}), as above.

If W is constrained:

Remove the zeros from vec(W) and make sure the other entries satisfy the sign constraints.

If λ_{mi} are constrained:

Replace λ_{2},...,λ_{M} with γ (rx1) that satisfies (λ_{2},..., λ_{M}) = C_{λ} γ where C_{λ} is a (d(M-1) x r) constraint matrix.

Above, φ_{m,0} is the intercept parameter, A_{m,i} denotes the ith coefficient matrix of the mth mixture component, Ω_{m} denotes the error term covariance matrix of the m:th mixture component, and α_{m} is the mixing weight parameter. The W and λ_{mi} are structural parameters replacing the error term covariance matrices (see Virolainen, 2020). If M=1, α_{m} and λ_{mi} are dropped. If parametrization=="mean", just replace each φ_{m,0} with regimewise mean μ_{m}. vec() is vectorization operator that stacks columns of a given matrix into a vector. vech() stacks columns of a given matrix from the principal diagonal downwards (including elements on the diagonal) into a vector.

In the GMVAR model, M1=M and ν is dropped from the parameter vector. In the StMVAR model, M1=0. In the G-StMVAR model, the first M1 regimes are GMVAR type and the rest M2 regimes are StMVAR type. In StMVAR and G-StMVAR models, the degrees of freedom parameters in ν should be strictly larger than two.

The notation is similar to the cited literature.

model

is "GMVAR", "StMVAR", or "G-StMVAR" model considered? In the G-StMVAR model, the first M1 components are GMVAR type and the rest M2 components are StMVAR type.

Details

This function is used for approximating gradient and Hessian of a StMVAR or G-StMVAR model. Very large degrees of freedom parameters cause significant numerical error if too small differences are used.

Value

Returns a vector with the same length as params. For other parameters than degrees of freedom parameters larger than 100, the differences will be 6e-6. For the large degrees of freedom parameters, the difference will be signif(df/1000, digits=2).


saviviro/gmvarkit documentation built on Oct. 25, 2021, 2:14 a.m.