## How to use Vector autoregressive models (VAR) in the stock market.

We get data MSFT from '2004-01-02', to='2019-07-30'

Draw chartSeries(ClCl(MSFT))

https://3159fhojn2sad855sm1blf1y9c.hop.clickbank.net

https://3159fhojn2sad855sm1blf1y9c.hop.clickbank.net

MSFT.ret <- diff(log(Ad(MSFT)))

> MSFT.M <- to.monthly(MSFT.ret)$MSFT.ret.Close

ret <- dailyReturn(Cl(MSFT), type='log')

par(mfrow=c(2,2))

> acf(ret, main="Return ACF");

> pacf(ret, main="Return PACF");

> acf(ret^2, main="Squared return ACF");

> pacf(ret^2, main="Squared return PACF")

> par(mfrow=c(1,1))

> m=mean(ret);s=sd(ret);

> par(mfrow=c(1,2))

hist(ret, nclass=40, freq=FALSE, main='Return histogram');curve(dnorm(x,

+ mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")

> plot(density(ret), main='Return empirical distribution');curve(dnorm(x,

+ mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")

> par(mfrow=c(1,1))

plot(density(ret), main='Return EDF - upper tail', xlim = c(0.1, 0.2),

+ ylim=c(0,2));

> curve(dnorm(x, mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")