-
Notifications
You must be signed in to change notification settings - Fork 0
/
30mar16
25 lines (24 loc) · 825 Bytes
/
30mar16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
base <- read.csv("amx.csv",header = T)
#sereie de tiempo
ts.amx <- ts(base$Close,frequency = 252,start = 2000)
#modelo aditivo
amx.adi <- decompose(ts.amx)
tende.adi <- amx.adi$trend
esta.adi <- amx.adi$seasonal
alet.adi <- amx.adi$random
plot(amx.adi)
#modelo muliplicativo
amx.mul <- decompose(ts.amx)
tende.mul <- amx.mul$trend
esta.mul <- amx.mul$seasonal
alet.mul <- amx.mul$random
plot(amx.mul)
### graficas
ts.plot(cbind(tende.mul,tende.mul*esta.mul),lty=5:2,col=c("orange","blue"))
### exportar a excel
tabla <-data.frame(tende.adi,esta.adi,alet.adi)
tabla2 <- data.frame(tende.mul,esta.mul,alet.mul)
install.packages("XLConnect") # paquete para leer y guardar dataframes en excel
library(XLConnect)
writeWorksheetToFile("series.xls", data = list(tabla, tabla2),
sheet = c("aditivo", "multi"))