An open API service indexing awesome lists of open source software.

https://github.com/daandejongen/hystar

R package that simulates and estimates the hystar model
https://github.com/daandejongen/hystar

autoregression estimation hysteresis simulation statistics threshold time-series-analysis

Last synced: 4 months ago
JSON representation

R package that simulates and estimates the hystar model

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# hystar

[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/daandejongen/hystar/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/daandejongen/hystar/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/daandejongen/hystar/branch/master/graph/badge.svg)](https://app.codecov.io/gh/daandejongen/hystar?branch=master)

## Overview

With the R-package [`hystar`](https://cran.r-project.org/package=hystar), you can simulate data from the hysteretic threshold autoregressive (HysTAR) model, and estimate its parameters. It comes with three functions:

* `hystar_fit`, to **estimate** the HysTAR parameters with the **conditional least squares** method, using your own data or simulated data,

* `z_sim`, to simulate a **threshold variable**,

* `hystar_sim`, to simulate an **outcome variable**.

Results from the time series analysis can be assessed with the standard methods in R, like `plot`, `summary` and `print`. Additionally, you can extract the predictive residuals with the `residuals`-method for further analysis.

## Use

A minimal example:

```{r}
library(hystar)
control_variable <- z_sim(n_t = 100)
simulated_hystar_model <- hystar_sim(z = control_variable)
fitted_hystar_model <- hystar_fit(data = simulated_hystar_model$data)
summary(fitted_hystar_model)
```

## Install

For the current [CRAN release](https://cran.r-project.org/package=hystar) (1.0.0):

```
install.packages("hystar")
```

For the development version (1.2.0.9000):

```
devtools::install_github("daandejongen/hystar")
```

## Cite

If you have used this package for an scientific publication, please cite it with:

De Jong, D. (2022). _hystar: Simulation and Estimation of the Hysteretic TAR Model_. R package version 1.2.0, .

BibTeX:
```
@Manual{,
title = {hystar: Simulation and Estimation of the Hysteretic TAR Model},
author = {Daan {de Jong}},
year = {2022},
note = {R package version 1.2.0},
url = {https://github.com/daandejongen/hystar/},
}
```

## Get more info

For more information about the package, see the [`hystar` website](https://daandejongen.github.io/hystar/).

If you want to read more about the HysTAR model itself, see the paper with the original proposal of the HysTAR model in Biometrika ([Li, Guan, Li and Yu (2015)](https://academic.oup.com/biomet/article-abstract/102/3/717/2365298?login=false)). Or, for a mathematically more accessible introduction, see [the paper](https://osf.io/preprints/psyarxiv/zrcft) (pre-print) I wrote about detecting hysteresis with the HysTAR model in psychological time series.