Hi Dennis,

I’ve already found that matrix, but I want to predict the time series, for
example with predict.loess() on every component. But actually I’m unable to
extract the plotted series’ (trend and seasonal) as a loess object. This
representation is what I’m looking for. 

At the moment I don’t see any other possibility to predict the particular
components as with the loess prediction. 

 

Do you have an idea to extract this representation and not just the data?

 

Thanks in advance.

Konrad

  _____  

Von: Dennis Murphy [mailto:djmuser@gmail.com] 
Gesendet: Sonntag, 7. Februar 2010 17:08
An: Konrad Hoppe
Betreff: Re: [R] predicting with stl() decomposition

 

Hi:

> str(decomp)
List of 8
 $ time.series: mts [1:300, 1:3] 0.0928 0.2906 -0.0852 -0.1877 0.0347 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:3] "seasonal" "trend" "remainder"
  ..- attr(*, "tsp")= num [1:3] 1980 2005 12
  ..- attr(*, "class")= chr [1:2] "mts" "ts"
 $ weights    : num [1:300] 1 1 1 1 1 1 1 1 1 1 ...
 $ call       : language stl(x = seriesTs, s.window = "periodic")
 $ win        : Named num [1:3] 3001 19 13
  ..- attr(*, "names")= chr [1:3] "s" "t" "l"
 $ deg        : Named int [1:3] 0 1 1
  ..- attr(*, "names")= chr [1:3] "s" "t" "l"
 $ jump       : Named num [1:3] 301 2 2
  ..- attr(*, "names")= chr [1:3] "s" "t" "l"
 $ inner      : int 2
 $ outer      : int 0
 - attr(*, "class")= chr "stl"

This tells you decomp$time.series is a matrix with respective columns
'seasonal', 'trend' and 'remainder', respectively. You can extract that and
go from there.

HTH,
Dennis

On Sun, Feb 7, 2010 at 7:55 AM, Konrad Hoppe <konradhoppe@hotmail.de> wrote:

Hi,

yes that error name is indeed kind of weird. But I think it’s thrown due to
the missing robustness of the estimation since every weight is one and hence
the fit is likely to be influenced by outliers in the provided data which
should be just an example.

 

But do you have an idea to extract the single components of the fit? I guess
there must be a possibility to predict those stl models.

 

Cheers,

Konrad

  _____  

Von: Dennis Murphy [mailto:djmuser@gmail.com] 
Gesendet: Sonntag, 7. Februar 2010 16:30
An: Konrad Hoppe
Betreff: Re: [R] predicting with stl() decomposition

 

Hi:

When I ran your code, I got the following message in the first loess call:

> llrSaison <- loess(seriesTs~time , span=decomp$win[1] ,
+ degree=decomp$deg[1])
Warning messages:
1: Chernobyl! trL<k 1 
2: Chernobyl! trL<k 1 

Somebody has a sense of humor in their code writing, but I'm pretty
sure the message  trL < k 1  has some meaning, probably telling you
the fit is unstable. I looked through the loess function code but couldn't
find anything in it that would be immediately helpful. It calls a
function simpleLoess(), but that function is evidently non-visible. You 
probably need expert guidance here.

Dennis

On Sun, Feb 7, 2010 at 5:48 AM, Konrad Hoppe <konradhoppe@hotmail.de> wrote:

Hi mailinglist members,



I’m actually working on a time series prediction and my current approach is
to decompose the series first into a trend, a seasonal component and a
remainder. Therefore I’m using the stl() function. But I’m wondering how to
get the single components in order to predict the particular fitted series’.

This code snippet illustrates my problem:



series <- vector(length=300)

noise <- rnorm(300,0,2)

time <- 1:300

series[1] <- noise[1]



for(i in 3:300){

           series[i] <- 0.5*series[i-1]+ noise[i] + 0.01*time[i]

}

seriesTs <- ts(series, start=c(1980,1), frequency=12)



decomp <- stl(seriesTs ,"periodic")

plot(decomp)

llrSaison <- loess(seriesTs~time , span=decomp$win[1] ,
degree=decomp$deg[1])

llrTrend  <- loess(seriesTs~time,  span=decomp$win[2] ,
degree=decomp$deg[2])



plot(llrSaison$fitted)



The last plot differs much from the seasonal plot in the plot(decomp) call.
This is why the llr estimator doesn’t extract the seasonal component, but
how can I predict the single components at last? Or is there a function
which can predict the values of the stl-object. Predict() doesn’t work, I’ve
already tried it.



All the best,

Konrad Hoppe


       [[alternative HTML version deleted]]


______________________________________________
R-help@r-project.org mailing list

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






	[[alternative HTML version deleted]]

