Hello everyone!
I´ve started using R last week and I´m having really persistent problems
trying to make predictions using the HoltWinters function.
I´m sending my script and the errors I´m getting.
My data is:
Jan Feb Mar Apr May Jun Jul Ago Sep Oct Nov Dec
2004 118 143 169 158 143 135 135 140 135 125.0000 120.0000 120.0000
2005 143 158 180 180 150 150 153 148 150 145.0000 145.0000 143.0000
2006 165 180 190 168 163 163 168 175 180 160.0000 155.0000 150.0000
2007 152 163 185 163 158 175 175 178 168 168.0000 160.0000 160.0000
2008 155 170 195 195 195 185 185 165 165 153.3333 153.3333 153.3333
The data I´m receiving using AP.ts <-
ts(AP,start=2004,end=2008,frequency=2) is:
Jan Feb Mar Apr May Jun Jul Ago Sep Oct Nov Dec
2004.0 118 143 169 158 143 135 135 140 135 125.0000 120.0000 120.0000
2004.5 143 158 180 180 150 150 153 148 150 145.0000 145.0000 143.0000
2005.0 165 180 190 168 163 163 168 175 180 160.0000 155.0000 150.0000
2005.5 152 163 185 163 158 175 175 178 168 168.0000 160.0000 160.0000
2006.0 155 170 195 195 195 185 185 165 165 153.3333 153.3333 153.3333
2006.5 118 143 169 158 143 135 135 140 135 125.0000 120.0000 120.0000
2007.0 143 158 180 180 150 150 153 148 150 145.0000 145.0000 143.0000
2007.5 165 180 190 168 163 163 168 175 180 160.0000 155.0000 150.0000
2008.0 152 163 185 163 158 175 175 178 168 168.0000 160.0000 160.0000
However that´s not what I want. Using fr=1 I get my data fine but can´t
plot due to the error:
plot(AP.ts)
Error in plotts(x = x, y = y, plot.type = plot.type, xy.labels xy.labels, :
cannot plot more than 10 series as "multiple"
AND
> AP.hw <- HoltWinters(AP.ts,seasonal="mult")
Error in decompose(ts(x[1L:wind], start = start(x), frequency = f),
seasonal) :
time series has no or less than 2 periods> plot(AP.hw)
Error in xy.coords(x, y) : 'x' and 'y' lengths differ
FILE="AWB1.csv"
#FILE2="AWB2.csv"
AP <- read.csv(FILE,header=T)
AP
is(AP)
AP.ts <- ts(AP,start=2004,end=2008,frequency=2)
#AP.ts
<-ts(structure(c(read.csv(FILE),start=c(2004,1),end=c(2008,1),frequency=12)))
is(AP.ts)
AP.ts
dput(AP.ts)
plot(AP.ts)
library(zoo)
plot(zoo(AP.ts), ylim = c(0, 20))
AP.ts #is(AP.ts) #start(AP.ts);frequency(AP.ts);end(AP.ts)
dput(AP.ts)
AP.hw <- HoltWinters(AP.ts,seasonal="mult")
plot(AP.hw)
AP.predict <- predict(AP.hw,n.ahead=10)
AP.predict
ts.plot(AP.ts,AP.predict, lty=1:4)
### TESTE
data(AirPassengers)
aa <- AirPassengers
aa
is(aa)
start(aa);frequency(aa);end(aa)
Thank you guys!!!!!
--
Vinicius Macedo Magalhães
(21) 9584-1533
[[alternative HTML version deleted]]