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
- Host: GitHub
- URL: https://github.com/daandejongen/hystar
- Owner: daandejongen
- License: other
- Created: 2022-07-18T16:26:00.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-19T10:34:36.000Z (over 2 years ago)
- Last Synced: 2025-10-17T04:05:01.592Z (8 months ago)
- Topics: autoregression, estimation, hysteresis, simulation, statistics, threshold, time-series-analysis
- Language: R
- Homepage: https://daandejongen.github.io/hystar/
- Size: 4.93 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
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%"
)
```
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://github.com/daandejongen/hystar/actions/workflows/R-CMD-check.yaml)
[](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.
