Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setwd("/Users/mariiaturchina/mathstat_data")
- AEX <- read.csv(file="AEX.csv", header=TRUE)
- AEX$Date <- as.POSIXct(AEX$Date,format="%Y-%m-%d")
- > AEX$Year <- as.numeric(format(AEX$Date,"%Y"))
- > AEX <- AEX[order(AEX$Date),]
- #plot the the opening and closing values
- plot(AEX$Date,AEX$Open, col = "red",type="p",lwd=0.005,xlab = "",ylab="AEX",
- main="AEX values",xaxt="n",las=1)
- # we do not use xlab="year" since dates are too wide and then too close to the label
- mtext("year", side=1,line=3.5)
- points(AEX$Date,AEX$Close,col="blue",type="p",lwd=0.005)
- axis.POSIXct(1,at = seq(min(AEX$Date),max(AEX$Date),by = "6 months"),format="%b-%Y",las=2,cex.axis=0.7)
- legend("topright",legend=c("opening","closing"),lty=1,lwd=2,col=c("red","blue"))
- # use head to show first 6 items in order to check that selection of
- # year 2008 works
- head(AEX[AEX$Year==2008,])
- #acf has option lag.max which is NOT "null" by default
- max(acf(AEX$Close,plot=F)$lag)
- max(acf(AEX$Close,lag.max=40,plot=F)$lag)
- AEX$Rate <- as.numeric((AEX$Close - AEX$Open)/AEX$Open)
- plot(AEX$Date, AEX$Rate, col = "red", type = "p")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement