Generates a random pair of cointegrated sequences
rcoint(n,
alpha = runif(1, -10, 10),
beta = runif(1, -10, 10),
rho = runif(1, 0, 1),
sd_eps = 1,
sd_delta = 1,
X0=0,
Y0=0)
Returns a two-column data.frame containing the randomly generated cointegrated sequences.
number of observations in each sequence
constant term of linear relation
slope term of linear relation
coefficient of mean reversion
standard deviation of innovations in first sequence
standard deviation of innovations in residual sequence
initial value of first sequence
initial value of second sequence
Matthew Clegg matthewcleggphd@gmail.com
Generates a random pair of cointegrated sequences. The sequences are constructed
by first generating two random sequences that are independent and normally distributed.
The elements of the first sequence, \(\epsilon[i]\),
have standard deviation sd_eps
,
while those of the second sequence, \(\delta[i]\),
have standard deviation sd_delta
.
Having generated these two sequences, the cointegrated sequences X[i]
and
Y[i]
are generated according to the following relations:
$$X[i] = X[i-1] + \epsilon[i]$$
$$R[i] = \rho R[i-1] + \delta[i]$$
$$Y[i] = \alpha + \beta X[i] + R[i]$$
rar1
sim.egcm
egcm
xy <- rcoint(1000, alpha = 1, beta = 2, rho = 0.8)
egcm(xy)
Run the code above in your browser using DataLab