Time Series Analysis
chartSeries(TITAN,multi.col=TRUE,theme="white")> addADX()
> addRSI()
> addMACD()
> TITAN_return <-
+ log(TITAN$TITAN.NS.Close/TITAN$TITAN.NS.Open)
> qqnorm(TITAN_return, main = "Normal Q-Q Plot of TITAN daily log return",
+ xlab = "Theoretical Quantiles",
+ ylab = "Sample Quantiles", plot.it = TRUE, datax = FALSE
+ )
> qqline(TITAN_return, col="red")
> qqnorm(TITAN_return, main = "Normal Q-Q Plot of TITAN daily log return",
+ xlab = "Theoretical Quantiles",ylab = "Sample Quantiles", plot.it = TRUE, datax = FALSE )
> ret <- dailyReturn(Cl(TITAN), type='log')
Warning message:
In to_period(xx, period = on.opts[[period]], ...) :
missing values removed from data
> 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))
> kurtosis(ret)
[1] 6.615807
attr(,"method")
[1] "excess"
> 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")
> plot(density(ret), xlim=c(-5*s,5*s),log='y', main='Density on log-scale')
> curve(dnorm(x, mean=m,sd=s), from=-5*s, to=5*s, log="y", add=TRUE,
+ col="red")
> qqnorm(ret);qqline(ret)
> library("rugarch", lib.loc="~/R/win-library/3.5")
garch11.spec = ugarchspec(variance.model = list(model="sGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> titan.garch11.fit = ugarchfit(spec=garch11.spec, data=ret)
> coef(titan.garch11.fit)
mu omega alpha1
0.0015069015 0.0001130584 0.1180053516
beta1
0.6339646076
> ni.garch11 <- newsimpact(titan.garch11.fit)
> plot(ni.garch11$zx, ni.garch11$zy, type="l", lwd=2, col="blue",
+ main="GARCH(1,1) - News Impact", ylab=ni.garch11$yexpr, xlab=ni.
+ garch11$xexpr)
Error: unexpected symbol in:
" main="GARCH(1,1) - News Impact", ylab=ni.garch11$yexpr, xlab=ni.
garch11"
> plot(ni.garch11$zx, ni.garch11$zy, type="l", lwd=2, col="blue",main="GARCH(1,1) - News Impact", ylab=ni.garch11$yexpr, xlab=ni.garch11$xexpr)
0 Comments