Re: [R] Exponential Smoothing: Forecast package
Hi Phani, something like this looks promising: # library(forecast) library(Mcomp) MAPE.for.Holt <- function (x,series,bignum=10e6) { foo <- try(ets(series$x,model="AAN",damped=FALSE,alpha=x[1],beta=x[2],restrict=FALSE),silent=TRUE) if ( class(foo) == "try-error" ) { bignum } else { mean(abs(fitted(foo)-series$x)/series$x,na.rm=TRUE) } } bar <- optim(par=c(.1,.1),fn=MAPE.for.Holt,series=M3[[1]]) # At least it converges. However, I have had problems with parameters leaving the allowed space (that's what the try() and the bignum is for), and even with convergence, some unrealistically big smoothing constants resulted, which in turn were not very stable for varying starting parameters... HTH, Stephan phani kishan schrieb: Hey, Thanks for the tip Stephan. But you could tell me how to pass the series to the function calling ets? Initially I planned to do it this way: wrapper<-function(x) { alpha<-x[1] beta<-x[2] ph<-x[3] series<-x[4] foofit<-ets(series,model="AZZ",alpha=alpha,beta=beta,phi=phi,additive.only=T,opt.crit=c("mse")) accuracy(foofit)[5] ##for MAPE } I then planned to use the optim using optim(c(alpha,beta,phi,series),wrapper) What I hoped to do is also select MAPE as a criteria for selection of my alpha and beta. However I shouldn't pass my series in this form right? As it would be "optimized" too in the process? Could you suggest a way around this. And I did find a way around could this allow me to set MAPE as a criteria? Phani On Tue, Jun 29, 2010 at 12:47 AM, Stephan Kolassa wrote: Hi Phani, to get the best Holt's model, I would simply wrap a suitable function calling ets() within optim() and optimize for alpha and beta - the values given by ets() without constraints would probably be good starting values, but you had better start the optimization with a variety of starting values to make sure you don't end up in a local minimum. I know of no comparison just between Holt and Brown - but you could use the above methods and the M3 Competition dataset (in Mcomp) to look how the two methods compare on a (more or less) benchmark dataset. HTH Stephan phani kishan schrieb: Hey, I am using the ets() function in the forecast package to find out the best fit parameters for my time-series. I have about 50 sets of time series data. I'm currently using the function as follows: ets(x,model="AZZ",opt.crit="mse") As to my observation about 5-10 of them have been identified by ets to have a trend and an alpha, beta values have been thrown up - which have been same in all these cases. When I read up online it came up as a Brown's double exponential smoothing as opposed to Holt's exponential smoothing (where alpha and beta differ). I am guessing this is happening as AIC/AICc/BIC select a model based on accuracy as well as a weight on number of parameters (1 in case of brown's, 2 in case of holt's). Now if I want to see results of the best parameters from the Holt's method, how should I go about it? And is there any study comparing the accuracy of brown's double exponential model versus holt's exponential model? Thanks in advance, Phani __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponential Smoothing: Forecast package
Hey, Thanks for the tip Stephan. But you could tell me how to pass the series to the function calling ets? Initially I planned to do it this way: wrapper<-function(x) { alpha<-x[1] beta<-x[2] ph<-x[3] series<-x[4] foofit<-ets(series,model="AZZ",alpha=alpha,beta=beta,phi=phi,additive.only=T,opt.crit=c("mse")) accuracy(foofit)[5] ##for MAPE } I then planned to use the optim using optim(c(alpha,beta,phi,series),wrapper) What I hoped to do is also select MAPE as a criteria for selection of my alpha and beta. However I shouldn't pass my series in this form right? As it would be "optimized" too in the process? Could you suggest a way around this. And I did find a way around could this allow me to set MAPE as a criteria? Phani On Tue, Jun 29, 2010 at 12:47 AM, Stephan Kolassa wrote: > Hi Phani, > > to get the best Holt's model, I would simply wrap a suitable function > calling ets() within optim() and optimize for alpha and beta - the values > given by ets() without constraints would probably be good starting values, > but you had better start the optimization with a variety of starting values > to make sure you don't end up in a local minimum. > > I know of no comparison just between Holt and Brown - but you could use the > above methods and the M3 Competition dataset (in Mcomp) to look how the two > methods compare on a (more or less) benchmark dataset. > > HTH > Stephan > > > phani kishan schrieb: > > Hey, >> I am using the ets() function in the forecast package to find out the best >> fit parameters for my time-series. I have about 50 sets of time series >> data. >> >> I'm currently using the function as follows: >> >> ets(x,model="AZZ",opt.crit="mse") >> >> >> As to my observation about 5-10 of them have been identified by ets to >> have >> a trend and an alpha, beta values have been thrown up - which have been >> same >> in all these cases. When I read up online it came up as a Brown's double >> exponential smoothing as opposed to Holt's exponential smoothing (where >> alpha and beta differ). I am guessing this is happening as AIC/AICc/BIC >> select a model based on accuracy as well as a weight on number of >> parameters >> (1 in case of brown's, 2 in case of holt's). Now if I want to see results >> of >> the best parameters from the Holt's method, how should I go about it? >> >> And is there any study comparing the accuracy of brown's double >> exponential >> model versus holt's exponential model? >> >> Thanks in advance, >> Phani >> >> > -- A. Phani Kishan 3rd Year B.Tech Dept. of Computer Science & Engineering IIT MADRAS Ph: +919962363545 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponential Smoothing: Forecast package
Hi Phani, to get the best Holt's model, I would simply wrap a suitable function calling ets() within optim() and optimize for alpha and beta - the values given by ets() without constraints would probably be good starting values, but you had better start the optimization with a variety of starting values to make sure you don't end up in a local minimum. I know of no comparison just between Holt and Brown - but you could use the above methods and the M3 Competition dataset (in Mcomp) to look how the two methods compare on a (more or less) benchmark dataset. HTH Stephan phani kishan schrieb: Hey, I am using the ets() function in the forecast package to find out the best fit parameters for my time-series. I have about 50 sets of time series data. I'm currently using the function as follows: ets(x,model="AZZ",opt.crit="mse") As to my observation about 5-10 of them have been identified by ets to have a trend and an alpha, beta values have been thrown up - which have been same in all these cases. When I read up online it came up as a Brown's double exponential smoothing as opposed to Holt's exponential smoothing (where alpha and beta differ). I am guessing this is happening as AIC/AICc/BIC select a model based on accuracy as well as a weight on number of parameters (1 in case of brown's, 2 in case of holt's). Now if I want to see results of the best parameters from the Holt's method, how should I go about it? And is there any study comparing the accuracy of brown's double exponential model versus holt's exponential model? Thanks in advance, Phani __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Exponential Smoothing: Forecast package
Hey, I am using the ets() function in the forecast package to find out the best fit parameters for my time-series. I have about 50 sets of time series data. I'm currently using the function as follows: ets(x,model="AZZ",opt.crit="mse") As to my observation about 5-10 of them have been identified by ets to have a trend and an alpha, beta values have been thrown up - which have been same in all these cases. When I read up online it came up as a Brown's double exponential smoothing as opposed to Holt's exponential smoothing (where alpha and beta differ). I am guessing this is happening as AIC/AICc/BIC select a model based on accuracy as well as a weight on number of parameters (1 in case of brown's, 2 in case of holt's). Now if I want to see results of the best parameters from the Holt's method, how should I go about it? And is there any study comparing the accuracy of brown's double exponential model versus holt's exponential model? Thanks in advance, Phani -- A. Phani Kishan 3rd Year B.Tech Dept. of Computer Science & Engineering IIT MADRAS Ph: +919962363545 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.