knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This is an introduction in how to use the AR1 package. The package contains a few functions that can fx simulate a AR(1) process.
A quick guide on how to install the package. Use the function install.package() to download it and then load it with;
library("AR1")
We will here show an example, that should visualize how to use the function. Here we have a AR(1) process, $$Y_{n+1}=\varphi Y_n+\varepsilon_n$$ where the white noise, $\varepsilon_n$, is a process with zero mean and variance 1 and the parameter and t distribution with 1.5 degrees of freedom, and $\varphi = 0.8$. Futhermore we have that $Y_0=0$.
y <- simAR1(0, 300, 0.8, distfun = rnorm, 300) plot(y, type = "l", main = "Normal distribution") x <- simAR1(0, 300, 0, distfun = rt, 300, 1.5) plot(y, type = "l", main = "t distribution")
The function LLN() will help determine if there is a Law of Large Numbers. The function also plots the mean. CLT() helps determine if $$\frac{\sum_{i=1}^n Y_i}{\sqrt{n}}$$ converges in distribution as $n\to\infty$ to a normal distribution. Here is an example of how to use the two functions:
x <- replicate(10, simAR1(0, 5000, 0.8, rnorm, 5000)) LLN(x) w <- replicate(50000,simAR1(0, 1000, 0.8, rnorm, 1000)) CLT(w)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.