data.gen.SW: Generate predictor and response data: Sinusoidal model

Description Usage Arguments Value References Examples

View source: R/data_gen_SW.R

Description

Generate predictor and response data: Sinusoidal model

Usage

1
data.gen.SW(nobs = 500, freq = 50, A = 2, phi = pi, mu = 0, sd = 1)

Arguments

nobs

The data length to be generated.

freq

The frequencies in the generated response. Default freq=50.

A

The amplitude of the sinusoidal series

phi

The phase of the sinusoidal series

mu

The mean of Gaussian noise in the variable.

sd

The standard deviation of Gaussian noise in the variable.

Value

A list of time and x.

References

Shumway, R. H., & Stoffer, D. S. (2011). Characteristics of Time Series. In D. S. Stoffer (Ed.), Time series analysis and its applications (pp. 8-14). New York : Springer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
### Sinusoidal model
delta <- 1/12 # sampling rate, assuming monthly
period.max<- 2^5

N = 6*period.max/delta
scales<- 2^(0:5)[c(2,6)] #pick two scales
scales

### scale, period, and frequency
# freq=1/T; T=s/delta so freq = delta/s
# since t is t is within 0-1, so freq need to have a factor of N.

x1 <- NULL
for(i in scales){ # i is the scale

  tmp <- synthesis::data.gen.SW(nobs=N, freq = 1/i*N*delta, A = 1, phi = 0, mu=0, sd = 0)$x

  x1 <- cbind(x1, tmp)
}
x <- rowSums(data.frame(x1))
plot.ts(cbind(x1,x), type = 'l')

synthesis documentation built on May 3, 2021, 9:07 a.m.