The output of each series is computed and presented in the table below.
returns <- read.table("d-axp3dx-0111.txt", header = TRUE)
returns <- as.data.frame(returns[, 2:5])
for(i in 1:4){
returns[,i] <- as.numeric(as.character(returns[,i]))
}
mean <- sapply(returns, mean)
sd <- sapply(returns, sd)
skewness <- sapply(returns, function(x) sum(((x - mean(x))/sd(x))^3)/(length(x)-1))
kurtosis <- sapply(returns, function(x) sum(((x - mean(x))/sd(x))^4)/(length(x)-1) )
min <- sapply(returns, min)
max <- sapply(returns, max)
output <- data.frame(mean, sd, skewness, kurtosis, min, max)
output
## mean sd skewness kurtosis min max
## axp 0.0005339487 0.02636841 0.45995481 12.59702 -0.175949 0.206485
## vw 0.0002240615 0.01365184 -0.09835717 10.98647 -0.089762 0.114889
## ew 0.0006258233 0.01208037 -0.24750781 11.11281 -0.078240 0.107422
## sp 0.0000942284 0.01377912 0.00815516 11.53722 -0.090350 0.115800
The process is repeated but for the log returns.
logreturns <- returns
for(i in 1:4){
logreturns[,i] <- log(logreturns[,i] + 1)
}
mean <- sapply(logreturns, mean)
sd <- sapply(logreturns, sd)
skewness <- sapply(logreturns, function(x) sum(((x - mean(x))/sd(x))^3)/(length(x)-1))
kurtosis <- sapply(logreturns, function(x) sum(((x - mean(x))/sd(x))^4)/(length(x)-1) )
min <- sapply(logreturns, min)
max <- sapply(logreturns, max)
output <- data.frame(mean, sd, skewness, kurtosis, min, max)
output
## mean sd skewness kurtosis min max
## axp 1.880014e-04 0.02629439 0.02100007 12.02524 -0.19352286 0.1877112
## vw 1.307504e-04 0.01367036 -0.30047081 10.88438 -0.09404918 0.1087548
## ew 5.525758e-04 0.01209955 -0.42748369 11.02206 -0.08147039 0.1020348
## sp -7.486380e-07 0.01379041 -0.20643834 11.32729 -0.09469537 0.1095716
Test of the null hypothesis that the mean of log returns for AXP stock is zero at 5 percent significance.
#t statistic and p-value
t.test(logreturns[, 1], mu = 0)
##
## One Sample t-test
##
## data: logreturns[, 1]
## t = 0.35999, df = 2534, p-value = 0.7189
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## -0.0008360686 0.0012120714
## sample estimates:
## mean of x
## 0.0001880014
So the mean of the log returns for AXP stock is not significantly different from zero.
Following the same process as above, but with GE monthly returns, yields the following output.
returns <- read.table("./m-ge3dx-4011.txt", header = T)
returns[,5] <- as.numeric(as.character(returns[,5]))
returns <- as.data.frame(returns[, 2:5])
sapply(returns, anyNA)
## ge vw ew sp
## FALSE FALSE FALSE TRUE
#since there are NA values in column 4, we will impute them with the mean
returns[is.na(returns[,4]),4] <- mean(returns[,4], na.rm = T)
mean <- sapply(returns, mean)
sd <- sapply(returns, sd)
skewness <- sapply(returns, function(x) sum(((x - mean(x))/sd(x))^3)/(length(x)-1))
kurtosis <- sapply(returns, function(x) sum(((x - mean(x))/sd(x))^4)/(length(x)-1) )
min <- sapply(returns, min)
max <- sapply(returns, max)
output <- data.frame(mean, sd, skewness, kurtosis, min, max)
output
## mean sd skewness kurtosis min max
## ge 0.010518621 0.06599786 0.05167823 4.244417 -0.272877 0.251236
## vw 0.009316476 0.04332840 -0.66158911 5.361547 -0.225363 0.165585
## ew 0.012178942 0.05479283 -0.30732110 6.145950 -0.272248 0.299260
## sp 0.006177714 0.04266439 -0.59048394 5.373762 -0.239541 0.163047
logreturns <- returns
for(i in 1:4){
logreturns[,i] <- log(logreturns[,i] + 1)
}
mean <- sapply(logreturns, mean)
sd <- sapply(logreturns, sd)
skewness <- sapply(logreturns, function(x) sum(((x - mean(x))/sd(x))^3)/(length(x)-1))
kurtosis <- sapply(logreturns, function(x) sum(((x - mean(x))/sd(x))^4)/(length(x)-1) )
min <- sapply(logreturns, min)
max <- sapply(logreturns, max)
output <- data.frame(mean, sd, skewness, kurtosis, min, max)
output
## mean sd skewness kurtosis min max
## ge 0.008318049 0.06573543 -0.2911199 4.783872 -0.3186596 0.2241319
## vw 0.008330507 0.04373975 -0.9441484 6.525491 -0.2553607 0.1532231
## ew 0.010611435 0.05504328 -0.7465789 7.177996 -0.3177949 0.2617949
## sp 0.005240954 0.04312955 -0.8794361 6.619759 -0.2738331 0.1510433
#t statistic and p-value
t.test(logreturns[, 1], mu = 0)
##
## One Sample t-test
##
## data: logreturns[, 1]
## t = 3.713, df = 860, p-value = 0.000218
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 0.003921037 0.012715061
## sample estimates:
## mean of x
## 0.008318049
Since the p-value for the two-sided alternative is less than .05, we can conclude that the mean of the log monthly returns for GE are significantly different than zero. Further, since the 95 percent confidence interval is strictly greater than zero, we can conclude with 95 percent confidence that the mean log monthly return for GE is significantly greater than zero.
First testing H_0: \(\mu = 0\) with a two sided alternative for the monthtly stock returns of the S&P index.
t.test(returns[, "sp"], mu = 0)
##
## One Sample t-test
##
## data: returns[, "sp"]
## t = 4.2488, df = 860, p-value = 2.384e-05
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 0.003323913 0.009031515
## sample estimates:
## mean of x
## 0.006177714
Since the p-value is less than .05, we conclude that the mean monthly return is significantly different from zero.
Now testing if the skewness is zero, using a two-sided alternative.
sp <- returns[, "sp"]
s.hat <- sum(((sp - mean(sp))/sd(sp))^3)/(length(sp)-1)
s.hat
## [1] -0.5904839
t.stat <- s.hat/(sqrt(6/length(sp)))
t.stat
## [1] -7.073495
p <- 2 * pnorm(t.stat, lower.tail = T)
p
## [1] 1.510796e-12
Since the p-value is less than .05, we can reject the null and conclude that skewness is not 0.
Lastly, we test if the kurtosis is 3, using a two-sided alternative.
x <- returns[, "sp"]
kurt.hat <-sum(((x - mean(x))/sd(x))^4)/(length(x)-1)
kurt.hat
## [1] 5.373762
t.stat <- (kurt.hat - 3)/(sqrt(24/length(x)))
t.stat
## [1] 14.21782
p <- 2 * pnorm(abs(t.stat), lower.tail = FALSE)
p
## [1] 7.102656e-46
Since the p-value is less than .05, we can reject the null and conclude that kurtosis is significantly different from 3.
First, test if skewness of the daily log returns of American Express is zero.
returns <- read.table("d-axp3dx-0111.txt", header = TRUE)
returns <- as.data.frame(returns[, 2:5])
for(i in 1:4){
returns[,i] <- as.numeric(as.character(returns[,i]))
}
axp <- returns[, "axp"]
s.hat <- sum(((axp - mean(axp))/sd(axp))^3)/(length(axp)-1)
s.hat
## [1] 0.4599548
t.stat <- s.hat/(sqrt(6/length(axp)))
t.stat
## [1] 9.454281
p <- 2 * pnorm(abs(t.stat), lower.tail = F)
p
## [1] 3.252488e-21
Since the p-value is less than .05, we can reject the null and conclude that skewness is not 0.
Next, test if the daily log returns have an excess kurtosis of zero, using a two-sided alternative.
x <- returns[, "axp"]
kurt.hat <-sum(((x - mean(x))/sd(x))^4)/(length(x)-1)
kurt.hat
## [1] 12.59702
t.stat <- (kurt.hat - 3)/(sqrt(24/length(x)))
t.stat
## [1] 98.63246
p <- 2 * pnorm(abs(t.stat), lower.tail = FALSE)
p
## [1] 0
Since the p-value is less than .05, we can reject the null and conclude that kurtosis is significantly different from 0.