Re: [R] time series has no or less than 2 periods

2014-01-06 Thread Rajaraman V


blockLength - 37 # can be anything you like
ts1 - ts(rnorm(2*blockLength-1, 0,2), frequency=blockLength)
de - decompose(ts1)  # error

ts2 - ts(rnorm(2*blockLength, 0,2), frequency=blockLength)
de - decompose(ts2)
plot(de)

So the trick is to have at least two periods in your time series. Even 
reduce one data point, and you will see this error.
__
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] time series has no or less than 2 periods

2014-01-06 Thread Rajaraman V
For decomposing a time series into seasonal components, you need at least 2 
seasons worth of data. If you have even one data point less, you will see 
this error message.

blockLength  -  52
ts1 - ts(rnorm(2*blockLength-1), frequency=blockLength)
decompose(ts1)  # error

ts2 - ts(rnorm(2*blockLength), frequency=blockLength)
decompose(ts2)  # OK
__
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] time series has no or less than 2 periods

2013-10-04 Thread Daniel Hickman
Bill,

Thanks for replying.


The data is weekly time series data.  Assume there is 52 weeks in the year.  Of 
the 52 weeks, I typically only have data for weeks 8 through 40.


4-Apr-10, 8, 27.2
11-Apr-10, 9, 32.3
18-Apr-10, 10, 31.7

DataXYZ, 40, 13.4


data - 
c(0,24.57,29.93,24.19,12.25,48.07,36.68,24.78,48.69,30.39,48.17,36.51,36.43,36.52,48.75,24.17,37.07,0,18.89)
ts - ts(data= data, start = 8, end = 40, frequency = )


There is a weekly seasonality effect.  What should I set my frequency value to?


Thanks,

Dan Hickman 






From: William Dunlap
Sent: ‎Thursday‎, ‎October‎ ‎3‎, ‎2013 ‎3‎:‎57‎ ‎PM
To: David Winsemius, Daniel Hickman
Cc: r-help@r-project.org


  ts - ts(data$QtyPerWeek, frequency=52)
  HoltWinters(ts,0.46924,0.05,0.2)
 
  This results in the following error. Error in decompose(ts(x[1L:wind], 
  start = start(x),
 frequency = f), seasonal) : time series has no or less than 2 periods

Since you have set the frequency of the time series to 52, you need
to have 104 observations to get the initial estimate of the seasonal
pattern.  How many observations are in 'ts'?  If you don't have enough
you can omit the seaonal component (HoltWinters(gamma=FALSE,...)),
change start.periods from the default 2 to 1, or supply a 52-long vector
of the initial seasonal pattern as the s.start argument.

If you do have more than 104 observations then you will have to tell
us more about the data.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of David Winsemius
 Sent: Thursday, October 03, 2013 12:39 PM
 To: Daniel Hickman
 Cc: r-help@r-project.org
 Subject: Re: [R] time series has no or less than 2 periods
 
 
 On Oct 3, 2013, at 8:32 AM, Daniel Hickman wrote:
 
  Hello,
 
 
 
  I have been tasked with taking an excel file that my colleague had 
  implemented Triple
 Exponential Smoothing and recreate using R.
 
  The following image shows the before and after of smoothing out a fixed 
  interval time
 series data using Triple Exponential Smoothing inside of Excel.
 
  enter image description here
 
 The image file formats that I know are acceptable are .ps, .pdf or .png. Not 
 sure about
 jpeg.
 
 
  I am trying to perform the same triple exponential smoothing in R.  I 
  created a csv file
 with the before smoothing data.  The csv file is attached and can also be 
 found here.
 
 Need to send with .txt extension.
 
 
  I found the HoltWinters method but I keep getting an error when I try to 
  apply
 HoltWinters against the csv.
  setwd(C:/temp)
  data - read.table(TripleExpSmoothingXLS.csv, header=TRUE, sep=,)
  ts - ts(data$QtyPerWeek, frequency=52)
  HoltWinters(ts,0.46924,0.05,0.2)
 
  This results in the following error. Error in decompose(ts(x[1L:wind], 
  start = start(x),
 frequency = f), seasonal) : time series has no or less than 2 periods
 
 Perhaps a data entry problem. We would need to see either the file or output 
 of
 str(data).
 
  In case it helps,  excel file with the triple exponential smoothing 
  formulas and original
 data can be found here.
 
 Again there is no here here.
 
 
  Any advice?
 
  Thanks, Dan__
  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.
 
 David Winsemius
 Alameda, CA, USA
 
 __
 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]]

__
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] time series has no or less than 2 periods

2013-10-04 Thread Clint Bowman

Perhaps looking at your data will suggest an appropriate number, viz.

plot(data,type=b,xlim=c(0,20),ylim=c(0,50))
par(new=T)
ind-1:19  # in this case where the data length is 19
data.ind-data.frame(ind,data)
data.lo-loess(data~ind,data.ind)
data.pre-predict(data.lo,data.frame(ind = seq(1,19,1))) 
plot(data.pre,pch=3,col=2,xlim=c(0,20),ylim=c(0,50))


If you now plot the difference between the data and the loess prediction,

data.ind-cbind(data.ind,data.pre)
data.diff-with(data.ind,data-data.pre)
data.ind-cbind(data.ind,data.diff)
with(data.ind,plot(ind,data.diff,type=b))
abline(h=0)

there is also a pretty strong two week signal--is that of any interest?

Now you should be able to decide how to proceed.

Clint

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 4 Oct 2013, Daniel Hickman wrote:


Bill,

Thanks for replying.


The data is weekly time series data.  Assume there is 52 weeks in the year.  Of 
the 52 weeks, I typically only have data for weeks 8 through 40.


4-Apr-10, 8, 27.2
11-Apr-10, 9, 32.3
18-Apr-10, 10, 31.7

DataXYZ, 40, 13.4


data - 
c(0,24.57,29.93,24.19,12.25,48.07,36.68,24.78,48.69,30.39,48.17,36.51,36.43,36.52,48.75,24.17,37.07,0,18.89)
ts - ts(data= data, start = 8, end = 40, frequency = )


There is a weekly seasonality effect.  What should I set my frequency value to?


Thanks,

Dan Hickman






From: William Dunlap
Sent: ???Thursday???, ???October??? ???3???, ???2013 ???3???:???57??? ???PM
To: David Winsemius, Daniel Hickman
Cc: r-help@r-project.org



ts - ts(data$QtyPerWeek, frequency=52)
HoltWinters(ts,0.46924,0.05,0.2)

This results in the following error. Error in decompose(ts(x[1L:wind], start = 
start(x),

frequency = f), seasonal) : time series has no or less than 2 periods


Since you have set the frequency of the time series to 52, you need
to have 104 observations to get the initial estimate of the seasonal
pattern.  How many observations are in 'ts'?  If you don't have enough
you can omit the seaonal component (HoltWinters(gamma=FALSE,...)),
change start.periods from the default 2 to 1, or supply a 52-long vector
of the initial seasonal pattern as the s.start argument.

If you do have more than 104 observations then you will have to tell
us more about the data.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf
Of David Winsemius
Sent: Thursday, October 03, 2013 12:39 PM
To: Daniel Hickman
Cc: r-help@r-project.org
Subject: Re: [R] time series has no or less than 2 periods


On Oct 3, 2013, at 8:32 AM, Daniel Hickman wrote:


Hello,



I have been tasked with taking an excel file that my colleague had implemented 
Triple

Exponential Smoothing and recreate using R.


The following image shows the before and after of smoothing out a fixed 
interval time

series data using Triple Exponential Smoothing inside of Excel.


enter image description here


The image file formats that I know are acceptable are .ps, .pdf or .png. Not 
sure about
jpeg.



I am trying to perform the same triple exponential smoothing in R.  I created a 
csv file

with the before smoothing data.  The csv file is attached and can also be found 
here.

Need to send with .txt extension.



I found the HoltWinters method but I keep getting an error when I try to apply

HoltWinters against the csv.

setwd(C:/temp)
data - read.table(TripleExpSmoothingXLS.csv, header=TRUE, sep=,)
ts - ts(data$QtyPerWeek, frequency=52)
HoltWinters(ts,0.46924,0.05,0.2)

This results in the following error. Error in decompose(ts(x[1L:wind], start = 
start(x),

frequency = f), seasonal) : time series has no or less than 2 periods

Perhaps a data entry problem. We would need to see either the file or output of
str(data).


In case it helps,  excel file with the triple exponential smoothing formulas 
and original

data can be found here.

Again there is no here here.



Any advice?

Thanks, Dan__
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.


David Winsemius
Alameda, CA, USA

__
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

Re: [R] time series has no or less than 2 periods

2013-10-03 Thread David Winsemius

On Oct 3, 2013, at 8:32 AM, Daniel Hickman wrote:

 Hello,
 
 
 
 I have been tasked with taking an excel file that my colleague had 
 implemented Triple Exponential Smoothing and recreate using R. 
 
 The following image shows the before and after of smoothing out a fixed 
 interval time series data using Triple Exponential Smoothing inside of Excel.
 
 enter image description here

The image file formats that I know are acceptable are .ps, .pdf or .png. Not 
sure about jpeg.

 
 I am trying to perform the same triple exponential smoothing in R.  I created 
 a csv file with the before smoothing data.  The csv file is attached and can 
 also be found here.

Need to send with .txt extension.

 
 I found the HoltWinters method but I keep getting an error when I try to 
 apply HoltWinters against the csv.
 setwd(C:/temp)
 data - read.table(TripleExpSmoothingXLS.csv, header=TRUE, sep=,)
 ts - ts(data$QtyPerWeek, frequency=52)
 HoltWinters(ts,0.46924,0.05,0.2)
 
 This results in the following error. Error in decompose(ts(x[1L:wind], start 
 = start(x), frequency = f), seasonal) : time series has no or less than 2 
 periods

Perhaps a data entry problem. We would need to see either the file or output of 
str(data).
 
 In case it helps,  excel file with the triple exponential smoothing formulas 
 and original data can be found here.

Again there is no here here.

 
 Any advice? 
 
 Thanks, Dan__
 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.

David Winsemius
Alameda, CA, USA

__
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] time series has no or less than 2 periods

2013-10-03 Thread William Dunlap
  ts - ts(data$QtyPerWeek, frequency=52)
  HoltWinters(ts,0.46924,0.05,0.2)
 
  This results in the following error. Error in decompose(ts(x[1L:wind], 
  start = start(x),
 frequency = f), seasonal) : time series has no or less than 2 periods

Since you have set the frequency of the time series to 52, you need
to have 104 observations to get the initial estimate of the seasonal
pattern.  How many observations are in 'ts'?  If you don't have enough
you can omit the seaonal component (HoltWinters(gamma=FALSE,...)),
change start.periods from the default 2 to 1, or supply a 52-long vector
of the initial seasonal pattern as the s.start argument.

If you do have more than 104 observations then you will have to tell
us more about the data.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of David Winsemius
 Sent: Thursday, October 03, 2013 12:39 PM
 To: Daniel Hickman
 Cc: r-help@r-project.org
 Subject: Re: [R] time series has no or less than 2 periods
 
 
 On Oct 3, 2013, at 8:32 AM, Daniel Hickman wrote:
 
  Hello,
 
 
 
  I have been tasked with taking an excel file that my colleague had 
  implemented Triple
 Exponential Smoothing and recreate using R.
 
  The following image shows the before and after of smoothing out a fixed 
  interval time
 series data using Triple Exponential Smoothing inside of Excel.
 
  enter image description here
 
 The image file formats that I know are acceptable are .ps, .pdf or .png. Not 
 sure about
 jpeg.
 
 
  I am trying to perform the same triple exponential smoothing in R.  I 
  created a csv file
 with the before smoothing data.  The csv file is attached and can also be 
 found here.
 
 Need to send with .txt extension.
 
 
  I found the HoltWinters method but I keep getting an error when I try to 
  apply
 HoltWinters against the csv.
  setwd(C:/temp)
  data - read.table(TripleExpSmoothingXLS.csv, header=TRUE, sep=,)
  ts - ts(data$QtyPerWeek, frequency=52)
  HoltWinters(ts,0.46924,0.05,0.2)
 
  This results in the following error. Error in decompose(ts(x[1L:wind], 
  start = start(x),
 frequency = f), seasonal) : time series has no or less than 2 periods
 
 Perhaps a data entry problem. We would need to see either the file or output 
 of
 str(data).
 
  In case it helps,  excel file with the triple exponential smoothing 
  formulas and original
 data can be found here.
 
 Again there is no here here.
 
 
  Any advice?
 
  Thanks, Dan__
  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.
 
 David Winsemius
 Alameda, CA, USA
 
 __
 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-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.