Description Usage Arguments Details Value Author(s) See Also Examples
Simulates a harmonic regression or a semiparametric harmonic regression. Possible types of models are normal, t(5), Laplace, cubic and AR1.
1 2 3 4 |
n |
Length of series. |
f |
Frequency. |
model |
The model used for generating the error term. See details. |
hpar |
structural parameters that specify A and B. See details. |
mu |
constant term |
sig |
The standard error of the series. |
phi |
Only used if AR1 error distribution is selected. |
c |
Only used if Contaminated Normal error distribution is selected. |
g |
A function used to transform the harmonic component. See details. |
Generate a harmonic series y with length n, where
y_t = mu+g( A*cos(2*pi*f*t)+B*sin(2*pi*f*t) )+sig*e_t,\ t=1,...,n,
and e_t comes from one of the following specified distributions
with mean 0 and standard error 1 that are specified
in the argument model
:
Gaussian
: A standard normal distribution (i.i.d.).
ContaminatedNormal
: Generates a random sample from a normal mixture
p*N(0,c^2)+(1-p)*N(0,1) where p=1/(1+c^2)).
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 the cube transform is used on the time series.
AR1
: An AR(1) series with autocorrelation paramater phi
(standardized to mean 0 and variance 1).
The argument hpar
is a list that specifies the sinusoid. If components
A
and B
are defined, these are used. Otherwise if components
R
and zeta
are defined, these specify the amplitude and phase.
Finally, snr
may be used to generate a model with a specified
signal-to-noise ratio and random phase.
Vector of length n, simulated harmonic series.
A.I. McLeod and Yuanhao Lai
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #Simulate the harmonic regression model with standard Gaussian error terms
z <- shreg(10, f=2.5/10, hpar=list(snr=10))
plot(1:10,z,type="b")
#Simulate the AR(1) errors
z <- shreg(50, f=2.5/10, hpar=list(snr=2),model="AR1", phi=0.5, mu=100)
plot(z, type="o")
ans <- hreg(z)
plot(ans)
plot(ans, type="cp")
#Contaminated normal with large outlier
set.seed(77233)
z <- shreg(100, f=4/10, hpar=list(snr=10), model="ContaminatedNormal", c=25)
(out <- hreg(z))
plot(out)
(out <- hreg(z, method="MM",K=100))
plot(out)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.