# uGMAR

The goal of uGMAR is to provide tools for analysing Gaussian mixture autoregressive (GMAR), Student’s t mixture Autoregressive (StMAR) and Gaussian and Student’s t mixture autoregressive (G-StMAR) models. uGMAR provides functions for unconstrained and constrained maximum likelihood estimation of the model parameters, quantile residual based model diagnostics, simulation from the processes, and forecasting.

## Installation

You can install the released version of uGMAR from CRAN with:

`install.packages("uGMAR")`

And the development version from GitHub with:

```
# install.packages("devtools")
devtools::install_github("saviviro/uGMAR")
```

## Example

This is a basic example how to estimate a GMAR model to data. The example data is simulated from a GMAR p=1, M=2 process. The estimation process is computationally demanding and takes advantage of parallel computing. After estimating the model, it’s shown by simple examples how to conduct some further analysis.

```
## Estimate a GMAR(1, 2) model and examine the estimates
data(simudata, package="uGMAR")
fit <- fitGSMAR(data=simudata, p=1, M=2, model="GMAR")
fit
summary(fit) # Approximate standard errors in brackets
plot(fit)
get_gradient(fit) # The first order condition
get_soc(fit) # The second order condition (eigenvalues of approximated Hessian)
profile_logliks(fit) # Plot the profile log-likelihood functions
## Quantile residual diagnostics
quantileResidualPlot(fit)
diagnosticPlot(fit)
qrt <- quantileResidualTests(fit)
## Simulate a sample path from the estimated process
sim <- simulateGSMAR(fit, nsimu=10)
## Forecast future values of the process
predict(fit, n_ahead=10, pi=c(0.95, 0.8))
```

## References

- Kalliovirta L., Meitz M. and Saikkonen P. 2015. Gaussian Mixture Autoregressive model for univariate time series.
*Journal of Time Series Analysis*, **36**, 247-266.
- Meitz M., Preve D., Saikkonen P. 2018. A mixture autoregressive model based on Student’s t-distribution. arXiv:1805.04010
** ***e***c**o**n***.*EM
- Virolainen S. 2020. A mixture autoregressive model based on Gaussian and Student’s t-distribution. arXiv:2003.05221 [econ.EM].