CALEF ALEJANDRO RODRIGUEZ CUEVAS
2010-Oct-12 04:39 UTC
[R] Help with STL function to decompose
Hi everyone. I'm having some troubles with STL function to decompose some data. My issue is that I have monthly data from September 2005 up to August 2010 i. e. 60 observations. I define it in the following way: *u<-read.csv("C:/CELEBREX.csv",header = TRUE) u.ts<-ts(u, start=c(2005,9), frequency=12) * The issue is that when I try to use stl(u.ts, 'per') Then the following error message is displayed: *Error en stl(u.ts, "per") : only univariate series are allowed * I know that stl needs a univariate time series in order to run, but I've already defined it in *u.ts. *Moreover, if I use the same *u.ts* with functions which also requires univariate time series, i. e. *auto.arima(u.ts, d=1, D=1)* Series: u.ts ARIMA(0,1,0)(0,1,1)[12] Call: auto.arima(x = u.ts, d = 1, D = 1) Coefficients: sma1 -0.5300 s.e. 0.2553 sigma^2 estimated as 22788111: log likelihood = -466.79 AIC = 937.57 AICc = 937.85 BIC = 941.27 or in *StructTS(u.ts) *Call: StructTS(x = u.ts) Variances: level slope seas epsilon 0 0 142829 12358227 or in *decompose(u.ts)* then I don't have any problem with *u.ts *defined as univariate time serie. What is it happening with STL?, What am I doing wrong? Thanks in advance. [[alternative HTML version deleted]]
Hi: Try str(u.ts) class(u.ts) That should give you more information about the type of object being input to stl. I tried the following, which worked on my system: u <- rnorm(100) u.ts <- ts(u, start = c(2001, 1), frequency = 12) u.stl <- stl(u.ts, 'per') plot(u.stl)> sessionInfo()R version 2.11.1 (2010-05-31) x86_64-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets grid [8] methods base other attached packages: [1] rgl_0.92 Hmisc_3.8-3 survival_2.35-8 sos_1.3-0 [5] brew_1.0-4 lattice_0.19-11 ggplot2_0.8.8 proto_0.3-8 [9] reshape_0.8.3 plyr_1.2.1 loaded via a namespace (and not attached): [1] cluster_1.13.1 tools_2.11.1 Since stl() is part of the base distribution, my attached packages should have no relevance in whether stl() works or not. The help page says that the input must be a univariate ts object with frequency greater than 1. My guess is that you have input a multiple time series object, which is why it is worth looking at str() and class(). HTH, Dennis On Mon, Oct 11, 2010 at 9:39 PM, CALEF ALEJANDRO RODRIGUEZ CUEVAS < alejandro.rodriguez.cuevas@gmail.com> wrote:> Hi everyone. > > I'm having some troubles with STL function to decompose some data. > > My issue is that I have monthly data from September 2005 up to August 2010 > i. e. 60 observations. > > I define it in the following way: > > *u<-read.csv("C:/CELEBREX.csv",header = TRUE) > u.ts<-ts(u, start=c(2005,9), frequency=12) > * > The issue is that when I try to use > > stl(u.ts, 'per') > > Then the following error message is displayed: > > *Error en stl(u.ts, "per") : only univariate series are allowed > * > > I know that stl needs a univariate time series in order to run, but I've > already defined it in *u.ts. > > *Moreover, if I use the same *u.ts* with functions which also requires > univariate time series, i. e. > > *auto.arima(u.ts, d=1, D=1)* > > Series: u.ts > ARIMA(0,1,0)(0,1,1)[12] > > Call: auto.arima(x = u.ts, d = 1, D = 1) > > Coefficients: sma1 > -0.5300 > s.e. 0.2553 > > sigma^2 estimated as 22788111: log likelihood = -466.79 > AIC = 937.57 AICc = 937.85 BIC = 941.27 > > or in > > *StructTS(u.ts) > > *Call: > StructTS(x = u.ts) > > Variances: > level slope seas epsilon > 0 0 142829 12358227 > > > or in > > *decompose(u.ts)* > > then I don't have any problem with *u.ts *defined as univariate time serie. > > What is it happening with STL?, What am I doing wrong? > > Thanks in advance. > > [[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. >[[alternative HTML version deleted]]