1) t.test
t.test between grop of cli delta is minus and plus. result is there is only 0.019% probability that those two groups posess same mean value. This result means they are different groups each other.
t.test(
diff(eps_year_xts,1)["2001::2018"][ apply.quarterly(diff(cli_xts$usa),mean)["2001::2018"] > 0],
diff(eps_year_xts,1)["2001::2018"][ apply.quarterly(diff(cli_xts$usa),mean)["2001::2018"] < 0]
)
# Welch Two Sample t-test
#
# data: diff(eps_year_xts, 1)["2001::2018"][apply.quarterly(diff(cli_xts$usa), and diff(eps_year_xts, 1)["2001::2018"][apply.quarterly(diff(cli_xts$usa), mean)["2001::2018"] > 0] and mean)["2001::2018"] < 0]
# t = 3.9531, df = 66.145, p-value = 0.0001903
# alternative hypothesis: true difference in means is not equal to 0
# 95 percent confidence interval:
# 3.115924 9.474840
# sample estimates:
# mean of x mean of y
# 4.117125 -2.178257
2) spot diagram
diff(eps_year_xts,1)["2001::2018"][ apply.quarterly(diff(cli_xts$usa),mean)["2001::2018"] > 0]
df <- data.frame(
cli=as.vector(apply.quarterly(diff(cli_xts$oecd),mean)["2001::2018"]),
eps=as.vector(diff(eps_year_xts,1)["2001::2018"]),
sign=as.vector(year(index(diff(eps_year_xts,1)["2001::2018"])))
)
p <- ggplot(df, aes(x=cli,y=eps,color=sign))
p <- p + geom_point(alpha=0.5)
p <- p + geom_smooth(method = "lm")
plot(p)
3)histgram
func <- function(x){if(x > 0){return("p")}else{return("m")}}
df <- data.frame(eps=round(as.vector(diff(eps_year_xts,1)["2001::2018"]),digits=2),
sign=as.vector(apply(apply.quarterly(diff(cli_xts$usa),mean)["2001::2018"],1,func)))
# parameter ase() better be put into a single line.
p <- ggplot(df, aes(x=eps,fill=sign))
p <- p + geom_histogram(bins=50,position = "identity", alpha = 0.5)
plot(p)
0 件のコメント:
コメントを投稿