Advertisement
Guest User

mathstat1

a guest
Sep 9th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.09 KB | None | 0 0
  1. setwd("/Users/mariiaturchina/mathstat_data")
  2. AEX <- read.csv(file="AEX.csv", header=TRUE)
  3. AEX$Date <- as.POSIXct(AEX$Date,format="%Y-%m-%d")
  4. > AEX$Year <- as.numeric(format(AEX$Date,"%Y"))
  5. > AEX <- AEX[order(AEX$Date),]
  6.  
  7.  
  8. #plot the the opening and closing values
  9. plot(AEX$Date,AEX$Open, col = "red",type="p",lwd=0.005,xlab = "",ylab="AEX",
  10.      main="AEX values",xaxt="n",las=1)
  11. # we do not use xlab="year" since dates are too wide and then too close to the label
  12. mtext("year", side=1,line=3.5)
  13. points(AEX$Date,AEX$Close,col="blue",type="p",lwd=0.005)
  14. axis.POSIXct(1,at = seq(min(AEX$Date),max(AEX$Date),by = "6 months"),format="%b-%Y",las=2,cex.axis=0.7)
  15. legend("topright",legend=c("opening","closing"),lty=1,lwd=2,col=c("red","blue"))
  16.  
  17. # use head to show first 6 items in order to check that selection of
  18. # year 2008 works
  19. head(AEX[AEX$Year==2008,])
  20.  
  21. #acf has option lag.max which is NOT "null" by default
  22. max(acf(AEX$Close,plot=F)$lag)
  23. max(acf(AEX$Close,lag.max=40,plot=F)$lag)
  24.  
  25. AEX$Rate <- as.numeric((AEX$Close - AEX$Open)/AEX$Open)
  26. plot(AEX$Date, AEX$Rate, col = "red", type = "p")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement