simHReg {ptest} | R Documentation |
Simulates a harmonic regression. Possible types of models are normal, t(5), Laplace, cubic and AR1.
simHReg(n, f, A, B, model = c("Gaussian", "t5", "Laplace", "cubic", "AR1"), phi = 0, sig = 1)
n |
Length of series. |
f |
Frequency. |
A |
Cosine amplitude. |
B |
Sine amplitude. |
model |
The model used for generating the error term. See details. |
phi |
Only used if AR1 error distribution is selected. |
sig |
The standard error of the series. |
Generate a harmonic series y with length n, where y_t = A*cos(2*pi*f*t)+B*sin(2*pi*f*t)+sig*e_t,\ t=1,...,n, and e comes from one of the following specified distributions with mean 0 and standard error 1:
Gaussian
: A standard normal distribution (i.i.d.).
t5
: A t distribution with 5 degrees of freedom
(i.i.d., standardized to mean 0 and variance 1).
Laplace
: A Laplace (double exponential) distribution
(i.i.d., standardized to mean 0 and variance 1).
cubic
: A standard normal distribution for e,
but y=y^3 this time.
AR1
: An AR(1) series with autocorrelation paramater phi
(standardized to mean 0 and variance 1).
Vector of length n, simulated harmonic series.
A.I. McLeod and Yuanhao Lai
McLeod, A.I., Yu, Hao and Krougly, Z. (2007), Algorithms for Linear Time Series Analysis: With R Package, Journal of Statistical Software 23, 5 1-26.
#Simulate the harmonic regression model with standard Gaussian error terms z <- simHReg(10, f=2/10, 1, 2, model="Gaussian",sig=1) #Fourier Frequency plot(1:10,z,type="b") #Simulate the AR(1) errors z <- simHReg(10, f=0/10, 0,0, model="AR1",phi=0.2,sig=1) acf(z)