-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
83 lines (58 loc) · 3.09 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# hystar <a href="https://daandejongen.github.io/hystar/"><img src="man/figures/logo.png" align="right" height="139" /></a>
<!-- badges: start -->
[![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)
<!-- badges: end -->
## 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, <https://github.com/daandejongen/hystar/>.
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.