Skip to content

Instantly share code, notes, and snippets.

@emorisse
Created July 28, 2018 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emorisse/46fcbf2d4d02726b8bcbfb606505276d to your computer and use it in GitHub Desktop.
Save emorisse/46fcbf2d4d02726b8bcbfb606505276d to your computer and use it in GitHub Desktop.
search <- read.csv("latest.search.csv", stringsAsFactors = FALSE)
openstack.month <- "2009-09"
search <- search[which(search$Month == openstack.month):nrow(search),]
search$austin <- 0
austin.month <- which(search$Month == "2016-04")
search[austin.month:nrow(search),]$austin <- 1
# test for stationary data
library(tseries)
adf.test(search$cloud.tco...Worldwide., alternative = "stationary")
library(ggplot2)
library(ggthemes)
library(forecast)
arimax <- auto.arima(search$cloud.tco...Worldwide.,xreg=data.frame(blog=search$blog), stepwise=FALSE, parallel = TRUE)
p<-(1-pnorm(abs(arimax$coef)/sqrt(diag(arimax$var.coef))))*2
print(p)
months <- sum(search$austin)
# 12 months
(12*arimax$coef["blog"])/sum(search[0:(11)+austin.month,]$cloud.tco...Worldwide.)
# all
(months*arimax$coef["blog"])/sum(search[0:(months-1)+austin.month,]$cloud.tco...Worldwide.)
awith.df <- data.frame(Month = search$Month, prediction=arimax$coef["intercept"]+arimax$coef["blog"]*search$blog)
png("CloudTCOSearchVolumeMST.png", width=1600,height=750,res=150)
ggplot(search, aes(y=cloud.tco...Worldwide.,x=Month,group=1)) +
geom_line(data=awith.df, aes(x=Month, y=prediction)) +
geom_line(color="gray50") +
geom_vline(xintercept=which(search$Month=="2016-01"), color="red") +
theme_tufte(base_family="Overpass") +
labs(y='"cloud tco" search volume on Google',x="") +
theme(axis.text.x = element_text(angle=90, hjust=1))
dev.off()
summary(lm(cloud.tco...Worldwide.~austin,data=search))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment