If you like to use the development version, you can install the package directly
from GitHub:
```{R, eval = FALSE}
devtools::install_github("aschersleben/cointReg", build_vignettes = TRUE)

Load the package:
```{R}
library("cointReg")

Basic examples

Simple test model with one regression variable

Generate a regression variable x and a dependant variable y. The fastest
and easiest way to plot both time series is matplot(...).

set.seed(42)
x <-cumsum(rnorm(200, mean =0, sd =0.1)) +10
y <- x +rnorm(200, sd =0.4) +2matplot(1:200, cbind(y, x), type ="l", main ="Cointegration Model")

Now you can estimate the model parameters with the FM-OLS method and include an
intercept in the model via the deter variable:

deter <-rep(1, 200)
test <-cointRegFM(x = x, y = y, deter = deter)

Print the results:

print(test)

You can see that both the intercept and the regression variable are significant.

Finally, you can plot the residuals:

plot(test, main ="Residuals of the Cointegration Model")

Another test model with three regression variables and a linear trend

set.seed(1909)
x1 <-cumsum(rnorm(100, mean =0.05, sd =0.1))
x2 <-cumsum(rnorm(100, sd =0.1)) +1
x3 <-cumsum(rnorm(100, sd =0.2)) +2
x <-cbind(x1, x2, x3)
y <- x1 + x2 + x3 +rnorm(100, sd =0.2) +1matplot(1:100, cbind(y, x), type ="l", main ="Cointegration Model")

deter <-cbind(level =1, trend =1:100)
test <-cointRegFM(x, y, deter, kernel ="ba", bandwidth ="and")
print(test)

plot(test, main ="Residuals of the Cointegration Model")

Spurious regression example

This is why you should use modified OLS methods instead of a normal OLS model
to estimate parameters of a cointegrating regression:

set.seed(26)
x <-cumsum(rnorm(200))
y <-cumsum(rnorm(200))
summary(lm(y ~ x))

The independant variable x seems to be significant at a very secure level.

And now have a look at the results of an FM-OLS regression:

cointRegFM(x = x, y = y, deter =rep(1, 200))

So the x variable doesn't have an influence on y -- which makes sense
because they were generated independently.