Nmdl: Normal distribution model

View source: R/models.R

NmdlR Documentation

Normal distribution model

Description

This function estimates a univariate or multivariate normally distributed model. This can be used for the null hypothesis of a linear model against an alternative hypothesis of a HMM with k regimes.

Usage

Nmdl(Y, Z = NULL, control = list())

Arguments

Y

a (T x q) matrix of observations.

Z

an otpional (T x qz) matrix of exogenous regressors. Default is NULL.

control

List with model options including:

  • const: Boolean determining whether to estimate model with constant if TRUE or not if FALSE. Default is TRUE.

  • getSE: Boolean determining whether to compute standard errors of parameters if TRUE or not if FALSE. Default is TRUE.

Value

List of class Nmdl (S3 object) with model attributes including:

  • y: a (T x q) matrix of observations.

  • fitted: a (T x q) matrix of fitted values.

  • resid: a (T x q) matrix of residuals.

  • mu: a (1 x q) vector of estimated means of each process.

  • intercept: a (1 x q) vector of estimated intercept of each process. If Z is NULL, it is the same as mu.

  • beta: a ((1 + p + qz) x q) matrix of estimated coefficients.

  • betaZ: a (qz x q) matrix of estimated exogenous regressor coefficients (If Z is provided).

  • stdev: a (q x 1) vector of estimated standard deviation of each process.

  • sigma: a (q x q) estimated covariance matrix.

  • theta: vector containing: mu, betaZ (if matrix Z is provided), and vech(sigma).

  • theta_mu_ind: vector indicating location of mean with 1 and 0 otherwise.

  • theta_sig_ind: vector indicating location of variance and covariances with 1 and 0 otherwise.

  • theta_var_ind: vector indicating location of variances with 1 and 0 otherwise.

  • n: number of observations (same as T).

  • q: number of series.

  • k: number of regimes. This is always 1 in Nmdl.

  • control: List with model options used.

  • logLike: log-likelihood.

  • AIC: Akaike information criterion.

  • BIC: Bayesian (Schwarz) information criterion.

  • Hess: Hessian matrix. Approximated using hessian and only returned if getSE=TRUE.

  • info_mat: Information matrix. Computed as the inverse of -Hess. If matrix is not PD then nearest PD matrix is obtained using nearest_spd. Only returned if getSE=TRUE.

  • nearPD_used: Boolean determining whether nearPD function was used on info_mat if TRUE or not if FALSE. Only returned if getSE=TRUE.

  • theta_se: standard errors of parameters in theta. Only returned if getSE=TRUE.

Examples

set.seed(1234)

# ----- Univariate ----- # 
# Define DGP 
mdl_norm <- list(n     = 1000, 
                 q     = 1,
                 mu    = as.matrix(5),
                 sigma = as.matrix(5.0))

# Simulate process using simuNorm() function
y_norm_simu <- simuNorm(mdl_norm)

# estimate parameters
y_norm_mdl <- Nmdl(y_norm_simu$y)
summary(y_norm_mdl)


# ----- Multivariate ----- # 
# Define DGP 
mdl_norm <- list(n     = 1000, 
                 q     = 2,
                 mu    = c(5, -2),
                 sigma = rbind(c(5.0, 1.5),
                               c(1.5, 1.0)))

# Simulate process using simuNorm() function
y_norm_simu <- simuNorm(mdl_norm)

# estimate parameters
y_norm_mdl <- Nmdl(y_norm_simu$y)
summary(y_norm_mdl)

roga11/MSTest documentation built on Feb. 25, 2025, 6:10 p.m.