From: Stephan Kolassa <Stephan.Kolassa_at_gmx.de>

Date: Tue, 29 Jun 2010 11:44:04 +0200

*>
*

>

R-help_at_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. Received on Tue 29 Jun 2010 - 18:27:50 GMT

Date: Tue, 29 Jun 2010 11:44:04 +0200

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 <Stephan.Kolassa_at_gmx.de>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_at_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. Received on Tue 29 Jun 2010 - 18:27:50 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 29 Jun 2010 - 18:30:43 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*