mjaniec

Analyzing iPad 3 U.S. adoption based on Chitika data

Apr 11th, 2012
58
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # blog post: http://www.reakkt.com/2012/04/are-new-ipad-sales-slowing.html
  2.  
  3. ### CHITIKA DATA
  4. # http://labs.chitika.com/ipad/
  5. ### CODE
  6.  
  7. library(TTR)
  8.  
  9. dataN <- length(iPadNewData)
  10. avgN  <- ceiling(dataN/10)
  11.  
  12. m <- runMean(iPadNewData,avgN)
  13. v <- runSD(iPadNewData,avgN)
  14.  
  15. delta <- rep(NA,dataN)
  16. for (i in (avgN*2):dataN) delta[i] <- log( m[i] / m[i-avgN+1] )
  17.  
  18. par(mfrow=c(2,1))
  19.  
  20. plot(iPadNewData,type="l",log="y",
  21.      main="new iPad U.S. adoption (log)",
  22.      sub="source: Chitika",
  23.      ylab="adoption %")
  24. lines(m,col="Red",lty="solid")
  25. lines(m+2*v,col="Orange",lty="dotted")
  26. lines(m-2*v,col="Orange",lty="dotted")
  27. legend("bottomright",paste("Last AVG=",format(tail(m,1),digits=4)))
  28.  
  29. delta_positive <- rep(NA,dataN)
  30. delta_positive[which(delta>0)] <- delta[which(delta>0)]
  31. delta_negative <- rep(NA,dataN)
  32. delta_negative[which(delta<0)] <- delta[which(delta<0)]
  33.  
  34. plot(delta_positive,type="h",col="Blue",
  35.      main="average change",ylab="change",ylim=range(delta,na.rm=TRUE))
  36. lines(delta_negative,type="h",col="Red")
  37.  
  38. par(mfrow=c(1,1))
RAW Paste Data