Re: [R] time series transformation....

2023-08-14 Thread akshay kulkarni
Dear ERic,
 THanks a lot!

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Eric Berger 
Sent: Monday, August 14, 2023 11:04 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] time series transformation

Hi Akshay,
If you do
> help(package="forecast")

you will find that arfima is listed. Unfortunately, I don't see any
ARCH-type models there, but you should check out the help page
results.

Good luck,
Eric

On Mon, Aug 14, 2023 at 8:04 PM akshay kulkarni  wrote:
>
> Dear Eric,
>  THanks for the reply...will this also work with arfima() ? 
> What if I want to fit a model like GARCH and friends?
>
> THanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
> 
> From: Eric Berger 
> Sent: Sunday, August 13, 2023 10:34 AM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] time series transformation
>
> Hi Akshay,
> The forecast package will do the BoxCox transform and automatically
> backtransform the forecasts.
> The package also handles xts objects.
> For example, modifying the example from the help page of
> forecast::forecast for Arima
>
> > dt <- as.Date("2023-01-01") + 1:length(WWWusage)
> > a <- xts(WWWusage, order.by=dt)
> > fit1 <- Arima(a, c(3,1,0))
> > fit2 <- Arima(a, lambda=0.5, c(3,1,0))  ## applies the Box-Cox transform 
> > with lambda=0.5
> > par(mfrow=c(1,2))
> > plot(forecast(fit1))
> > plot(forecast(fit2))
>
> HTH,
> Eric
>
> p.s. RJH is the author/maintainer of the forecast package
>
>
> On Sun, Aug 13, 2023 at 1:01 AM akshay kulkarni  wrote:
> >
> > dear members,
> >  I have a heteroscedastic time series which I want 
> > to transform to make it homoscedastic by a box cox transformation. I am 
> > using Otexts by RJ hyndman and George Athanopolous as my textbook. They 
> > discuss transformation and also say the fpp3 and the fable package 
> > automatically back transforms the point forecast. they also discuss the 
> > process which I find to be very cumbersome. Is there any R package which 
> > automatically back transforms the point forecast when I use xts objects ( 
> > RJH and GA use tsibble objects) with arfima/arima in the forecast package?
> >
> > THanking you,
> > Yours sincerely,
> > AKSHAY M KULKARNI
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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 -- To UNSUBSCRIBE and more, see
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 transformation....

2023-08-14 Thread Eric Berger
Hi Akshay,
If you do
> help(package="forecast")

you will find that arfima is listed. Unfortunately, I don't see any
ARCH-type models there, but you should check out the help page
results.

Good luck,
Eric

On Mon, Aug 14, 2023 at 8:04 PM akshay kulkarni  wrote:
>
> Dear Eric,
>  THanks for the reply...will this also work with arfima() ? 
> What if I want to fit a model like GARCH and friends?
>
> THanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
> 
> From: Eric Berger 
> Sent: Sunday, August 13, 2023 10:34 AM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] time series transformation
>
> Hi Akshay,
> The forecast package will do the BoxCox transform and automatically
> backtransform the forecasts.
> The package also handles xts objects.
> For example, modifying the example from the help page of
> forecast::forecast for Arima
>
> > dt <- as.Date("2023-01-01") + 1:length(WWWusage)
> > a <- xts(WWWusage, order.by=dt)
> > fit1 <- Arima(a, c(3,1,0))
> > fit2 <- Arima(a, lambda=0.5, c(3,1,0))  ## applies the Box-Cox transform 
> > with lambda=0.5
> > par(mfrow=c(1,2))
> > plot(forecast(fit1))
> > plot(forecast(fit2))
>
> HTH,
> Eric
>
> p.s. RJH is the author/maintainer of the forecast package
>
>
> On Sun, Aug 13, 2023 at 1:01 AM akshay kulkarni  wrote:
> >
> > dear members,
> >  I have a heteroscedastic time series which I want 
> > to transform to make it homoscedastic by a box cox transformation. I am 
> > using Otexts by RJ hyndman and George Athanopolous as my textbook. They 
> > discuss transformation and also say the fpp3 and the fable package 
> > automatically back transforms the point forecast. they also discuss the 
> > process which I find to be very cumbersome. Is there any R package which 
> > automatically back transforms the point forecast when I use xts objects ( 
> > RJH and GA use tsibble objects) with arfima/arima in the forecast package?
> >
> > THanking you,
> > Yours sincerely,
> > AKSHAY M KULKARNI
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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 -- To UNSUBSCRIBE and more, see
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 transformation....

2023-08-14 Thread akshay kulkarni
Dear Eric,
 THanks for the reply...will this also work with arfima() ? 
What if I want to fit a model like GARCH and friends?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Eric Berger 
Sent: Sunday, August 13, 2023 10:34 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] time series transformation

Hi Akshay,
The forecast package will do the BoxCox transform and automatically
backtransform the forecasts.
The package also handles xts objects.
For example, modifying the example from the help page of
forecast::forecast for Arima

> dt <- as.Date("2023-01-01") + 1:length(WWWusage)
> a <- xts(WWWusage, order.by=dt)
> fit1 <- Arima(a, c(3,1,0))
> fit2 <- Arima(a, lambda=0.5, c(3,1,0))  ## applies the Box-Cox transform with 
> lambda=0.5
> par(mfrow=c(1,2))
> plot(forecast(fit1))
> plot(forecast(fit2))

HTH,
Eric

p.s. RJH is the author/maintainer of the forecast package


On Sun, Aug 13, 2023 at 1:01 AM akshay kulkarni  wrote:
>
> dear members,
>  I have a heteroscedastic time series which I want to 
> transform to make it homoscedastic by a box cox transformation. I am using 
> Otexts by RJ hyndman and George Athanopolous as my textbook. They discuss 
> transformation and also say the fpp3 and the fable package automatically back 
> transforms the point forecast. they also discuss the process which I find to 
> be very cumbersome. Is there any R package which automatically back 
> transforms the point forecast when I use xts objects ( RJH and GA use tsibble 
> objects) with arfima/arima in the forecast package?
>
> THanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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 transformation....

2023-08-12 Thread Eric Berger
Hi Akshay,
The forecast package will do the BoxCox transform and automatically
backtransform the forecasts.
The package also handles xts objects.
For example, modifying the example from the help page of
forecast::forecast for Arima

> dt <- as.Date("2023-01-01") + 1:length(WWWusage)
> a <- xts(WWWusage, order.by=dt)
> fit1 <- Arima(a, c(3,1,0))
> fit2 <- Arima(a, lambda=0.5, c(3,1,0))  ## applies the Box-Cox transform with 
> lambda=0.5
> par(mfrow=c(1,2))
> plot(forecast(fit1))
> plot(forecast(fit2))

HTH,
Eric

p.s. RJH is the author/maintainer of the forecast package


On Sun, Aug 13, 2023 at 1:01 AM akshay kulkarni  wrote:
>
> dear members,
>  I have a heteroscedastic time series which I want to 
> transform to make it homoscedastic by a box cox transformation. I am using 
> Otexts by RJ hyndman and George Athanopolous as my textbook. They discuss 
> transformation and also say the fpp3 and the fable package automatically back 
> transforms the point forecast. they also discuss the process which I find to 
> be very cumbersome. Is there any R package which automatically back 
> transforms the point forecast when I use xts objects ( RJH and GA use tsibble 
> objects) with arfima/arima in the forecast package?
>
> THanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] time series transformation....

2023-08-12 Thread akshay kulkarni
dear members,
 I have a heteroscedastic time series which I want to 
transform to make it homoscedastic by a box cox transformation. I am using 
Otexts by RJ hyndman and George Athanopolous as my textbook. They discuss 
transformation and also say the fpp3 and the fable package automatically back 
transforms the point forecast. they also discuss the process which I find to be 
very cumbersome. Is there any R package which automatically back transforms the 
point forecast when I use xts objects ( RJH and GA use tsibble objects) with 
arfima/arima in the forecast package?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time series and correlation

2022-04-26 Thread Marlin Keith Cox
Hi all, I have three columns. Resistance, Time and Frequency, and I need to
find correlations between Resistance and Time by each of 100 Frequencies.
I have set Frequencies to be a factor.  Time is in the format "%m/%d/%Y
%H:%M:%S", but correlations dont seem to like Time data.
I can run this code from Stackoverflow

library(plyr)
g <- data.frame(col1=rnorm(100, 1, 1), col2=rnorm(100, 10, 3),
col3=c(rep("a", 50), rep("b", 50)))

co <- ddply(g, .(col3), function(adf) cor(adf[,1], adf[,2]))

But if one of the columns is Time, it does not work.  So the functionality
of giving correlations by Frequency works, but not when Time is used.

I hope this is clear enough.

keith



M. Keith Cox, Ph.D.
Principal
MKConsulting
17415 Christine Ave.
Juneau, AK 99801
U.S. 907.957.4606

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time Series Latent Variable modeling in lavaan

2019-08-05 Thread Mangalani Makananisa
Dear all,

I have been reading some documentations including Latent variable Modeling
using R and I am confronted with some challenges.  Could you please
direction/guidance me with the following problem?

If I am given continuous time series ‘quarterly data’ with three indicators
(Y1, Y2 and Y3) and 5 causal variables (X1, X2, . . ., X5) and assuming
one latent variable (F1). The observed variables are stationary at first
difference I(1).

How do i specify the model in lavaan() given that this is a time series
 quarterly data with  continuous variables only. I would like to see a
draft model specification in lavaan.

 Looking forward to hearing from you soon and I will give feedback.

Kind regards,

Peter

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Abs Spurdle
This is possibly off topic now...
However, given that it involves mgcv, I think that it's relevant to R.

> to test if there is a change over the years on the amount of debris in
these locations and more specifically a change after the implementation of
a mitigation strategy

> My debris items per effort (Ieffort) are fishing and shipping related
items that can be due to an intentional discharge or an accidental
discharge. It is very common to find a great amount of these items together
in the beach (from where we collected these data (beach clean-ups),
possibly having origin from the same ship. I was thinking that this can be
a problem but still don't know how to overcome or if it makes sense to
include in the model.

I could be wrong on this.
If your goal is simply to determine whether the MARPOL term in significant
or not (or how strong the effect is), I don't think the above issue is
important.
However, you could do a separate spatial analysis, which could be very
interesting...

> This does not apply along the different years.

Are you sure (there's no long term effect)?
Note that you could combine Year and nMonth into one variable, say t.
However, if I understand your variables correctly, this would be correlated
with DaysIa.
So, if you try to fit a model with both Year and DaysIa, then Year is less
likely to be significant, and you probably don't need both.

Note that another approach, is to regard month as a categorical variable.

Also, note that it may be worthwhile testing for interactions, between
MARPOL and Location or Site.
If you want to be fancy, you could test for interactions between MARPOL and
your time variables.

It's possible that there are higher order interactions, however, these sort
of models are difficult for most people to interpret, so are probably a bad
idea.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Abs Spurdle
> > My data has a few problems: (1) I think I will need to fix the effects
of
> > seasonal variation (Monthly) and (2) of possible spatial correlation
> > (probability of finding an item is higher after finding one since they
can
> > come from the same ship). (3) How do I handle the fact that the
> > measurements were not taken at a regular interval?
>
> Can I ask two questions:
> (1) Is the data autocorrelated (or "Seasonal") over time?
> If not then this problem is a lot simpler.
> (2) Can you expand on the following statement?
> "possible spatial correlation (probability of finding an item is higher
after finding one since they can come from the same ship"

I just had a closer look at your example.

You've tried to model nMonth (presumably in {1, 2, ..., 12}) but is there a
long term trend, over Year?
Also, I'm not an expert on mgcv, but I was wondering if you want bs="cp"
rather than bs="ps"?

When you say "measurements were not taken at a regular interval" are you
referring to the variable "DaysIa"?
In which case, my previous question about autocorrelation applies to this
variable.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Abs Spurdle
> My data has a few problems: (1) I think I will need to fix the effects of
> seasonal variation (Monthly) and (2) of possible spatial correlation
> (probability of finding an item is higher after finding one since they can
> come from the same ship). (3) How do I handle the fact that the
> measurements were not taken at a regular interval?

Can I ask two questions:
(1) Is the data autocorrelated (or "Seasonal") over time?
If not then this problem is a lot simpler.
(2) Can you expand on the following statement?
"possible spatial correlation (probability of finding an item is higher
after finding one since they can come from the same ship"

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Bert Gunter
I have 0 expertise, but I suggest that you check out the SPatioTemporal
taskview on CRAN (or possibly others, like environmetrics). You might also
want to move this to the R-Sig-geo list,where you probably are more likely
to find relevant expertise.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Apr 30, 2019 at 8:13 AM Catarina Serra Gonçalves <
catarin...@gmail.com> wrote:

> I have a dataset of marine debris items (number of items standardized per
> effort: Items/(number of volunteers*Hours*Lenght)) taken from 2 main
> locations (WA and Queensland) in Australia (8 Sub Sites in total: 4 in WA
> and 4 in Queensland) at irregular sampling intervals over a period 15
> years.
>
> I want to test if there is a change over the years on the amount of debris
> in these locations and more specifically a change after the implementation
> of a mitigation strategy (in 2013).
> Here’s the head of the data:[image: enter image description here]
> Description of each one of the
> varables in the dataframe:
>
> *eventid *= each sampling (clean-up) event Location = Queensland and New
> South Wales Sites = all the 9 sampling beaches
>
> *Date *= specific dates for the clean-up events (day-month-year)
>
> *Date1 *= specific dates for the clean-up events (day-month-year) on the
> POSICXT format Year= Year of sampling event (2004 to 2018)
>
> *Month*= Month of the sampling event (jan to dec)
>
> *nMonth*= a number was determined to the respective month of the sampling
> event (1 to 12)
>
> *Day*= Day of sampling (1 to 31) Days = Days since the first date of clean
> up = just another way of using the dates
>
> *MARPOL *= before and after implementation (factor with 2 levels)
>
> *DaysC *= days between sampling events for the same sites = number of days
> since the previous clean-up event
>
> *DaysI *= Days since intervention, all the dates before implementation are
> zero, and after we count the number of days since the implementation date
> (1 jan 2013)
>
> *DaysIa*= same as DayI but instead of zero for before the intervention we
> have negative values (days)
>
> *Items *= number of fishing and shipping items counted in each clean-up
> event
>
> *Hours *= hours spent by all volunteers together at each clean up event
>
> *Lenght *= Lenght of beach sampled by all volunteers together at each clean
> up event volunteers = all volunteers at each clean up event
>
> *HoursVolunteer *= hours spent bt each volunteer at each clean up event
> (Hours/volunteers)
>
> *Ieffort *= the items standarized by the effort (hours, volunteers and
> lenght)
>
> *GrossWeight & **GrossTotal are not relevant *
> --
> Problems:
>
> My data has a few problems: (1) I think I will need to fix the effects of
> seasonal variation (Monthly) and (2) of possible spatial correlation
> (probability of finding an item is higher after finding one since they can
> come from the same ship). (3) How do I handle the fact that the
> measurements were not taken at a regular interval?
>
> I was trying to use GAMs to analyse the data and see the trends over time.
> The model I came across is the following:
>
> m4<- gamm(Ieffort ~ s(DaysIa)+MARPOL+ s(nMonth, bs = "ps", k = 12),
> random=list(Site=~1,Location=~1),data = d)
>
> *thank you in advance.*
> -
> *Catarina Serra Gonçalves *
> PhD candidate
>
> Adrift Lab  
> University of Tasmania  | Institute for Marine
> and
> Antarctic Studies  
> Launceston, TAS | Australia
>
> Personal website 
> | E-mail   |
> Twitter 
> Research Gate
>  | Google
> Scholar 
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Time series (trend over time) for irregular sampling dates and multiple sites

2019-04-30 Thread Catarina Serra Gonçalves
I have a dataset of marine debris items (number of items standardized per
effort: Items/(number of volunteers*Hours*Lenght)) taken from 2 main
locations (WA and Queensland) in Australia (8 Sub Sites in total: 4 in WA
and 4 in Queensland) at irregular sampling intervals over a period 15 years.

I want to test if there is a change over the years on the amount of debris
in these locations and more specifically a change after the implementation
of a mitigation strategy (in 2013).
Here’s the head of the data:[image: enter image description here]
Description of each one of the
varables in the dataframe:

*eventid *= each sampling (clean-up) event Location = Queensland and New
South Wales Sites = all the 9 sampling beaches

*Date *= specific dates for the clean-up events (day-month-year)

*Date1 *= specific dates for the clean-up events (day-month-year) on the
POSICXT format Year= Year of sampling event (2004 to 2018)

*Month*= Month of the sampling event (jan to dec)

*nMonth*= a number was determined to the respective month of the sampling
event (1 to 12)

*Day*= Day of sampling (1 to 31) Days = Days since the first date of clean
up = just another way of using the dates

*MARPOL *= before and after implementation (factor with 2 levels)

*DaysC *= days between sampling events for the same sites = number of days
since the previous clean-up event

*DaysI *= Days since intervention, all the dates before implementation are
zero, and after we count the number of days since the implementation date
(1 jan 2013)

*DaysIa*= same as DayI but instead of zero for before the intervention we
have negative values (days)

*Items *= number of fishing and shipping items counted in each clean-up
event

*Hours *= hours spent by all volunteers together at each clean up event

*Lenght *= Lenght of beach sampled by all volunteers together at each clean
up event volunteers = all volunteers at each clean up event

*HoursVolunteer *= hours spent bt each volunteer at each clean up event
(Hours/volunteers)

*Ieffort *= the items standarized by the effort (hours, volunteers and
lenght)

*GrossWeight & **GrossTotal are not relevant *
--
Problems:

My data has a few problems: (1) I think I will need to fix the effects of
seasonal variation (Monthly) and (2) of possible spatial correlation
(probability of finding an item is higher after finding one since they can
come from the same ship). (3) How do I handle the fact that the
measurements were not taken at a regular interval?

I was trying to use GAMs to analyse the data and see the trends over time.
The model I came across is the following:

m4<- gamm(Ieffort ~ s(DaysIa)+MARPOL+ s(nMonth, bs = "ps", k = 12),
random=list(Site=~1,Location=~1),data = d)

*thank you in advance.*
-
*Catarina Serra Gonçalves *
PhD candidate

Adrift Lab  
University of Tasmania  | Institute for Marine and
Antarctic Studies  
Launceston, TAS | Australia

Personal website 
| E-mail   |
Twitter 
Research Gate
 | Google
Scholar 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time series analysis: Granger causality with error-correction term

2018-08-21 Thread John
Hi,

   Which package/function do you recommend for Granger causality between x
and y with an error correction term?

   In my problem, economic theory maintains that x~ I(1); y~I(1), x-y ~I(0)

\begin{eqnarray}
\Delta x_t = g_0 + \lambda_{x}(x_{t-1}-y_{t-1})+\sum_{k=1}^{n}g_{1k}\Delta
x_{t-s}+\sum_{k=1}^{n}g_{2k}\Delta y_{t-s}+\epsilon_{1t}  \\
\Delta y_t = g_0 + \lambda_{y}(x_{t-1}-y_{t-1})+\sum_{k=1}^{n}g_{3k}\Delta
x_{t-s}+\sum_{k=1}^{n}g_{4k}\Delta y_{t-s}+\epsilon_{2t}
\end{eqnarray}

   I am not sure if it would work if I run Granger causality between \Delta
x and \Delta y, treating the error correction term (x_{t-1}-y_{t-1}) and
exogenous variable.

   Thank you very much!!

John

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 moving average question

2018-06-04 Thread Bill Poling
Good morning Don, thank you for your support. I will give this all more 
investigation and submit my findings when finalized.

Cheers and thanks again for your help Sir.

WHP



From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 5:03 PM
To: Bill Poling ; r-help (r-help@r-project.org) 

Subject: Re: [R] Time-series moving average question

For your first question, you’re doing moving averages of 3 points (I assume 
that’s what order=3 does). For any given time point of your input data, that 
would be one before, one at, and one after the given time point. Do all of  
your input times have both one before and one after?

Don’t know about your same 8 point forecast values question, not without 
running it myself, but I would say that if the data really is different, yet 
the forecasts are the same, it would have to be coincidental. But a priori this 
seems unlikely, so I’d inspect your script very carefully for mistakes.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Bill Poling mailto:bill.pol...@zelis.com>>
Date: Friday, June 1, 2018 at 10:43 AM
To: "MacQueen, Don" mailto:macque...@llnl.gov>>, array 
R-help mailto:r-help@r-project.org>>
Subject: RE: [R] Time-series moving average question

Hi Don, wow, you are so right. I picked that piece up from the bloggers 
tutorial and since I am R naive yet, I thought it was all one step

moving_average = forecast(ma(tdat[1:31], order=2), h=5)

Truly, I usually print and check at every step I can, as painful as it is 
sometimes.
Great lesson for this novice usR.

So the first and last values are NA in each case? Do you know why? Should I 
replace the NA with a value, say the average of the others?

Also, I have 5 series of data I am working with using this script and of course 
each gave me that warning, but only the one series had the same 8 Point 
Forecast values, is that coincidental you think?

Terrific of you to help, I really appreciate it.

WHP


From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 12:54 PM
To: Bill Poling mailto:bill.pol...@zelis.com>>; r-help 
(r-help@r-project.org<mailto:r-help@r-project.org>) 
mailto:r-help@r-project.org>>
Subject: Re: [R] Time-series moving average question

You are right that there are no NAs in the practice data. But there are NAs in 
the moving average data.

To see this, break your work into two separate steps, like this:

tnr.ma<http://tnr.ma> <- ma(dat3[1:28], order=3)
TNR_moving_average <- forecast(tnr.ma<http://tnr.ma>, h=8)

I think you will find that the warning comes from the second step.

Print tnr.ma<http://tnr.ma> and you will see some NAs.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Bill Poling mailto:bill.pol...@zelis.com>>
Date: Friday, June 1, 2018 at 8:58 AM
To: "MacQueen, Don" mailto:macque...@llnl.gov>>, array 
R-help mailto:r-help@r-project.org>>
Subject: RE: [R] Time-series moving average question

Hello Don, thank you for your response. I appreciate your help.

I am using the forecast package, originally I found it following a forecasting 
example on bloggers.com<http://bloggers.com>

https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/<https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/>

And subsequently located the complete pdf 
https://cran.r-project.org/web/packages/forecast/forecast.pdf<https://cran.r-project.org/web/packages/forecast/forecast.pdf>

Since I created this practice data using the structure() function I am unsure 
why there would be NA’s as there are none apparently in the structure?

No worries though, I am going to reach out to the package author.

Cheers.

WHP

From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 11:24 AM
To: Bill Poling mailto:bill.pol...@zelis.com>>; r-help 
(r-help@r-project.org<mailto:r-help@r-project.org>) 
mailto:r-help@r-project.org>>
Subject: Re: [R] Time-series moving average question

My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I 
assume they come from some package you installed; it would be helpful to say 
which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509


__
mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide 
http://www.R-p

Re: [R] Time-series moving average question

2018-06-01 Thread MacQueen, Don via R-help
For your first question, you’re doing moving averages of 3 points (I assume 
that’s what order=3 does). For any given time point of your input data, that 
would be one before, one at, and one after the given time point. Do all of  
your input times have both one before and one after?

Don’t know about your same 8 point forecast values question, not without 
running it myself, but I would say that if the data really is different, yet 
the forecasts are the same, it would have to be coincidental. But a priori this 
seems unlikely, so I’d inspect your script very carefully for mistakes.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Bill Poling 
Date: Friday, June 1, 2018 at 10:43 AM
To: "MacQueen, Don" , array R-help 
Subject: RE: [R] Time-series moving average question

Hi Don, wow, you are so right. I picked that piece up from the bloggers 
tutorial and since I am R naive yet, I thought it was all one step

moving_average = forecast(ma(tdat[1:31], order=2), h=5)

Truly, I usually print and check at every step I can, as painful as it is 
sometimes.
Great lesson for this novice usR.

So the first and last values are NA in each case? Do you know why? Should I 
replace the NA with a value, say the average of the others?

Also, I have 5 series of data I am working with using this script and of course 
each gave me that warning, but only the one series had the same 8 Point 
Forecast values, is that coincidental you think?

Terrific of you to help, I really appreciate it.

WHP


From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 12:54 PM
To: Bill Poling ; r-help (r-help@r-project.org) 

Subject: Re: [R] Time-series moving average question

You are right that there are no NAs in the practice data. But there are NAs in 
the moving average data.

To see this, break your work into two separate steps, like this:

tnr.ma<http://tnr.ma> <- ma(dat3[1:28], order=3)
TNR_moving_average <- forecast(tnr.ma<http://tnr.ma>, h=8)

I think you will find that the warning comes from the second step.

Print tnr.ma<http://tnr.ma> and you will see some NAs.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Bill Poling mailto:bill.pol...@zelis.com>>
Date: Friday, June 1, 2018 at 8:58 AM
To: "MacQueen, Don" mailto:macque...@llnl.gov>>, array 
R-help mailto:r-help@r-project.org>>
Subject: RE: [R] Time-series moving average question

Hello Don, thank you for your response. I appreciate your help.

I am using the forecast package, originally I found it following a forecasting 
example on bloggers.com<http://bloggers.com>

https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/

And subsequently located the complete pdf 
https://cran.r-project.org/web/packages/forecast/forecast.pdf

Since I created this practice data using the structure() function I am unsure 
why there would be NA’s as there are none apparently in the structure?

No worries though, I am going to reach out to the package author.

Cheers.

WHP

From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 11:24 AM
To: Bill Poling mailto:bill.pol...@zelis.com>>; r-help 
(r-help@r-project.org<mailto:r-help@r-project.org>) 
mailto:r-help@r-project.org>>
Subject: Re: [R] Time-series moving average question

My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I 
assume they come from some package you installed; it would be helpful to say 
which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509


__
mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transm

Re: [R] Time-series moving average question

2018-06-01 Thread Bill Poling
Hi Don, wow, you are so right. I picked that piece up from the bloggers 
tutorial and since I am R naive yet, I thought it was all one step

moving_average = forecast(ma(tdat[1:31], order=2), h=5)

Truly, I usually print and check at every step I can, as painful as it is 
sometimes.
Great lesson for this novice usR.

So the first and last values are NA in each case? Do you know why? Should I 
replace the NA with a value, say the average of the others?

Also, I have 5 series of data I am working with using this script and of course 
each gave me that warning, but only the one series had the same 8 Point 
Forecast values, is that coincidental you think?

Terrific of you to help, I really appreciate it.

WHP


From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 12:54 PM
To: Bill Poling ; r-help (r-help@r-project.org) 

Subject: Re: [R] Time-series moving average question

You are right that there are no NAs in the practice data. But there are NAs in 
the moving average data.

To see this, break your work into two separate steps, like this:

tnr.ma<http://tnr.ma> <- ma(dat3[1:28], order=3)
TNR_moving_average <- forecast(tnr.ma<http://tnr.ma>, h=8)

I think you will find that the warning comes from the second step.

Print tnr.ma<http://tnr.ma> and you will see some NAs.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Bill Poling mailto:bill.pol...@zelis.com>>
Date: Friday, June 1, 2018 at 8:58 AM
To: "MacQueen, Don" mailto:macque...@llnl.gov>>, array 
R-help mailto:r-help@r-project.org>>
Subject: RE: [R] Time-series moving average question

Hello Don, thank you for your response. I appreciate your help.

I am using the forecast package, originally I found it following a forecasting 
example on bloggers.com<http://bloggers.com>

https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/<https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/>

And subsequently located the complete pdf 
https://cran.r-project.org/web/packages/forecast/forecast.pdf<https://cran.r-project.org/web/packages/forecast/forecast.pdf>

Since I created this practice data using the structure() function I am unsure 
why there would be NA’s as there are none apparently in the structure?

No worries though, I am going to reach out to the package author.

Cheers.

WHP

From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 11:24 AM
To: Bill Poling mailto:bill.pol...@zelis.com>>; r-help 
(r-help@r-project.org<mailto:r-help@r-project.org>) 
mailto:r-help@r-project.org>>
Subject: Re: [R] Time-series moving average question

My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I 
assume they come from some package you installed; it would be helpful to say 
which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509


__
mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html<http://www.R-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.



Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.

Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, o

Re: [R] Time-series moving average question

2018-06-01 Thread MacQueen, Don via R-help
You are right that there are no NAs in the practice data. But there are NAs in 
the moving average data.

To see this, break your work into two separate steps, like this:

  tnr.ma <- ma(dat3[1:28], order=3)
  TNR_moving_average <- forecast(tnr.ma, h=8)

I think you will find that the warning comes from the second step.

Print tnr.ma and you will see some NAs.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 


From: Bill Poling 
Date: Friday, June 1, 2018 at 8:58 AM
To: "MacQueen, Don" , array R-help 
Subject: RE: [R] Time-series moving average question

Hello Don, thank you for your response. I appreciate your help. 
 
I am using the forecast package, originally I found it following a forecasting 
example on bloggers.com 
 
https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/
 
And subsequently located the complete pdf 
https://cran.r-project.org/web/packages/forecast/forecast.pdf
 
Since I created this practice data using the structure() function I am unsure 
why there would be NA’s as there are none apparently in the structure?
 
No worries though, I am going to reach out to the package author.
 
Cheers. 
 
WHP
 
From: MacQueen, Don [mailto:macque...@llnl.gov] 
Sent: Friday, June 01, 2018 11:24 AM
To: Bill Poling ; r-help (r-help@r-project.org) 

Subject: Re: [R] Time-series moving average question
 
My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I 
assume they come from some package you installed; it would be helpful to say 
which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509


__
mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018. 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 moving average question

2018-06-01 Thread Bill Poling
Hello Don, thank you for your response. I appreciate your help.

I am using the forecast package, originally I found it following a forecasting 
example on bloggers.com

https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/

And subsequently located the complete pdf 
https://cran.r-project.org/web/packages/forecast/forecast.pdf

Since I created this practice data using the structure() function I am unsure 
why there would be NA’s as there are none apparently in the structure?

No worries though, I am going to reach out to the package author.

Cheers.

WHP

From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Friday, June 01, 2018 11:24 AM
To: Bill Poling ; r-help (r-help@r-project.org) 

Subject: Re: [R] Time-series moving average question

My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I 
assume they come from some package you installed; it would be helpful to say 
which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509


__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html<http://www.R-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.


Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 moving average question

2018-06-01 Thread MacQueen, Don via R-help
My guess would be that if you inspect the output from
ma(dat3[1:28], order=3)
you will find some NAs in it. And then forecast() doesn't like NAs.

But I can't check, because I can't find the ma() and forecast() functions. I 
assume they come from some package you installed; it would be helpful to say 
which package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 6/1/18, 4:20 AM, "R-help on behalf of Bill Poling" 
 wrote:

Good morning, I hope someone can help with these questions, or perhaps 
suggest one of the other R-lists?

I have two questions:


  1.  Why am I getting this warning?
  2.  Why is the second example "Point Forecast" the same value, I do not 
see that in previous attempts with similar but different data sets as in 
example 1?

Example1:
dat3 <- structure(c(3539122.86, 3081383.87, 4158672.31, 4137518.78, 
4123682.08, 4819375.2, 4342687.77, 5028674.58, 4472145.07, 4967277.73, 
4516240.31, 4876194.63, 4816446.59,
4887399.37, 5478504.85, 4871385.27, 5487543.68, 
5464193.69, 5252591.03, 7071416.89, 5524350.89, 6107166.69, 6530003.55, 
6445929.08, 7356743.81, 6750025.03,
6934714.08, 6656194.35

,-13913, -29385.31, -39633.37, -23487.13, -18202.86, 
-57335.49, -26061.45, -60880.07, -17589.45, -35970.08, -89133.94,
-84694.58, -31724.89, -29847.95, -65421.74, -34334.22, 
-48511.98, -30298.97, -38729.46, -29292.89, -46098.4, -65909.49,
-85879.23, -71845.28, -69017.07, -93161.03, -70847.29, 
-85106.04

,-357694.19, -444792.75, -361349.57, -386717.55, 
-547422.05, -518259.22, -417613.76, -578631.46, -804516.81, -572875.52, 
-510487.53,
-666294.87, -673233.37, -556564.45, -963346.75, 
-639288.2, -910104.23, -773428.8, -1008078.84, -546685.3, -729932.94, 
-987098.23,
-964001.63, -986995.93, -680066.58, -728854.58, 
-730766.92, -753861.59)
,.Dim = c(28L, 3L)
,.Dimnames = list(NULL, c("OONNetRev","OONAdjusted" 
,"OONCancelled"))
,.Tsp = c(2016, 2018.25, 12), class = c("mts", "ts", 
"matrix"))
head(dat3); nrow(dat3)

TNR_moving_average <- forecast(ma(dat3[1:28], order=3), h=8)
TNR_moving_average

# Warning message:
#   In ets(object, lambda = lambda, biasadj = biasadj, 
allow.multiplicative.trend = allow.multiplicative.trend,  :
#Missing values encountered. Using longest contiguous portion 
of time series
#  > Point Forecast Lo 80 Hi 80 Lo 95   
  Hi 95
# 28  7007065.99688 6675015.72012 7339116.27365 6499238.92148 
7514893.07229
# 29  7135745.42473 6721543.41996 7549947.42950 6502278.12345 
7769212.72601
# 30  7264424.85258 6779532.18065 7749317.52450 6522845.50541 
8006004.19974
# 31  7393104.28042 6844496.10189 7941712.45896 6554080.47486 
8232128.08599
# 32  7521783.70827 6914203.11991 8129364.29663 6592569.38486 
8450998.03168
# 33  7650463.13612 6987355.72657 8313570.54567 6636327.86794 
8664598.40429
# 34  7779142.56396 7063123.29787 8495161.83005 6684085.59434 
8874199.53358
# 35  7907821.99181 7140937.69145 8674706.29217 6734973.66528 
9080670.31834




Example2:
dat3 <- structure(c(994320.58, 811664.54, 1045259.43, 951659.48, 669458.94, 
986741.09, 1023344.82, 938971.65, 897670.06, 1040074.6, 1090310.01,
1289821.17, 1187806.23, 971485.76, 1161147.42, 
870585.04, 1021301.52, 1215798.03, 1015004.43, 1365863.09, 995769.41,
1331725.36, 1271032.91, 1092103.82, 1297131.4, 
1129195.28, 1372594.58, 1553717.57,

-39811.51, -47356.74, -49046.86, -41311.13, -79063.98, 
-43916.59, -16746.33, -38347.9, -84797.44, -38961.44,
-72036.83, -62854.78, -35259.84, -44198.39, -34262.65, 
-49245.82, -34977.28, -36797.35, -47534.43, -33515.13,
-25764.41, -29130.53, -57693.63, -51026.83, -49624.49, 
-36508.13, -32667.21, -37900.5,

-247443.87, -372942.34, -344080.78, -355586.21, 
-458998.84, -378086.44, -333994.18, -567024.45, -521499.8, -428915.13,
-512034.28, -440865.42, -347494.22, -422436.19, 
-444588.65, -462891.57, -518395.47, -373818.5, -398899.53, -381573.69,
-531449.2, -476238.48, -434296.86, -655679.94, 
-528999.52, -423725.95, -556977.31, -518633.95)
  ,.Dim = c(28L, 3L)
  ,.Dimnames = list(NULL, c("EditNetRev","EditNetAdjusted" 
,"EditNetCancelled"))
  ,.Tsp = c(2016, 2018.25, 12), class = c("mts", "ts", 
"matrix"))
head(dat3); nrow(dat3)
   

[R] Time-series moving average question

2018-06-01 Thread Bill Poling
Good morning, I hope someone can help with these questions, or perhaps suggest 
one of the other R-lists?

I have two questions:


  1.  Why am I getting this warning?
  2.  Why is the second example "Point Forecast" the same value, I do not see 
that in previous attempts with similar but different data sets as in example 1?

Example1:
dat3 <- structure(c(3539122.86, 3081383.87, 4158672.31, 4137518.78, 4123682.08, 
4819375.2, 4342687.77, 5028674.58, 4472145.07, 4967277.73, 4516240.31, 
4876194.63, 4816446.59,
4887399.37, 5478504.85, 4871385.27, 5487543.68, 5464193.69, 
5252591.03, 7071416.89, 5524350.89, 6107166.69, 6530003.55, 6445929.08, 
7356743.81, 6750025.03,
6934714.08, 6656194.35

,-13913, -29385.31, -39633.37, -23487.13, -18202.86, 
-57335.49, -26061.45, -60880.07, -17589.45, -35970.08, -89133.94,
-84694.58, -31724.89, -29847.95, -65421.74, -34334.22, 
-48511.98, -30298.97, -38729.46, -29292.89, -46098.4, -65909.49,
-85879.23, -71845.28, -69017.07, -93161.03, -70847.29, 
-85106.04

,-357694.19, -444792.75, -361349.57, -386717.55, 
-547422.05, -518259.22, -417613.76, -578631.46, -804516.81, -572875.52, 
-510487.53,
-666294.87, -673233.37, -556564.45, -963346.75, -639288.2, 
-910104.23, -773428.8, -1008078.84, -546685.3, -729932.94, -987098.23,
-964001.63, -986995.93, -680066.58, -728854.58, -730766.92, 
-753861.59)
,.Dim = c(28L, 3L)
,.Dimnames = list(NULL, c("OONNetRev","OONAdjusted" 
,"OONCancelled"))
,.Tsp = c(2016, 2018.25, 12), class = c("mts", "ts", 
"matrix"))
head(dat3); nrow(dat3)

TNR_moving_average <- forecast(ma(dat3[1:28], order=3), h=8)
TNR_moving_average

# Warning message:
#   In ets(object, lambda = lambda, biasadj = biasadj, 
allow.multiplicative.trend = allow.multiplicative.trend,  :
#Missing values encountered. Using longest contiguous portion of 
time series
#  > Point Forecast Lo 80 Hi 80 Lo 95 
Hi 95
# 28  7007065.99688 6675015.72012 7339116.27365 6499238.92148 
7514893.07229
# 29  7135745.42473 6721543.41996 7549947.42950 6502278.12345 
7769212.72601
# 30  7264424.85258 6779532.18065 7749317.52450 6522845.50541 
8006004.19974
# 31  7393104.28042 6844496.10189 7941712.45896 6554080.47486 
8232128.08599
# 32  7521783.70827 6914203.11991 8129364.29663 6592569.38486 
8450998.03168
# 33  7650463.13612 6987355.72657 8313570.54567 6636327.86794 
8664598.40429
# 34  7779142.56396 7063123.29787 8495161.83005 6684085.59434 
8874199.53358
# 35  7907821.99181 7140937.69145 8674706.29217 6734973.66528 
9080670.31834




Example2:
dat3 <- structure(c(994320.58, 811664.54, 1045259.43, 951659.48, 669458.94, 
986741.09, 1023344.82, 938971.65, 897670.06, 1040074.6, 1090310.01,
1289821.17, 1187806.23, 971485.76, 1161147.42, 870585.04, 
1021301.52, 1215798.03, 1015004.43, 1365863.09, 995769.41,
1331725.36, 1271032.91, 1092103.82, 1297131.4, 1129195.28, 
1372594.58, 1553717.57,

-39811.51, -47356.74, -49046.86, -41311.13, -79063.98, 
-43916.59, -16746.33, -38347.9, -84797.44, -38961.44,
-72036.83, -62854.78, -35259.84, -44198.39, -34262.65, 
-49245.82, -34977.28, -36797.35, -47534.43, -33515.13,
-25764.41, -29130.53, -57693.63, -51026.83, -49624.49, 
-36508.13, -32667.21, -37900.5,

-247443.87, -372942.34, -344080.78, -355586.21, -458998.84, 
-378086.44, -333994.18, -567024.45, -521499.8, -428915.13,
-512034.28, -440865.42, -347494.22, -422436.19, -444588.65, 
-462891.57, -518395.47, -373818.5, -398899.53, -381573.69,
-531449.2, -476238.48, -434296.86, -655679.94, -528999.52, 
-423725.95, -556977.31, -518633.95)
  ,.Dim = c(28L, 3L)
  ,.Dimnames = list(NULL, c("EditNetRev","EditNetAdjusted" 
,"EditNetCancelled"))
  ,.Tsp = c(2016, 2018.25, 12), class = c("mts", "ts", 
"matrix"))
head(dat3); nrow(dat3)



TNR_moving_average <- forecast(ma(dat3[1:28], order=3), h=8)
TNR_moving_average

# Warning message:
# In ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend 
= allow.multiplicative.trend,  :
#  Missing values encountered. Using longest contiguous portion of time 
series
#> TNR_moving_average
#Point Forecast Lo 80 Hi 80  Lo 95 Hi 95
#28  1351827.24389 1246570.02118 1457084.46661 1190850.213255 
1512804.27453
#29  1351827.24389 1202841.21791 1500813.26987 1123972.779844 
1579681.70794
#30  1351827.24389 1169192.03201 1534462.45578 1072510.790913 
1631143.69687
#31  1351827.24389 1140745.29674 1562909.19105 1029005.263624 
1674649.22416
#32  

[R] Time Series with Neural Networks

2017-12-26 Thread Emre Karagülle
Hi,
I am would like to ask few questions. 
I am trying to forecast  hourly electricity prices by 24 hours ahead.
I have hourly data starting from 2015*12*18 to 2017-10-24
and I have defined the data as time series as written in the code below.

Then I am trying do neural network with 23 non-seasonal dummies and 1 seasonal 
dummy.
But I don’t know whether training set is enough.( Guess it is 50 hours in here?)

The problem is that I couldn’t 24 for output here. How can I make such forecast?
 And my MASE score (6.95 in the Test set) is not good. Could be related to 
shortness of training set?

The Code:

library(zoo)
library(readxl)
setwd("C:/Users/emrek/Dropbox/2017-2018 Master Thesis/DATA")
epias <- read_excel("eski.epias.xlsx")


nPTF <- epias$`PTF (TL/MWh)`
nSMF<- epias$`SMF(TL/MWh)`
nC<- epias$`TT(MWh)`
nEAK<- epias$`EAK-Toplam (MWh)`
nTP<- epias$`Toplam (MWh)`

times <- seq(from=as.POSIXct("2015-12-18 00:00:00"), 
to=as.POSIXct("2017-10-24 23:00:00"), by="hour")
mydata <- rnorm(length(times))

PTF <- zoo(nPTF, order.by=times )
SMF <- zoo(nSMF, order.by=times )
C <- zoo(nC, order.by=times )
EAK <- zoo(nEAK, order.by=times )
TP<- zoo(nTP, order.by=times )
SH <- (EAK-TP)

epias <- cbind(PTF,C,SH)
View(epias)

#neural networks
library(forecast)
set.seed(201)
epias.nn <- nnetar(PTF, repeats = 50, p=23, P=1, size =12)
summary(epias.nn$model[[1]])

epias.pred <- forecast(epias.nn, h= 24)
accuracy(epias.pred, 24)

plot(PTF, ylim=c(0,500) , ylab=  , xlab= , bty="l", xaxt="n", 
xlim=c(as.POSIXct("2017-10-20 00:00:00"),as.POSIXct("2017-10-25 23:00:00")) , 
lty=1 )

lines(epias.pred$fitted,lwd = 2,col="blue")


Best Regards,
--
Emre


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 Plotting"

2017-10-11 Thread PIKAL Petr
Hi
keep your emails to R help, I do not offer private consultance and others could 
have different opinion how to solve your problem.
Did you even try my suggestion? If not, why not? If yes in what respect it does 
not comply with your expectations.
Cheers
Petr

From: niharika singhal [mailto:niharikasinghal1...@gmail.com]
Sent: Tuesday, October 10, 2017 2:34 PM
To: PIKAL Petr <petr.pi...@precheza.cz>
Subject: Re: [R] "Time Series Plotting"

Hello,

My Energy column looks like in the image in the attachment, and my sequence 
column correspond to state.
I wanted to look at the graph and see the state correspond to the energy column 
in the Times series

Thanks & Regards
Niharika


On Tue, Oct 10, 2017 at 2:28 PM, niharika singhal 
<niharikasinghal1...@gmail.com<mailto:niharikasinghal1...@gmail.com>> wrote:
hello,

I just wanted the result in Time series thats why i am doing ts

On Tue, Oct 10, 2017 at 2:23 PM, PIKAL Petr 
<petr.pi...@precheza.cz<mailto:petr.pi...@precheza.cz>> wrote:
Hi

I wonder why do you want to change it to ts. If I am not mistaken


plot(Data$Energy, col=Data$sequence)

or

plot(1:nrow(Data), Data$Energy, col=Data$sequence)

should do the trick.

Cheers
Petr

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>] On 
> Behalf Of niharika
> singhal
> Sent: Tuesday, October 10, 2017 2:09 PM
> To: r-help@r-project.org<mailto:r-help@r-project.org>
> Subject: [R] "Time Series Plotting"
>
> Hello,
>
>
> I need some help in plotting time series.
>
>
> I have dataframe Data with two column and thousands of row, I want wherever
> the sequence corresponding to Energy column is changed the color change
> should be reflected in Time Series plot, some rows of dataframe are below
>
>
>
> Energy  sequence
>
> 13536 3
>
> 14335 3
>
> 14638 3
>
> 25363 3
>
> 18511 2
>
> 18371 2
>
> 14555 3
>
>
>
> I am able to plot time series by:-
>
> Data.energy<- ts(Data$ Energy, frequency=1)
>
> plot(Data.energy)
>
>
>
> How should I add the color effect based on the sequence column value?
>
>
>
> Thanks & Regards
>
> Niharika Singhal
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> 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.




Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any

Re: [R] "Time Series Plotting"

2017-10-10 Thread PIKAL Petr
Hi

I wonder why do you want to change it to ts. If I am not mistaken


plot(Data$Energy, col=Data$sequence)

or

plot(1:nrow(Data), Data$Energy, col=Data$sequence)

should do the trick.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of niharika
> singhal
> Sent: Tuesday, October 10, 2017 2:09 PM
> To: r-help@r-project.org
> Subject: [R] "Time Series Plotting"
>
> Hello,
>
>
> I need some help in plotting time series.
>
>
> I have dataframe Data with two column and thousands of row, I want wherever
> the sequence corresponding to Energy column is changed the color change
> should be reflected in Time Series plot, some rows of dataframe are below
>
>
>
> Energy  sequence
>
> 13536 3
>
> 14335 3
>
> 14638 3
>
> 25363 3
>
> 18511 2
>
> 18371 2
>
> 14555 3
>
>
>
> I am able to plot time series by:-
>
> Data.energy<- ts(Data$ Energy, frequency=1)
>
> plot(Data.energy)
>
>
>
> How should I add the color effect based on the sequence column value?
>
>
>
> Thanks & Regards
>
> Niharika Singhal
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] "Time Series Plotting"

2017-10-10 Thread niharika singhal
Hello,


I need some help in plotting time series.


I have dataframe Data with two column and thousands of row, I want wherever
the sequence corresponding to Energy column is changed the color change
should be reflected in Time Series plot, some rows of dataframe are below



Energy  sequence

13536 3

14335 3

14638 3

25363 3

18511 2

18371 2

14555 3



I am able to plot time series by:-

Data.energy<- ts(Data$ Energy, frequency=1)

plot(Data.energy)



How should I add the color effect based on the sequence column value?



Thanks & Regards

Niharika Singhal

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread Gabor Grothendieck
Maybe one of these are close enough:

  xts(c(2, 4, 5), yearqtr(1991:1993))

  as.xts(ts(c(2, 4, 5), 1991))

of if you want only a plain year as the index then then use zoo,
zooreg or ts class:

  library(zoo)
  zoo(c(2, 4, 5), 1991:1993)

  zooreg(c(2, 4, 5), 1991)

  ts(c(2, 4, 5), 1991)

On Fri, Oct 6, 2017 at 2:56 AM, John  wrote:
> Hi,
>
>I'd like to make a time series at an annual frequency.
>
>> a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993"))
> Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) :
>   order.by requires an appropriate time-based object
>> a<-xts(x=c(2,4,5), order.by=1991:1993)
> Error in xts(x = c(2, 4, 5), order.by = 1991:1993) :
>   order.by requires an appropriate time-based object
>
>   How should I do it? I know that to do for quarterly or monthly time
> series, we use as.yearqtr or as.yearmon. What about annual?
>
>Thanks,
>
> John
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread Eric Berger
Hi John,
Here's one way to do it:
vec <- c(2,4,5)
yrs <- seq(from=as.Date("1991-01-01"),by="1 year",length=length(vec))
a <-  xts(x=vec, order.by=yrs)

HTH,
Eric


On Fri, Oct 6, 2017 at 9:56 AM, John  wrote:

> Hi,
>
>I'd like to make a time series at an annual frequency.
>
> > a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993"))
> Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) :
>   order.by requires an appropriate time-based object
> > a<-xts(x=c(2,4,5), order.by=1991:1993)
> Error in xts(x = c(2, 4, 5), order.by = 1991:1993) :
>   order.by requires an appropriate time-based object
>
>   How should I do it? I know that to do for quarterly or monthly time
> series, we use as.yearqtr or as.yearmon. What about annual?
>
>Thanks,
>
> John
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Time series: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread John
Hi,

   I'd like to make a time series at an annual frequency.

> a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993"))
Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) :
  order.by requires an appropriate time-based object
> a<-xts(x=c(2,4,5), order.by=1991:1993)
Error in xts(x = c(2, 4, 5), order.by = 1991:1993) :
  order.by requires an appropriate time-based object

  How should I do it? I know that to do for quarterly or monthly time
series, we use as.yearqtr or as.yearmon. What about annual?

   Thanks,

John

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] time series x axis labels

2017-06-07 Thread Felipe Carrillo via R-help
I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and 
those are the values that I want to show on my x axis, howeverI only get 3, 
3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I 
getthe following error:Error in unit(x, default.units) : 'x' and 'units' must 
have length > 0
question: Which argument is needed in the ts() call to make the x axis 
showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66, 73, 80, 87, 
94, 101), AvgWeight = c(1, 1.67, 2.07, 2.275, 
3.83, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 
21.5), PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L), .Label = "Pond01", class = "factor"),     SampleDate = 
structure(c(1182585600, 1183190400, 1183795200,     118440, 1185004800, 
1185609600, 1186214400, 1186819200,     1187424000, 1188028800, 1188633600, 
1189238400, 1189843200,     1190448000, 1191052800), class = c("POSIXct", 
"POSIXt"))), .Names = c("DOC", "AvgWeight", "PondName", "SampleDate"), 
row.names = c(NA, 15L), class = "data.frame")  
wt$SampleDate <- as.Date(wt$SampleDate)  wt
library(forecast)library(ggplot2)pond <- 
ts(wt$AvgWeight,start=3,frequency=52)pond d.arima <- auto.arima(pond)d.forecast 
<- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 
'units' must have length > 0

Take a look at the attached plot

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time series axis breaks

2017-06-07 Thread Felipe Carrillo via R-help
I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and 
those are the values that I want to show on my x axis, howeverI only get 3, 
3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I 
getthe following error:Error in unit(x, default.units) : 'x' and 'units' must 
have length > 0
question: Which argument is needed in the ts() call to make the x axis 
showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66, 73, 80, 87, 
94, 101), AvgWeight = c(1, 1.67, 2.07, 2.275, 
3.83, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 
21.5), PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L), .Label = "Pond01", class = "factor"),     SampleDate = 
structure(c(1182585600, 1183190400, 1183795200,     118440, 1185004800, 
1185609600, 1186214400, 1186819200,     1187424000, 1188028800, 1188633600, 
1189238400, 1189843200,     1190448000, 1191052800), class = c("POSIXct", 
"POSIXt"))), .Names = c("DOC", "AvgWeight", "PondName", "SampleDate"), 
row.names = c(NA, 15L), class = "data.frame")  
wt$SampleDate <- as.Date(wt$SampleDate)  wt
library(forecast)library(ggplot2)pond <- 
ts(wt$AvgWeight,start=3,frequency=52)pond d.arima <- auto.arima(pond)d.forecast 
<- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 
'units' must have length > 0

Take a look at the attached plot
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time Series forecasting models for irregular time series for zoo objects

2017-04-20 Thread Sonam Tripathi
Hi I am new with R.Currently I am using time series forecasting to do daily 
forecasting for predicting request per day.The dataset which i am using has 
unevenly spaced date a snapshot of dataset is given below I have to find 
the best model which can help me in predicting the future request which can 
make forecast for next 15 days.I have used zoo package for dealing with 
irregular time series data but now I am unable to implement "ets" and "ar" 
and "arima" model with this as it expects the series to be regular and 
evenly spaced and it gives me warning " Missing values encountered. Using 
longest contiguous portion of time series"  but still I proceed for 
forecast then it is showing me date in the format like "1.711600e+04" and 
point of forecast is same for nearly all the dates. 

date req_per_day 
13-07-2016 1 
15-07-2016 1 
11-08-2016 1 
01-09-2016 1 
13-09-2016 1 
14-09-2016 1 
22-09-2016 2 
23-09-2016 1 
26-09-2016 2 
27-09-2016 4 
29-09-2016 2 

My question is how to implement ets and other model on zoo objects which 
show me correct date format.Based on other suggestions i have also tried 
converting zoo to ts but it is again showing "NA" for the dates which are 
not present in the dataset and give same result which I specified above.

How to do time series forecasting with uneven or irregular dates using zoo 
objects in R.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Generating Web Service for R Time Series Model in Microsoft Machine Learning Studio

2017-02-23 Thread Paul Bernal
Dear all,

I just created an R script to generate forecasts in Microsoft Azure Machine
Learning Studio, however, I want to create a web service for this model.

Does anybody has any idea of how to do it? I have been searching in the
web, but haven´t found anything yet.

Any help will be greatly appreciated,

Best regards,

Paul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 plot with Date/Time showing on x-axis

2016-03-16 Thread Jim Lemon
Hi Kwabena,
Try this:

kfa.df<-read.table(text="Date/Time,PR,SW,TP,SM,SHF,CO2
28.11.2011 17:39:49,978.4,13.15,30.5,20,NA,NA
28.11.2011 17:50:00,978.5,13.11,30.4,20,NA,NA
28.11.2011 18:00:00,978.8,13.14,30.3,20,NA,NA
28.11.2011 18:10:00,979,13.07,30.1,20,NA,NA
28.11.2011 18:20:00,979.2,13.1,30,20,NA,NA
28.11.2011 18:30:00,979.4,13.09,29.8,20,NA,NA
28.11.2011 18:40:00,979.5,13.08,29.6,20,NA,NA
28.11.2011 18:50:00,979.5,13.06,29.5,20,NA,NA
28.11.2011 19:00:00,979.6,13.06,29.4,20,NA,NA
28.11.2011 19:10:00,979.7,13.05,29.3,20,NA,NA
28.11.2011 19:20:00,979.9,13.03,29.2,20,NA,NA
28.11.2011 19:30:00,980,13,29.1,20,NA,NA
28.11.2011 19:40:00,980,13.03,29,20,NA,NA
28.11.2011 19:50:00,980.1,13.03,28.9,20,NA,NA
28.11.2011 20:00:00,980.3,13,28.8,20,NA,NA
28.11.2011 20:10:00,980.5,12.97,28.7,20,NA,NA
28.11.2011 20:20:00,980.8,12.96,28.6,20,NA,NA
28.11.2011 20:30:00,981.1,12.95,28.5,20,NA,NA
28.11.2011 20:40:00,981.1,12.95,28.4,20,NA,NA
28.11.2011 20:50:00,981.2,12.94,28.3,20,NA,NA
28.11.2011 21:00:00,981.3,12.93,28.2,20,NA,NA
28.11.2011 21:10:00,981.3,12.92,28.1,20,NA,NA
28.11.2011 21:20:00,981.5,12.9,28,20,NA,NA
28.11.2011 21:30:00,981.6,12.9,27.9,20,NA,NA
28.11.2011 21:40:00,981.7,12.88,27.9,20,NA,NA
28.11.2011 21:50:00,981.7,12.87,27.8,20,NA,NA
28.11.2011 22:00:00,981.7,12.86,27.7,20,NA,NA
28.11.2011 22:10:00,981.8,12.85,27.6,20,NA,NA
28.11.2011 22:20:00,981.8,12.84,27.5,20,NA,NA
28.11.2011 22:30:00,981.8,12.83,27.5,20,NA,NA",
sep=",",header=TRUE,stringsAsFactors=FALSE)
kfa.df$Date.Time<-strptime(kfa.df$Date.Time,"%d.%m.%Y %H:%M:%S")
library(plotrix)
plot(kfa.df$Date.Time,kfa.df$PR,xaxt="n")
xticklab<-pretty(kfa.df$Date.Time)
staxlab(1,at=xticklab)

Jim


On Wed, Mar 16, 2016 at 2:28 PM, Kwabena Fosu-Amankwah  wrote:
> I would be very grateful if someone can help me with the code or
> script on how to plot a time series plot with Date/Time showing on
> x-axis for the set of data below:
>
> Date/Time PR SW TP  SM SHF CO2
> 28.11.2011 17:39:49 978.4 13.15 30.5 20 NA NA
> 28.11.2011 17:50:00 978.5 13.11 30.4 20 NA NA
> 28.11.2011 18:00:00 978.8 13.14 30.3 20 NA NA
> 28.11.2011 18:10:00 979 13.07 30.1 20 NA NA
> 28.11.2011 18:20:00 979.2 13.1 30 20 NA NA
> 28.11.2011 18:30:00 979.4 13.09 29.8 20 NA NA
> 28.11.2011 18:40:00 979.5 13.08 29.6 20 NA NA
> 28.11.2011 18:50:00 979.5 13.06 29.5 20 NA NA
> 28.11.2011 19:00:00 979.6 13.06 29.4 20 NA NA
> 28.11.2011 19:10:00 979.7 13.05 29.3 20 NA NA
> 28.11.2011 19:20:00 979.9 13.03 29.2 20 NA NA
> 28.11.2011 19:30:00 980 13 29.1 20 NA NA
> 28.11.2011 19:40:00 980 13.03 29 20 NA NA
> 28.11.2011 19:50:00 980.1 13.03 28.9 20 NA NA
> 28.11.2011 20:00:00 980.3 13  28.8 20 NA NA
> 28.11.2011 20:10:00 980.5 12.97 28.7 20 NA NA
> 28.11.2011 20:20:00 980.8 12.96 28.6 20 NA NA
> 28.11.2011 20:30:00 981.1 12.95 28.5 20 NA NA
> 28.11.2011 20:40:00 981.1 12.95 28.4 20 NA NA
> 28.11.2011 20:50:00 981.2 12.94 28.3 20 NA NA
> 28.11.2011 21:00:00 981.3 12.93 28.2 20 NA NA
> 28.11.2011 21:10:00 981.3 12.92 28.1 20 NA NA
> 28.11.2011 21:20:00 981.5 12.9 28 20 NA NA
> 28.11.2011 21:30:00 981.6 12.927.9 20 NA NA
> 28.11.2011 21:40:00 981.7 12.88 27.9 20 NA NA
> 28.11.2011 21:50:00 981.7 12.87 27.8 20 NA NA
> 28.11.2011 22:00:00 981.7 12.86 27.7 20 NA NA
> 28.11.2011 22:10:00 981.8 12.85 27.6 20 NA NA
> 28.11.2011 22:20:00 981.8 12.84 27.5 20 NA NA
> 28.11.2011 22:30:00 981.8 12.83 27.5 20 NA NA
>
> Thank you
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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 plot with Date/Time showing on x-axis

2016-03-16 Thread PIKAL Petr
Hi

From your data is not clear if your first column is in POSOX format or 
character/factor. You can check it by

?str

If it is POSIX, what is wrong in

with(yourdata, plot(Date/Time, SW))

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kwabena
> Fosu-Amankwah
> Sent: Wednesday, March 16, 2016 4:28 AM
> To: r-help@r-project.org
> Subject: [R] Time series plot with Date/Time showing on x-axis
>
> I would be very grateful if someone can help me with the code or script
> on how to plot a time series plot with Date/Time showing on x-axis for
> the set of data below:
>
> Date/Time PR SW TP  SM SHF CO2
> 28.11.2011 17:39:49 978.4 13.15 30.5 20 NA NA
> 28.11.2011 17:50:00 978.5 13.11 30.4 20 NA NA
> 28.11.2011 18:00:00 978.8 13.14 30.3 20 NA NA
> 28.11.2011 18:10:00 979 13.07 30.1 20 NA NA
> 28.11.2011 18:20:00 979.2 13.1 30 20 NA NA
> 28.11.2011 18:30:00 979.4 13.09 29.8 20 NA NA
> 28.11.2011 18:40:00 979.5 13.08 29.6 20 NA NA
> 28.11.2011 18:50:00 979.5 13.06 29.5 20 NA NA
> 28.11.2011 19:00:00 979.6 13.06 29.4 20 NA NA
> 28.11.2011 19:10:00 979.7 13.05 29.3 20 NA NA
> 28.11.2011 19:20:00 979.9 13.03 29.2 20 NA NA
> 28.11.2011 19:30:00 980 13 29.1 20 NA NA
> 28.11.2011 19:40:00 980 13.03 29 20 NA NA
> 28.11.2011 19:50:00 980.1 13.03 28.9 20 NA NA
> 28.11.2011 20:00:00 980.3 13  28.8 20 NA NA
> 28.11.2011 20:10:00 980.5 12.97 28.7 20 NA NA
> 28.11.2011 20:20:00 980.8 12.96 28.6 20 NA NA
> 28.11.2011 20:30:00 981.1 12.95 28.5 20 NA NA
> 28.11.2011 20:40:00 981.1 12.95 28.4 20 NA NA
> 28.11.2011 20:50:00 981.2 12.94 28.3 20 NA NA
> 28.11.2011 21:00:00 981.3 12.93 28.2 20 NA NA
> 28.11.2011 21:10:00 981.3 12.92 28.1 20 NA NA
> 28.11.2011 21:20:00 981.5 12.9 28 20 NA NA
> 28.11.2011 21:30:00 981.6 12.927.9 20 NA NA
> 28.11.2011 21:40:00 981.7 12.88 27.9 20 NA NA
> 28.11.2011 21:50:00 981.7 12.87 27.8 20 NA NA
> 28.11.2011 22:00:00 981.7 12.86 27.7 20 NA NA
> 28.11.2011 22:10:00 981.8 12.85 27.6 20 NA NA
> 28.11.2011 22:20:00 981.8 12.84 27.5 20 NA NA
> 28.11.2011 22:30:00 981.8 12.83 27.5 20 NA NA
>
> Thank you
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recip

[R] Time series plot with Date/Time showing on x-axis

2016-03-16 Thread Kwabena Fosu-Amankwah
I would be very grateful if someone can help me with the code or
script on how to plot a time series plot with Date/Time showing on
x-axis for the set of data below:

Date/Time PR SW TP  SM SHF CO2
28.11.2011 17:39:49 978.4 13.15 30.5 20 NA NA
28.11.2011 17:50:00 978.5 13.11 30.4 20 NA NA
28.11.2011 18:00:00 978.8 13.14 30.3 20 NA NA
28.11.2011 18:10:00 979 13.07 30.1 20 NA NA
28.11.2011 18:20:00 979.2 13.1 30 20 NA NA
28.11.2011 18:30:00 979.4 13.09 29.8 20 NA NA
28.11.2011 18:40:00 979.5 13.08 29.6 20 NA NA
28.11.2011 18:50:00 979.5 13.06 29.5 20 NA NA
28.11.2011 19:00:00 979.6 13.06 29.4 20 NA NA
28.11.2011 19:10:00 979.7 13.05 29.3 20 NA NA
28.11.2011 19:20:00 979.9 13.03 29.2 20 NA NA
28.11.2011 19:30:00 980 13 29.1 20 NA NA
28.11.2011 19:40:00 980 13.03 29 20 NA NA
28.11.2011 19:50:00 980.1 13.03 28.9 20 NA NA
28.11.2011 20:00:00 980.3 13  28.8 20 NA NA
28.11.2011 20:10:00 980.5 12.97 28.7 20 NA NA
28.11.2011 20:20:00 980.8 12.96 28.6 20 NA NA
28.11.2011 20:30:00 981.1 12.95 28.5 20 NA NA
28.11.2011 20:40:00 981.1 12.95 28.4 20 NA NA
28.11.2011 20:50:00 981.2 12.94 28.3 20 NA NA
28.11.2011 21:00:00 981.3 12.93 28.2 20 NA NA
28.11.2011 21:10:00 981.3 12.92 28.1 20 NA NA
28.11.2011 21:20:00 981.5 12.9 28 20 NA NA
28.11.2011 21:30:00 981.6 12.927.9 20 NA NA
28.11.2011 21:40:00 981.7 12.88 27.9 20 NA NA
28.11.2011 21:50:00 981.7 12.87 27.8 20 NA NA
28.11.2011 22:00:00 981.7 12.86 27.7 20 NA NA
28.11.2011 22:10:00 981.8 12.85 27.6 20 NA NA
28.11.2011 22:20:00 981.8 12.84 27.5 20 NA NA
28.11.2011 22:30:00 981.8 12.83 27.5 20 NA NA

Thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 and Auto.arima

2016-01-31 Thread Lorenzo Isella

Partially the trouble is that the zoo time series is then translated
into a ts object by auto.arima.
In doing so, the series along a regular time grid and some missing
data appear.
To fix this, I should replace each NA with the previous non-NA value.
This is easy enough and the series exhibits some clear cycles: roughly
every month there is a spike, followed by a decrease, then another
spike and so on.
I would like to forecast a couple of cycles (60 steps), but when I do
so with auto.arima, nothing like what I expect appears (the
seasonality is completely lost).
Any idea why?
I paste below the revised R code for reproducibility.

Lorenzo





library(forecast)

tt<-structure(c(1494.5, 1367.57, 1357.57, 1222.23, 1124.02, 1011.64,
4575.64, 3201.87, 3050.04, 2173.38, 1967.88, 1838.55, 1666.05,
1656.05, 1524.96, 835.96, 775.36, 592.36, 494.15, 4058.15, 2624.36,
2448.47, 1598.47, 1398.47, 1264.14, 1165.88, 1053.67, 941.36,
821.36, 471.36, 373.15, 259.91, 3808.91, 2262.26, 1940.39, 1011.39,
800.81, 790.81), index = structure(c(16563L, 16565L, 16570L,
16572L, 16577L, 16579L, 16584L, 16585L, 16586L, 16587L, 16588L,
16589L, 16590L, 16592L, 16593L, 16599L, 16606L, 16607L, 16608L,
16612L, 16613L, 16614L, 16617L, 16618L, 16619L, 16620L, 16621L,
16628L, 16633L, 16635L, 16638L, 16642L, 16647L, 16648L, 16649L,
16650L, 16651L, 16654L), class = "Date"), class = "zoo")

tt2<-as.ts(tt)
tt2<-na.locf(tt2)

mm<-auto.arima(tt2)


plot(forecast(mm, h=60))




On Fri, Jan 29, 2016 at 02:16:27PM -0800, David Winsemius wrote:



On Jan 29, 2016, at 12:59 PM, Lorenzo Isella  wrote:

Dear All,
I am puzzled and probably I am misunderstanding something.
Please consider the snippet at the end of the email.
We see a time series that has clearly some pattern (essentially, it is
an account where a salary is regularly paid followed by some
expenses).
However the output of the auto.arima from the forecast function does
not seem to make any sense (at least to me).
I wonder if the problem is the fact that the time series is not
defined at regular intervals.
Any suggestions and alternative ways to fit it (e.g.: sarima from the astsa
package to account for the seasonality?) are really welcome.
Many thanks

Lorenzo



##
library(forecast)

tt<-structure(c(1494.5, 1367.57, 1357.57, 1222.23, 1124.02, 1011.64,
4575.64, 3201.87, 3050.04, 2173.38, 1967.88, 1838.55, 1666.05,
1656.05, 1524.96, 835.96, 775.36, 592.36, 494.15, 4058.15, 2624.36,
2448.47, 1598.47, 1398.47, 1264.14, 1165.88, 1053.67, 941.36,
821.36, 471.36, 373.15, 259.91, 3808.91, 2262.26, 1940.39, 1011.39,
800.81, 790.81), index = structure(c(16563L, 16565L, 16570L,
16572L, 16577L, 16579L, 16584L, 16585L, 16586L, 16587L, 16588L,
16589L, 16590L, 16592L, 16593L, 16599L, 16606L, 16607L, 16608L,
16612L, 16613L, 16614L, 16617L, 16618L, 16619L, 16620L, 16621L,
16628L, 16633L, 16635L, 16638L, 16642L, 16647L, 16648L, 16649L,
16650L, 16651L, 16654L), class = "Date"), class = "zoo")

plot(tt)



library(forecast)


fit<-auto.arima(tt)

###


If , after runing plot(tt), you then run:

fitted(fit)

Time Series:
Start = 16563
End = 16654
Frequency = 1
[1] 1448.8211NA 1444.8612NANANANA
[8] 1398.7752NA 1359.0350NANANANA
[15] 1309.1398NA 1219.7420NANANANA
[22] 2302.8903 3708.1762 2713.0349 2603.0512 1968.0100 1819.1484 1725.4634
[29]NA 1572.6179 1593.2628NANANANA
[36]NA 1258.3403NANANANANA
[43]NA 1184.9656  955.3023  822.7394NANANA
[50] 1987.7634 .3131 2294.6941NANA 1760.6351 1551.5526
[57] 1406.6751 1309.3682 1238.1899NANANANA
[64]NANA 1251.6898NANANANA
[71] 1179.9970NA  988.3885NANA  888.4533NA
[78]NANA  889.4017NANANANA
[85] 1970.0911 3152.7668 2032.3935 1799.2350 1126.2794NANA
[92] 1088.1525


Using that vector:

lines(seq(16563 ,16654 ),fitted(fit), col="red", lwd=3)

You can see that the fitted values are capturing quite a bit of the variation.



I'm not a regular user of pkg:forecast, so there may be more refined methods of 
extracting information than using `fitted`.

--

David Winsemius
Alameda, CA, USA



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 and Auto.arima

2016-01-29 Thread Lorenzo Isella

Thanks,
But something fishy is going on.
The fitted time series is full of missing values, whereas the original
tt object does not have any.
I suppose that in trying to fit the time series defined on an
irregular time grid, some problem arises inside the auto.arima
function.

Lorenzo

On Fri, Jan 29, 2016 at 02:16:27PM -0800, David Winsemius wrote:



On Jan 29, 2016, at 12:59 PM, Lorenzo Isella  wrote:

Dear All,
I am puzzled and probably I am misunderstanding something.
Please consider the snippet at the end of the email.
We see a time series that has clearly some pattern (essentially, it is
an account where a salary is regularly paid followed by some
expenses).
However the output of the auto.arima from the forecast function does
not seem to make any sense (at least to me).
I wonder if the problem is the fact that the time series is not
defined at regular intervals.
Any suggestions and alternative ways to fit it (e.g.: sarima from the astsa
package to account for the seasonality?) are really welcome.
Many thanks

Lorenzo



##
library(forecast)

tt<-structure(c(1494.5, 1367.57, 1357.57, 1222.23, 1124.02, 1011.64,
4575.64, 3201.87, 3050.04, 2173.38, 1967.88, 1838.55, 1666.05,
1656.05, 1524.96, 835.96, 775.36, 592.36, 494.15, 4058.15, 2624.36,
2448.47, 1598.47, 1398.47, 1264.14, 1165.88, 1053.67, 941.36,
821.36, 471.36, 373.15, 259.91, 3808.91, 2262.26, 1940.39, 1011.39,
800.81, 790.81), index = structure(c(16563L, 16565L, 16570L,
16572L, 16577L, 16579L, 16584L, 16585L, 16586L, 16587L, 16588L,
16589L, 16590L, 16592L, 16593L, 16599L, 16606L, 16607L, 16608L,
16612L, 16613L, 16614L, 16617L, 16618L, 16619L, 16620L, 16621L,
16628L, 16633L, 16635L, 16638L, 16642L, 16647L, 16648L, 16649L,
16650L, 16651L, 16654L), class = "Date"), class = "zoo")

plot(tt)



library(forecast)


fit<-auto.arima(tt)

###


If , after runing plot(tt), you then run:

fitted(fit)

Time Series:
Start = 16563
End = 16654
Frequency = 1
[1] 1448.8211NA 1444.8612NANANANA
[8] 1398.7752NA 1359.0350NANANANA
[15] 1309.1398NA 1219.7420NANANANA
[22] 2302.8903 3708.1762 2713.0349 2603.0512 1968.0100 1819.1484 1725.4634
[29]NA 1572.6179 1593.2628NANANANA
[36]NA 1258.3403NANANANANA
[43]NA 1184.9656  955.3023  822.7394NANANA
[50] 1987.7634 .3131 2294.6941NANA 1760.6351 1551.5526
[57] 1406.6751 1309.3682 1238.1899NANANANA
[64]NANA 1251.6898NANANANA
[71] 1179.9970NA  988.3885NANA  888.4533NA
[78]NANA  889.4017NANANANA
[85] 1970.0911 3152.7668 2032.3935 1799.2350 1126.2794NANA
[92] 1088.1525


Using that vector:

lines(seq(16563 ,16654 ),fitted(fit), col="red", lwd=3)

You can see that the fitted values are capturing quite a bit of the variation.



I'm not a regular user of pkg:forecast, so there may be more refined methods of 
extracting information than using `fitted`.

--

David Winsemius
Alameda, CA, USA



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 and Auto.arima

2016-01-29 Thread David Winsemius

> On Jan 29, 2016, at 12:59 PM, Lorenzo Isella  wrote:
> 
> Dear All,
> I am puzzled and probably I am misunderstanding something.
> Please consider the snippet at the end of the email.
> We see a time series that has clearly some pattern (essentially, it is
> an account where a salary is regularly paid followed by some
> expenses).
> However the output of the auto.arima from the forecast function does
> not seem to make any sense (at least to me).
> I wonder if the problem is the fact that the time series is not
> defined at regular intervals.
> Any suggestions and alternative ways to fit it (e.g.: sarima from the astsa
> package to account for the seasonality?) are really welcome.
> Many thanks
> 
> Lorenzo
> 
> 
> 
> ##
> library(forecast)
> 
> tt<-structure(c(1494.5, 1367.57, 1357.57, 1222.23, 1124.02, 1011.64,
> 4575.64, 3201.87, 3050.04, 2173.38, 1967.88, 1838.55, 1666.05,
> 1656.05, 1524.96, 835.96, 775.36, 592.36, 494.15, 4058.15, 2624.36,
> 2448.47, 1598.47, 1398.47, 1264.14, 1165.88, 1053.67, 941.36,
> 821.36, 471.36, 373.15, 259.91, 3808.91, 2262.26, 1940.39, 1011.39,
> 800.81, 790.81), index = structure(c(16563L, 16565L, 16570L,
> 16572L, 16577L, 16579L, 16584L, 16585L, 16586L, 16587L, 16588L,
> 16589L, 16590L, 16592L, 16593L, 16599L, 16606L, 16607L, 16608L,
> 16612L, 16613L, 16614L, 16617L, 16618L, 16619L, 16620L, 16621L,
> 16628L, 16633L, 16635L, 16638L, 16642L, 16647L, 16648L, 16649L,
> 16650L, 16651L, 16654L), class = "Date"), class = "zoo")
> 
> plot(tt)
> 

library(forecast)

> fit<-auto.arima(tt)
> 
> ###

If , after runing plot(tt), you then run:

 fitted(fit)

Time Series:
Start = 16563 
End = 16654 
Frequency = 1 
 [1] 1448.8211NA 1444.8612NANANANA
 [8] 1398.7752NA 1359.0350NANANANA
[15] 1309.1398NA 1219.7420NANANANA
[22] 2302.8903 3708.1762 2713.0349 2603.0512 1968.0100 1819.1484 1725.4634
[29]NA 1572.6179 1593.2628NANANANA
[36]NA 1258.3403NANANANANA
[43]NA 1184.9656  955.3023  822.7394NANANA
[50] 1987.7634 .3131 2294.6941NANA 1760.6351 1551.5526
[57] 1406.6751 1309.3682 1238.1899NANANANA
[64]NANA 1251.6898NANANANA
[71] 1179.9970NA  988.3885NANA  888.4533NA
[78]NANA  889.4017NANANANA
[85] 1970.0911 3152.7668 2032.3935 1799.2350 1126.2794NANA
[92] 1088.1525


Using that vector:

lines(seq(16563 ,16654 ),fitted(fit), col="red", lwd=3)

You can see that the fitted values are capturing quite a bit of the variation.



I'm not a regular user of pkg:forecast, so there may be more refined methods of 
extracting information than using `fitted`.

-- 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time Series and Auto.arima

2016-01-29 Thread Lorenzo Isella

Dear All,
I am puzzled and probably I am misunderstanding something.
Please consider the snippet at the end of the email.
We see a time series that has clearly some pattern (essentially, it is
an account where a salary is regularly paid followed by some
expenses).
However the output of the auto.arima from the forecast function does
not seem to make any sense (at least to me).
I wonder if the problem is the fact that the time series is not
defined at regular intervals.
Any suggestions and alternative ways to fit it (e.g.: sarima from the astsa
package to account for the seasonality?) are really welcome.
Many thanks

Lorenzo



##
library(forecast)

tt<-structure(c(1494.5, 1367.57, 1357.57, 1222.23, 1124.02, 1011.64,
4575.64, 3201.87, 3050.04, 2173.38, 1967.88, 1838.55, 1666.05,
1656.05, 1524.96, 835.96, 775.36, 592.36, 494.15, 4058.15, 2624.36,
2448.47, 1598.47, 1398.47, 1264.14, 1165.88, 1053.67, 941.36,
821.36, 471.36, 373.15, 259.91, 3808.91, 2262.26, 1940.39, 1011.39,
800.81, 790.81), index = structure(c(16563L, 16565L, 16570L,
16572L, 16577L, 16579L, 16584L, 16585L, 16586L, 16587L, 16588L,
16589L, 16590L, 16592L, 16593L, 16599L, 16606L, 16607L, 16608L,
16612L, 16613L, 16614L, 16617L, 16618L, 16619L, 16620L, 16621L,
16628L, 16633L, 16635L, 16638L, 16642L, 16647L, 16648L, 16649L,
16650L, 16651L, 16654L), class = "Date"), class = "zoo")

plot(tt)

fit<-auto.arima(tt)

###

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time series in spatial regression model (spautolm)

2015-10-09 Thread Tobias Rüttenauer
Dear r-sig-geo team,

I started working with spatial analysis some month ago, so I'm quite new
(and unknowing ) in this field. However, my aim is to connect time series
analysis with spatial analysis, what seems to be quite difficult (to me).

The dataset I am working with a spatial polygons data frame, containing 402
spatial polygons for the years 2007-2011.

In a first step, I want to estimate a SAR model which accounts only for the
spatial autoregressive error term within a year. So what I am basically
trying is to construct a weights list object, containing only weights for
neighbors in the same year (excluding the linkages to the "self" spatial
unit (in different years) and neighboring units in different years). So what
I tried was to expand the original weights matrix by duplicating the
original matrix on the main diagonal while filling all the other linkages
(e.g. linkages between 2007 spatial units and 2008 spatial units) with zero
by the following code:


# Queens links:
> data.nb<-poly2nb(data_subset.spdf)
> 
> # Remove temporal links
> data2.nb<-aggregate(data.nb, data_subset.spdf$id, remove.self = TRUE)
> 
> # Get matrix
> tmp.mat<-nb2mat(data2.nb)
> 
> # Expand matrix
> zero1.mat<-matrix(0, 402, 402)
> zero2.mat<-matrix(0, 402, 402)
> zero3.mat<-matrix(0, 402, 402)
> zero4.mat<-matrix(0, 402, 402)
> zero5.mat<-matrix(0, 402, 402)
> 
> tmp2.mat<-tmp.mat
> tmp3.mat<-tmp.mat
> tmp4.mat<-tmp.mat
> tmp5.mat<-tmp.mat
> 
> row.names(zero1.mat)<-paste("2007", as.numeric(row.names(tmp.mat)), 
> sep="_") row.names(zero2.mat)<-paste("2008", 
> as.numeric(row.names(tmp.mat)), sep="_") 
> row.names(zero3.mat)<-paste("2009", as.numeric(row.names(tmp.mat)), 
> sep="_") row.names(zero4.mat)<-paste("2010", 
> as.numeric(row.names(tmp.mat)), sep="_") 
> row.names(zero5.mat)<-paste("2011", as.numeric(row.names(tmp.mat)), 
> sep="_")
> 
> row.names(tmp.mat)<-paste("2007", as.numeric(row.names(tmp2.mat)), 
> sep="_") row.names(tmp2.mat)<-paste("2008", 
> as.numeric(row.names(tmp2.mat)), sep="_") 
> row.names(tmp3.mat)<-paste("2009", as.numeric(row.names(tmp3.mat)), 
> sep="_") row.names(tmp4.mat)<-paste("2010", 
> as.numeric(row.names(tmp4.mat)), sep="_") 
> row.names(tmp5.mat)<-paste("2011", as.numeric(row.names(tmp5.mat)), 
> sep="_")
> 
> tmp1<-rbind(tmp.mat, zero2.mat, zero3.mat, zero4.mat, zero5.mat) 
> tmp2<-rbind(zero1.mat, tmp2.mat, zero3.mat, zero4.mat, zero5.mat) 
> tmp3<-rbind(zero1.mat, zero2.mat, tmp3.mat, zero4.mat, zero5.mat) 
> tmp4<-rbind(zero1.mat, zero2.mat, zero3.mat, tmp4.mat, zero5.mat) 
> tmp5<-rbind(zero1.mat, zero2.mat, zero3.mat, zero4.mat, tmp5.mat)
> 
> nb.mat<-cbind(tmp1, tmp2, tmp3, tmp4, tmp5)
> 
> data_sub.lw<-mat2listw(data.matrix(nb.mat))
> 
> any(is.na(nb.mat))
[1] FALSE

So I get a weights list object including 2010 observations (5 years with 402
observations, which fits the spatial polygon data frame with 2010
observations), but after running a spautolm model, I get the following error
message:

> spreg.mod<-spautolm(sqrt(fortzuege_gem) ~ v1 + v2,
+ data=data_subset.spdf, listw=data_sub.lw,
weights=area_sqkm, 
+ zero.policy=TRUE)
Error in subset.listw(listw, subset, zero.policy = zero.policy) : 
  Not yet able to subset general weights lists

Elsewhere, it is mentioned that this error messages occurs if the weights
matrix contains missing values, but that's not the case here. I assume that
there is some mistake in creating the weights matrix. Do you have any ideas?


Another thing I was trying to estimate is a SAR model with unit fixed
effects, just by including the id dummies into the equation (for the test I
include the total list weights objects, containing all linkages).

> data_total.nb<-poly2nb(data_subset.spdf)
> data_total.lw<-nb2listw(data.nb, style="W")
> 
> spreg_false.mod<-spautolm(sqrt(fortzuege_gem) ~ id  + v1 + v2,
+ data=data_subset.spdf, listw=data_total.lw,
weights=area_sqkm, 
+ zero.policy=TRUE)
Error in solve.default(crossprod(X, as.matrix(IlW %*% X)), tol = tol.solve)
: 
  system is computationally singular: reciprocal condition number =
1.01026e-16
>

So I assume there occurs some conflict, between using ID dummies and a
weights matrix in one model? Is there any way to solve this problem? This
may be a stupid question for some who is (totally) aware of the mathematics
behind the model. 

I would be really happy about any help!

Thank you in advance and best wishes,
Tobi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time Series Daily Frequency Part of a Year

2015-10-07 Thread zod jones
My data consist of daily sales figures for multiple products but only for a
3 month period each year (Oct., Nov., Dec). The goal is to forecast the
daily sales figures for the following year *by day* (the following Oct.,
Nov., Dec.) So, I'd like to forecast what sales for product X will be on
Nov. 12th of the next year (and each day of those three months), for
example.

I am just conceptually stuck on the fact that the time series is "yearly"
in one sense but the daily observations only occur for those 3 months. The
rest of the year is not really 0 -- the products are not even for sale the
rest of the year (these are tickets for events). The frequency seems like
it should be 92 days.

Hoping someone can just point me in the right direction conceptually.

Thanks,

Zodran

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 exercise (was: (no subject)).

2015-07-10 Thread Rolf Turner

On 10/07/15 21:17, Lia LEE wrote:

Hello forum members,

I am taking this R course which I have to admit that it is beyond my
capability. I am asked to analyze the following data(file attached) according
to the question provided below:

1. The file [data_13-9.txt] contains a data of length 225, which seems to
have some cycle pattern.
(1) Fit a suitable model for this data, then report the model equation.
(2) Provide the forecast values for 3-steps ahead and 6-steps ahead.

I am desperately seeking for your help, since I really don't know where to
start.. I have done plot.ts(data.13-6), but not further. Above question
is just part of the whole task, but I believe solving this would be very
much helpful for me to jump in to the other questions. It would be easier
for me to follow if your answer is in R script..
I appreciate your patience and help.
Thank you so much in advance!


As Bert Gunter said, we don't do homework for people on this list. 
Notwithstanding I couldn't resist having a crack at analysing your time 
series, and I found it, uh, challenging to say the least.  I think of 
myself as having at least *some* skill at fitting time series models, 
and I struggled to find a model that fitted adequately to your data.
(I finally managed to get a decent fit, after trying a number of models 
on a hammer-and-hope basis.)


Perhaps I am even more of a thicko than I think I am.  Nevertheless it 
seems to me that your instructor has dropped you in the deep end by 
setting you this exercise.  (Perhaps I am missing something obvious, as 
is so often the case.  Others may wish to chime in with some comments to 
the effect You idiot Rolf.  The *obvious* model is )


At any rate, your first stop should be your instructor.  Get him or her 
to give you some pointers as to how to get started.  That is what 
instructors are for.


cheers,

Rolf Turner

Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] time series decompose

2015-01-20 Thread catalin roibu
Dear all,

I have a time series (years with n column's) and I want to decompose this
time series in high, low and bandpass components using a n-years filter (in
my case 20 years). Until now I tried many libraries such as mFilter,
signal, spectral.methods, but unfortunately without success.
Please help me to succeed in this problem.

Thank you very much!

Best regards!

Catalin


-- 
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Time series Regression with lags

2014-10-07 Thread jpm miao
Hi,

   I am working on zoo (time series) objects.

   Is there any way to do a time series regression with a lag period?

E.g., Y(t) = b1*X1(t)+b2*X(t-1)+b3*X2(t)

   Is dynlm the default one to use? Anything else

Thanks!

[[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.


[R] Time series analysis for a large number of series

2014-08-09 Thread Trevor Miles
I have over 8000 time series that I need to analyze and forecast. Running 1500 
takes over 2 hours using just ETS, let alone Holt-Winters and ARIMA. So I am 
looking at ways in shrinking the time to generate a 2 year forecast.

The code I am using successfully to run through the time series sequentially is 
below. The essence of the code being reading data from multiple CSV files, 1 
per data set, that contain up to 5 years of historical sales by item. I parse 
each file out by item, generate a time-series for each item, fit the ETS model 
by item, generate a 24 months forecast by item, add the item number to the 
forecast, and write the forecast to an Excel file.

I'm looking for guidance in two areas:

* Reading the raw data in from Excel which is in the form:
 d1d2d3   d4...
series 1  v11   v12  v13  v14
series 2  v21   v22  v23  v24
.
.

* Using parallel processing to analyze the data more quickly using 
several cores.

I have tried to use doParallel at the item level, but without success. I have 
annotated the code to show where I tried to insert the %dopar% aspects.

# store the current directory
initial.dir-getwd()
# change to the new directory
setwd(~/R)
# load the necessary libraries
require(TTR)
require(forecast)
require(xlsx)

#require(doParallel)
#cl - makeCluster(3)
#registerDoSNOW(cl)
#chunks - getDoParWorkers()

# output plots to a file
pdf(R Plots.pdf)
# set the output file
sink(file = R Output.out, type = c(output))

# load the dataset
files - c(3MH, 6MH, 12MH)
for (j in 1:3)
{
  title - paste(\n\n\n Evaluation of, files[j],  - Started at, date(), 
\n\n\n)
  cat(title)

  History - read.csv(paste(files[j],csv, sep=.))

  # output forecast to XLSX
  outwb - createWorkbook()
  sheet - createSheet(outwb, sheetName = paste(files[j],  - ETS))
  Item - unique(unlist(History$Item))

  for (i in 1:length(Item))  # I tried using r - foreach(i=1:length(Item) , 
.combine='rbind') %dopar% at this level
  {
title - paste(Evaluation of item , Item[i], -, i, of, 
length(Item),\n)
cat(title)
data - subset(History, Item == Item[i])
dates - unique(unlist(data$Date))
d - as.Date(dates, format(%d/%m/%Y))
data.ts - ts(data$Volume, frequency=12, 
start=c(as.numeric(format(d[1],%Y)), as.numeric(format(d[1],%m
#try(plot(decompose(data.ts)))
#acf(data.ts)
try(data.ets - ets(data.ts))
try(forecast.ets - forecast.ets(data.ets, h=24))
IL - 
c(Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i],Item[i])
ets.df - data.frame(forecast.ets)
ets.df$Item - IL
r - 24*(i-1)+2
addDataFrame(ets.df, sheet, col.names=FALSE, startRow=r)
  }

  title - paste(\n\n\n Evaluation of, files[j],  - Completed at, date(), 
\n\n\n)
  cat(title)
  saveWorkbook(outwb, paste(files[j],xlsx,sep='.'))
}

# close the output file
sink()
dev.off()
#stopCluster(cl)
# change back to the original directory
setwd(initial.dir)


Trevor Miles
Vice President, Thought Leadership
[http://www.kinaxis.com/email-signature/images/logo-kinaxis.png]http://www.kinaxis.com
O: +1.613.907.7611  |  M: +1.647.248.6269  |  T: 
@MilesAheadhttps://twitter.com/milesahead  |  L: 
ca.linkedin.com/in/trevormileshttp://ca.linkedin.com/in/trevormiles

[Kinexions '14]http://kinexions.kinaxis.com

[http://www2.kinaxis.com/email-signature/images/social-icon-twitter.png]http://twitter.com/kinaxis
  [http://www2.kinaxis.com/email-signature/images/social-icon-facebook.png] 
http://www.facebook.com/Kinaxis   
[http://www2.kinaxis.com/email-signature/images/social-icon-linkedin.png] 
http://www.linkedin.com/company/kinaxis   
[http://www2.kinaxis.com/email-signature/images/social-icon-community.png] 
https://community.kinaxis.com

Confidential. This email and any attachments hereto may contain private, 
confidential, and privileged material for the sole use of the addressee. Any 
review, copying, or distribution of this email (or any attachments thereto) by 
others is strictly prohibited. If you are not the intended recipient, please 
return this email to the sender immediately and permanently delete the original 
and any copies of this email and any of its attachments. Thank you.


[[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.


[R] Time series

2014-06-30 Thread So
Hi There!
I have a time series data for 13 years with freqency of 23 per year. I have
plot the curve on R.
Is it possible to refer to the point inbetween the nodes... 
eg. say the time series ts1 has ts1[1] 0.25 and ts1[2]=0.4. is it possible
to get the time when ts1 reach to 0.3??



--
View this message in context: 
http://r.789695.n4.nabble.com/Time-series-tp4693234.html
Sent from the R help mailing list archive at Nabble.com.

__
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

2014-06-30 Thread PIKAL Petr
Hi

Not much to cook from. Maybe

?approx

Regards
Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of So
 Sent: Monday, June 30, 2014 7:05 AM
 To: r-help@r-project.org
 Subject: [R] Time series

 Hi There!
 I have a time series data for 13 years with freqency of 23 per year. I
 have plot the curve on R.
 Is it possible to refer to the point inbetween the nodes...
 eg. say the time series ts1 has ts1[1] 0.25 and ts1[2]=0.4. is it
 possible to get the time when ts1 reach to 0.3??



 --
 View this message in context: http://r.789695.n4.nabble.com/Time-
 series-tp4693234.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
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

2014-06-03 Thread John Kane
I know essentially nothing about plotting time series so so I just let it pass 
hoping someone with knowledge of time series would help

What were you expecting to get? Just plotting the time series without labels 
etc, since I am getting some weird error messages about pch having a 
“unexpected ',' in  pch=16 and I am too lazy to bother debugging it I get a 
four panel plot (see attached). This does not seem make any sense to me since I 
don't see why Date is plotted, but as I say I know nothing about time series.

However the data did come through okay. Presumably test$Date is a date. It 
reads in as a factor for me which is one reason for using dput() which 
maintains the structure of the data.

Below is what I think your data looks like in dput() format.

Sorry not to be of more help.

test - structure(list(Date = structure(c(15657, 15664, 15678, 15700, 15713, 
15720, 15734, 15741, 15755, 15769, 15783, 15790, 15811, 15832, 15839, 15853, 
15867, 15880, 15895, 15902, 15916, 15930, 15944, 15951, 15958, 15965, 15972, 
15979, 15986, 16000, 16014, 16021, 16028, 16035, 16042, 16049, 16056, 16065, 
16077, 16084, 16091, 16105, 16112, 16126, 16141, 16147, 16154, 16161, 16175, 
16189, 16203), class = Date), Inr = c(2.2, 2.5, 2.4, 2.3, 2.1, 1.9, 1.9, 3.3, 
2.6, 2.7, 3.1, 2.4, 2, 2.5, 2.3, 2.4, 2.3, 2.3, 2.1, 2.4, 3.6, 3, 1.3, 2.6, 
1.9, 3.4, 2.4, 2.2, 2.9, 2.8, 2.1, 2.2, 2.2, 3, 2.7, 2.3, 2.7, 2.9, 2.7, 2.6, 
2.6, 3.3, 2.6, 2.8, 2.9, 3.5, 2.8, 2.7, 2.5, 2.8, 2.3), Wdose = c(30, 32.5, 
32.5, 35, 35, 35, 25, 40, 37.5, 37.5, 37.5, 32.5, 37.5, 35, 35, 35, 35, 35, 35, 
42.5, 40, 35, 25, 40, 32.5, 35, 32.5, 35, 37.5, 35, 35, 37.5, 37.5, 40, 37.5, 
37.5, 40, 40, 40, 40, 37.5, 37.5, 40, 37.5, 40, 40, 32.5, 35, 35, 35, 35), 
Deldose = c(NA, 2.5, 0, 2.5, 0, 0, -10, 15, -2.7, 0, 0, -5, 5, -2.5, 0, 0, 0, 
0, 0, 7.5, -2.5, -5, -10, 15, -7.5, 2.5, -2.5, 2.5, 2.5, -2.5, 0, 2.5, 0, 2.5, 
-2.5, 0, 2.5, 0, 0, 0, -2.5, 0, 2.5, -2.5, 2.5, 0, -7.5, 2.5, 0, 0, 0)), .Names 
= c(Date, Inr, Wdose, Deldose), row.names = c(NA, -51L), class = 
data.frame)


John Kane
Kingston ON Canada

-Original Message-
From: schmtz...@yahoo.com
Sent: Mon, 2 Jun 2014 08:06:33 -0700 (PDT)
To: jrkrid...@inbox.com, r-help@r-project.org
Subject: Re: [R] Time Series

John:

The data that I sent you did you receive it? If so what thoughts or suggestions 
do you have for plotting the time series?

I am not sure what is going wrong and getting multi plot of same.

Thank you

Wayne Schlemitz

schmtz...@yahoo.com

  On Saturday, May 24, 2014 11:34 AM, John Kane jrkrid...@inbox.com wrote:

No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada

 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Time Series
 
 Dear Sir:
 I am trying to plot a time series from the following code:
 
 test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep
 = ;)
 x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
 plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series,
 ylim=c(1.0,4.0),pch=16, col=black)
 
 What I get is multi plots that print 3x across the plot.
 
 Using R 2.15.2-1 on Ubuntu Natty
 Attached is the raw data.
 
 Thank you for any suggestions.
 Wayne
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help 
 [https://stat.ethz.ch/mailman/listinfo/r-help]
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html 
 [http://www.r-project.org/posting-guide.html]
 and provide commented, minimal, self-contained, reproducible code.


Protect your computer files with professional cloud backup.
Get PCRx Backup and upload unlimited files automatically. 
Learn more at http://backup.pcrx.com/mail [http://backup.pcrx.com/mail]


Protect your computer files with professional cloud backup.
Get PCRx Backup and upload unlimited files automatically. 
Learn more at http://backup.pcrx.com/mail
__
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

2014-06-03 Thread Bastian Pöschl
It would be great to get a detailed question.

As far as I understood you wanted to plot your series in a single frame.
There are plenty examples in the help of plot.ts and plot.zoo for that.
I prefer working with time series be using the zoo package. But most things
can also be done within ts.
The packages lattice and ggplot2 offer further styles for plots

Try this:

library(zoo)
test - structure(list(Date = structure(c(15657, 15664, 15678, 15700,
15713, 15720, 15734, 15741, 15755, 15769, 15783, 15790, 15811, 15832,
15839, 15853, 15867, 15880, 15895, 15902, 15916, 15930, 15944, 15951,
15958, 15965, 15972, 15979, 15986, 16000, 16014, 16021, 16028, 16035,
16042, 16049, 16056, 16065, 16077, 16084, 16091, 16105, 16112, 16126,
16141, 16147, 16154, 16161, 16175, 16189, 16203), class = Date), Inr =
c(2.2, 2.5, 2.4, 2.3, 2.1, 1.9, 1.9, 3.3, 2.6, 2.7, 3.1, 2.4, 2, 2.5, 2.3,
2.4, 2.3, 2.3, 2.1, 2.4, 3.6, 3, 1.3, 2.6, 1.9, 3.4, 2.4, 2.2, 2.9, 2.8,
2.1, 2.2, 2.2, 3, 2.7, 2.3, 2.7, 2.9, 2.7, 2.6, 2.6, 3.3, 2.6, 2.8, 2.9,
3.5, 2.8, 2.7, 2.5, 2.8, 2.3), Wdose = c(30, 32.5, 32.5, 35, 35, 35, 25,
40, 37.5, 37.5, 37.5, 32.5, 37.5, 35, 35, 35, 35, 35, 35, 42.5, 40, 35, 25,
40, 32.5, 35, 32.5, 35, 37.5, 35, 35, 37.5, 37.5, 40, 37.5, 37.5, 40, 40,
40, 40, 37.5, 37.5, 40, 37.5, 40, 40, 32.5, 35, 35, 35, 35), Deldose =
c(NA, 2.5, 0, 2.5, 0, 0, -10, 15, -2.7, 0, 0, -5, 5, -2.5, 0, 0, 0, 0, 0,
7.5, -2.5, -5, -10, 15, -7.5, 2.5, -2.5, 2.5, 2.5, -2.5, 0, 2.5, 0, 2.5,
-2.5, 0, 2.5, 0, 0, 0, -2.5, 0, 2.5, -2.5, 2.5, 0, -7.5, 2.5, 0, 0, 0)),
.Names = c(Date, Inr, Wdose, Deldose), row.names = c(NA, -51L),
class = data.frame)
test_zoo-zoo(test[,2:3],test[,1])

plot(test_zoo) ## read ?plot.zoo or ?plot.ts

plot(test_zoo, plot.type = single) ## there is a option for plotting both
series in one frame

## Secondary y-axis and ticks are a bit tricky and in most cases you have
to adjust them by hand
plot(test_zoo[,1], ylim=range(pretty(c(0, test_zoo[,1]))), xlab=,
ylab=, col=blue)
yaxp3-(par(yaxp)[3])
abline(h=seq(par(yaxp)[1], par(yaxp)[2],
(par(yaxp)[2]-par(yaxp)[1])/par(yaxp)[3]), lty=6, col = grey)
par(bty=n, new=T)
niceticks-c(0:(yaxp3)*(pretty(c(0, test_zoo[,2]),
n=yaxp3-1)[2]-pretty(c(0, test_zoo[,1]), n=yaxp3-1)[1]))
plot(test_zoo[,2], lty=2, yaxt=n, xaxt=n, col=red, ann=FALSE,
xlim=c(start(test_zoo),end(test_zoo)), ylim=range(0,max(niceticks)))
axis(4, at=niceticks)
par(bty=o, new=F)



2014-06-03 15:26 GMT+02:00 John Kane jrkrid...@inbox.com:

 I know essentially nothing about plotting time series so so I just let it
 pass hoping someone with knowledge of time series would help

 What were you expecting to get? Just plotting the time series without
 labels etc, since I am getting some weird error messages about pch having a
 “unexpected ',' in  pch=16 and I am too lazy to bother debugging it I
 get a four panel plot (see attached). This does not seem make any sense to
 me since I don't see why Date is plotted, but as I say I know nothing about
 time series.

 However the data did come through okay. Presumably test$Date is a date. It
 reads in as a factor for me which is one reason for using dput() which
 maintains the structure of the data.

 Below is what I think your data looks like in dput() format.

 Sorry not to be of more help.

 test - structure(list(Date = structure(c(15657, 15664, 15678, 15700,
 15713, 15720, 15734, 15741, 15755, 15769, 15783, 15790, 15811, 15832,
 15839, 15853, 15867, 15880, 15895, 15902, 15916, 15930, 15944, 15951,
 15958, 15965, 15972, 15979, 15986, 16000, 16014, 16021, 16028, 16035,
 16042, 16049, 16056, 16065, 16077, 16084, 16091, 16105, 16112, 16126,
 16141, 16147, 16154, 16161, 16175, 16189, 16203), class = Date), Inr =
 c(2.2, 2.5, 2.4, 2.3, 2.1, 1.9, 1.9, 3.3, 2.6, 2.7, 3.1, 2.4, 2, 2.5, 2.3,
 2.4, 2.3, 2.3, 2.1, 2.4, 3.6, 3, 1.3, 2.6, 1.9, 3.4, 2.4, 2.2, 2.9, 2.8,
 2.1, 2.2, 2.2, 3, 2.7, 2.3, 2.7, 2.9, 2.7, 2.6, 2.6, 3.3, 2.6, 2.8, 2.9,
 3.5, 2.8, 2.7, 2.5, 2.8, 2.3), Wdose = c(30, 32.5, 32.5, 35, 35, 35, 25,
 40, 37.5, 37.5, 37.5, 32.5, 37.5, 35, 35, 35, 35, 35, 35, 42.5, 40, 35, 25,
 40, 32.5, 35, 32.5, 35, 37.5, 35, 35, 37.5, 37.5, 40, 37.5, 37.5, 40, 40,
 40, 40, 37.5, 37.5, 40, 37.5, 40, 40, 32.5, 35, 35, 35, 35), Deldose =
 c(NA, 2.5, 0, 2.5, 0, 0, -10, 15, -2.7, 0, 0, -5, 5, -2.5, 0, 0, 0, 0, 0,
 7.5, -2.5, -5, -10, 15, -7.5, 2.5, -2.5, 2.5, 2.5, -2.5, 0, 2.5, 0, 2.5,
 -2.5, 0, 2.5, 0, 0, 0, -2.5, 0, 2.5, -2.5, 2.5, 0, -7.5, 2.5, 0, 0, 0)),
 .Names = c(Date, Inr, Wdose, Deldose), row.names = c(NA, -51L),
 class = data.frame)


 John Kane
 Kingston ON Canada

 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Mon, 2 Jun 2014 08:06:33 -0700 (PDT)
 To: jrkrid...@inbox.com, r-help@r-project.org
 Subject: Re: [R] Time Series

 John:

 The data that I sent you did you receive it? If so what thoughts or
 suggestions do you have for plotting the time series?

 I am not sure what is going wrong and getting multi plot of same.

 Thank you

 Wayne Schlemitz

 schmtz...@yahoo.com

Re: [R] Time Series

2014-06-03 Thread Duncan Mackay
Not sure where things are up to in the thread but this may illuminate things
Using the test data.frame
from an old thread I was just looking at
https://stat.ethz.ch/pipermail/r-help/2007-May/133033.html

ylabGrob -
function(...) { # ...is lab1, lab2, etc
labs - lapply(list(...), textGrob, rot = 90)
nlabs - length(labs)
lab.widths -
lapply(labs,
function(lab) unit(1, grobwidth, data = list(lab)))
lab.layout -
grid.layout(ncol = 1,
nrow = nlabs,
heights = unit(1, null),
widths = do.call(max, lab.widths), respect = TRUE)
lab.gf - frameGrob(layout = lab.layout)
for (i in seq_len(nlabs)) {
lab.gf - placeGrob(lab.gf, labs[[i]], row = i, col = 1)
}
lab.gf
}

xyplot(Wdose+Deldose ~ Date, test,
   outer = T,
   strip.left = T,
   strip = F,
   layout = c(1,2),
   ylab = ylabGrob(Del units,Win units),
   par.settings = list(strip.background = list(col = transparent)),
   scales   = list(x = list(alternating = FALSE,
relation= same,
rot = 0),
   y = list(alternating = FALSE,
 relation= same,
 rot = 0)
  ))

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of John Kane
Sent: Tuesday, 3 June 2014 23:27
To: wayne schlemitz; r-help@R-project.org
Subject: Re: [R] Time Series

I know essentially nothing about plotting time series so so I just let it pass 
hoping someone with knowledge of time series would help

What were you expecting to get? Just plotting the time series without labels 
etc, since I am getting some weird error messages about pch having a 
“unexpected ',' in  pch=16 and I am too lazy to bother debugging it I get a 
four panel plot (see attached). This does not seem make any sense to me since I 
don't see why Date is plotted, but as I say I know nothing about time series.

However the data did come through okay. Presumably test$Date is a date. It 
reads in as a factor for me which is one reason for using dput() which 
maintains the structure of the data.

Below is what I think your data looks like in dput() format.

Sorry not to be of more help.

test - structure(list(Date = structure(c(15657, 15664, 15678, 15700, 15713, 
15720, 15734, 15741, 15755, 15769, 15783, 15790, 15811, 15832, 15839, 15853, 
15867, 15880, 15895, 15902, 15916, 15930, 15944, 15951, 15958, 15965, 15972, 
15979, 15986, 16000, 16014, 16021, 16028, 16035, 16042, 16049, 16056, 16065, 
16077, 16084, 16091, 16105, 16112, 16126, 16141, 16147, 16154, 16161, 16175, 
16189, 16203), class = Date), Inr = c(2.2, 2.5, 2.4, 2.3, 2.1, 1.9, 1.9, 3.3, 
2.6, 2.7, 3.1, 2.4, 2, 2.5, 2.3, 2.4, 2.3, 2.3, 2.1, 2.4, 3.6, 3, 1.3, 2.6, 
1.9, 3.4, 2.4, 2.2, 2.9, 2.8, 2.1, 2.2, 2.2, 3, 2.7, 2.3, 2.7, 2.9, 2.7, 2.6, 
2.6, 3.3, 2.6, 2.8, 2.9, 3.5, 2.8, 2.7, 2.5, 2.8, 2.3), Wdose = c(30, 32.5, 
32.5, 35, 35, 35, 25, 40, 37.5, 37.5, 37.5, 32.5, 37.5, 35, 35, 35, 35, 35, 35, 
42.5, 40, 35, 25, 40, 32.5, 35, 32.5, 35, 37.5, 35, 35, 37.5, 37.5, 40, 37.5, 
37.5, 40, 40, 40, 40, 37.5, 37.5, 40, 37.5, 40, 40, 32.5, 35, 35, 35, 35), 
Deldose = c(NA, 2.5, 0, 2.5, 0, 0, -10, 15, -2.7, 0, 0, -5, 5, -2.5, 0, 0, 0, 
0, 0, 7.5, -2.5, -5, -10, 15, -7.5, 2.5, -2.5, 2.5, 2.5, -2.5, 0, 2.5, 0, 2.5, 
-2.5, 0, 2.5, 0, 0, 0, -2.5, 0, 2.5, -2.5, 2.5, 0, -7.5, 2.5, 0, 0, 0)), .Names 
= c(Date, Inr, Wdose, Deldose), row.names = c(NA, -51L), class = 
data.frame)


John Kane
Kingston ON Canada

-Original Message-
From: schmtz...@yahoo.com
Sent: Mon, 2 Jun 2014 08:06:33 -0700 (PDT)
To: jrkrid...@inbox.com, r-help@r-project.org
Subject: Re: [R] Time Series

John:

The data that I sent you did you receive it? If so what thoughts or suggestions 
do you have for plotting the time series?

I am not sure what is going wrong and getting multi plot of same.

Thank you

Wayne Schlemitz

schmtz...@yahoo.com

  On Saturday, May 24, 2014 11:34 AM, John Kane jrkrid...@inbox.com wrote:

No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada

 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Time Series
 
 Dear Sir:
 I am trying to plot a time series from the following code:
 
 test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep
 = ;)
 x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
 plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series,
 ylim=c(1.0,4.0),pch=16, col=black)
 
 What I get is multi plots that print 3x across the plot.
 
 Using R 2.15.2-1 on Ubuntu Natty
 Attached is the raw data.
 
 Thank you for any suggestions.
 Wayne
 __
 R-help@r

Re: [R] Time Series

2014-06-03 Thread arun


Hi Wayne,

As John mentioned, it is not clear about your expectations.  May be this helps:
library(xts)
x2New - xts(test[,-1], order.by=test[,1])
library(xtsExtra)
plot(x2New,screens=1,auto.legend=TRUE)

A.K.




On Tuesday, June 3, 2014 9:29 AM, John Kane jrkrid...@inbox.com wrote:
I know essentially nothing about plotting time series so so I just let it pass 
hoping someone with knowledge of time series would help

What were you expecting to get? Just plotting the time series without labels 
etc, since I am getting some weird error messages about pch having a 
“unexpected ',' in  pch=16 and I am too lazy to bother debugging it I get a 
four panel plot (see attached). This does not seem make any sense to me since I 
don't see why Date is plotted, but as I say I know nothing about time series.

However the data did come through okay. Presumably test$Date is a date. It 
reads in as a factor for me which is one reason for using dput() which 
maintains the structure of the data.

Below is what I think your data looks like in dput() format.

Sorry not to be of more help.

test - structure(list(Date = structure(c(15657, 15664, 15678, 15700, 15713, 
15720, 15734, 15741, 15755, 15769, 15783, 15790, 15811, 15832, 15839, 15853, 
15867, 15880, 15895, 15902, 15916, 15930, 15944, 15951, 15958, 15965, 15972, 
15979, 15986, 16000, 16014, 16021, 16028, 16035, 16042, 16049, 16056, 16065, 
16077, 16084, 16091, 16105, 16112, 16126, 16141, 16147, 16154, 16161, 16175, 
16189, 16203), class = Date), Inr = c(2.2, 2.5, 2.4, 2.3, 2.1, 1.9, 1.9, 3.3, 
2.6, 2.7, 3.1, 2.4, 2, 2.5, 2.3, 2.4, 2.3, 2.3, 2.1, 2.4, 3.6, 3, 1.3, 2.6, 
1.9, 3.4, 2.4, 2.2, 2.9, 2.8, 2.1, 2.2, 2.2, 3, 2.7, 2.3, 2.7, 2.9, 2.7, 2.6, 
2.6, 3.3, 2.6, 2.8, 2.9, 3.5, 2.8, 2.7, 2.5, 2.8, 2.3), Wdose = c(30, 32.5, 
32.5, 35, 35, 35, 25, 40, 37.5, 37.5, 37.5, 32.5, 37.5, 35, 35, 35, 35, 35, 35, 
42.5, 40, 35, 25, 40, 32.5, 35, 32.5, 35, 37.5, 35, 35, 37.5, 37.5, 40, 37.5, 
37.5, 40, 40, 40, 40, 37.5, 37.5, 40, 37.5, 40, 40, 32.5, 35, 35, 35, 35), 
Deldose = c(NA, 2.5, 0, 2.5, 0, 0, -10,
 15, -2.7, 0, 0, -5, 5, -2.5, 0, 0, 0, 0, 0, 7.5, -2.5, -5, -10, 15, -7.5, 2.5, 
-2.5, 2.5, 2.5, -2.5, 0, 2.5, 0, 2.5, -2.5, 0, 2.5, 0, 0, 0, -2.5, 0, 2.5, 
-2.5, 2.5, 0, -7.5, 2.5, 0, 0, 0)), .Names = c(Date, Inr, Wdose, 
Deldose), row.names = c(NA, -51L), class = data.frame)


John Kane
Kingston ON Canada

-Original Message-
From: schmtz...@yahoo.com
Sent: Mon, 2 Jun 2014 08:06:33 -0700 (PDT)
To: jrkrid...@inbox.com, r-help@r-project.org
Subject: Re: [R] Time Series

John:

The data that I sent you did you receive it? If so what thoughts or suggestions 
do you have for plotting the time series?

I am not sure what is going wrong and getting multi plot of same.

Thank you

Wayne Schlemitz

schmtz...@yahoo.com

  On Saturday, May 24, 2014 11:34 AM, John Kane jrkrid...@inbox.com wrote:

No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada

 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Time Series
 
 Dear Sir:
 I am trying to plot a time series from the following code:
 
 test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep
 = ;)
 x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
 plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series,
 ylim=c(1.0,4.0),pch=16, col=black)
 
 What I get is multi plots that print 3x across the plot.
 
 Using R 2.15.2-1 on Ubuntu Natty
 Attached is the raw data.
 
 Thank you for any suggestions.
 Wayne
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help 
 [https://stat.ethz.ch/mailman/listinfo/r-help]
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html 
 [http://www.r-project.org/posting-guide.html]
 and provide commented, minimal, self-contained, reproducible code.


Protect your computer files with professional cloud backup.
Get PCRx Backup and upload unlimited files automatically. 
Learn more at http://backup.pcrx.com/mail [http://backup.pcrx.com/mail]


Protect your computer files with professional cloud backup.
Get PCRx Backup and upload unlimited files automatically. 
Learn more at http://backup.pcrx.com/mail
__
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.


Re: [R] Time Series

2014-06-02 Thread wayne schlemitz

John:

The data that I sent you did you receive it? If so what thoughts or suggestions 
do you have for plotting the time series?

I am not sure what is going wrong and getting multi plot of same.

Thank you
Wayne Schlemitz
schmtz...@yahoo.com



On Saturday, May 24, 2014 11:34 AM, John Kane jrkrid...@inbox.com wrote:
 


No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada


 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Time Series
 
 Dear Sir:
 I am trying to plot a time series from the following code:
 
 test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep
 = ;)
 x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
 plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series,
 ylim=c(1.0,4.0),pch=16, col=black)
 
 What I get is multi plots that print 3x across the plot.
 
 Using R 2.15.2-1 on Ubuntu Natty
 Attached is the raw data.
 
 Thank you for any suggestions.
 Wayne
 __
 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.


Protect your computer files with professional cloud backup.

Learn more at http://backup.pcrx.com/mail
[[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

2014-05-24 Thread John Kane
No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada


 -Original Message-
 From: schmtz...@yahoo.com
 Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Time Series
 
 Dear Sir:
 I am trying to plot a time series from the following code:
 
 test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep
 = ;)
 x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
 plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series,
 ylim=c(1.0,4.0),pch=16, col=black)
 
 What I get is multi plots that print 3x across the plot.
 
 Using R 2.15.2-1 on Ubuntu Natty
 Attached is the raw data.
 
 Thank you for any suggestions.
 Wayne
 __
 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.


Protect your computer files with professional cloud backup.
Get PCRx Backup and upload unlimited files automatically. 
Learn more at http://backup.pcrx.com/mail

__
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] Time Series

2014-05-23 Thread wayne schlemitz
Dear Sir:
I am trying to plot a time series from the following code:

test - read.table(/home/wayne/inr2a.txt, header = TRUE, quote=, sep = ;) 
x2 - ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
plot.ts(x2, xlab=Date, ylab=Inr, main=X2 - Time Series, 
ylim=c(1.0,4.0),pch=16, col=black)

What I get is multi plots that print 3x across the plot.

Using R 2.15.2-1 on Ubuntu Natty
Attached is the raw data.

Thank you for any suggestions.
Wayne__
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] Time Series Decomposition On Zoo Objects: Errors

2014-04-03 Thread Rich Shepard

  I have irregular time series as zoo objects; one example:

structure(c(6, 5, 14, 9, 8, 9, 8, 5, 5, 5, 3, 3, 4, 3, 9, 6.94, 
7.44, 3.09, 0.84, 5.35, 4.76, 4.21, 1.58, 2.6, 3.41, 9.59, 7.1, 
5, 5, 5, 3, 1.5, 2.4, 3.9, 5.8, 2.3, 3.6, 4.1, 15.4, 7.8, 4.2, 
5.8, 3, 4.5, 8.1, 9.6, 9.3, 7.9, 3.8, 3.2, 3.6, 8.4, 10.5, 8.7, 
7.9, 3.1, 2.7, 3.7, 3.7, 2.9, 3.6, 2.3, 2, 1), index = structure(c(8147, 
8177, 8345, 8428, 8449, 8462, 8474, 8498, 8520, 8531, 8547, 8561, 
8576, 8590, 8612, 8852, 8862, 8881, 8912, 8939, 9231, 9249, 9280, 
9304, 9337, 9468, 9511, 9623, 9652, 9679, 9981, 9995, 10028, 
10071, 10371, 10374, 10434, 10484, 10520, 10554, 10721, 10736, 
10764, 10794, 10904, 10926, 11020, 11026, 11068, 11086, 11136, 
11288, 11298, 11369, 11388, 11442, 11453, 11498, 11811, 11859, 
12175, 12218, 12597, 12600), class = Date), class = zoo)


  They appear to have seasonal variation and a trend. When I try to decompose
them using stl() I get an error about missing values:

s95so4.stl - stl(s95so4.z)
Error in na.fail.default(as.ts(x)) : missing values in object

  The s.window option might be applicable, but it seems to me that
specifying 'periodic' for an irregular time series is inappropriate (in any
case, it still produces the same error message), and I don't know what would
be an appropriate span (in lags) for the loess window.

  I would like to learn how to decompose such irregular (zoo) time series
into seasonal variation, trend, and residual errors so I can apply
regressions (using lm()) to pairs that ought to be related.

  Would StructTS() be the appropriate function for these data?

Rich

__
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 Decomposition On Zoo Objects: Errors

2014-04-03 Thread Rich Shepard

On Thu, 3 Apr 2014, arun wrote:


Not sure if this helps you.
http://stackoverflow.com/questions/12623027/how-to-analyse-irregular-time-series-in-r


A.K.,

  Yes, it does. I've read all the zoo docs I can find and have been
searching for more information on irregular time series data. Environmental
data, unlike financial or economic data (or the examples in books and R help
pages) is always sloppy and irregular. Wish there was a book or monograph on
these data.

Thanks very much,

Rich

--
Richard B. Shepard, Ph.D.  |  Have knowledge, will travel.
Applied Ecosystem Services, Inc.   |
www.appl-ecosys.com  Voice: 503-667-4517 Fax: 503-667-8863

__
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 Decomposition On Zoo Objects: Errors

2014-04-03 Thread Roy Mendelssohn
HI Rich:

How irregular is irregular.  kalman filter based methods, such as those in KFAS 
and DLM, can handle missing data, and often irregular data can be thought of 
as regular data with missing values,  A lot depends on how irregular and how 
big the gaps, to the point where the analysis can be calculated but is not very 
meaningful.

Don't know if this helps.

-Roy M.

On Apr 3, 2014, at 2:25 PM, Rich Shepard rshep...@appl-ecosys.com wrote:

 On Thu, 3 Apr 2014, arun wrote:
 
 Not sure if this helps you.
 http://stackoverflow.com/questions/12623027/how-to-analyse-irregular-time-series-in-r
 
 A.K.,
 
  Yes, it does. I've read all the zoo docs I can find and have been
 searching for more information on irregular time series data. Environmental
 data, unlike financial or economic data (or the examples in books and R help
 pages) is always sloppy and irregular. Wish there was a book or monograph on
 these data.
 
 Thanks very much,
 
 Rich
 
 -- 
 Richard B. Shepard, Ph.D.  |  Have knowledge, will travel.
 Applied Ecosystem Services, Inc.   |
 www.appl-ecosys.com  Voice: 503-667-4517 Fax: 503-667-8863
 
 __
 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.

**
The contents of this message do not reflect any position of the U.S. 
Government or NOAA.
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.
From those who have been given much, much will be expected 
the arc of the moral universe is long, but it bends toward justice -MLK Jr.

__
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 Decomposition On Zoo Objects: Errors

2014-04-03 Thread Rich Shepard

On Thu, 3 Apr 2014, Roy Mendelssohn wrote:


How irregular is irregular. kalman filter based methods, such as those in
KFAS and DLM, can handle missing data, and often irregular data can be
thought of as regular data with missing values, A lot depends on how
irregular and how big the gaps, to the point where the analysis can be
calculated but is not very meaningful.


Roy,

  The degree of irregularity varies with the data set. It varies greatly.
Sometimes, monthly samples are missed because the streambed is dry, or
because there are several meters of snow on top of the channel. Sometimes
regulators have permit holders stop analyzing for a chemical constituent,
then there's an agency staff change and that constituent is back on the list
of chemicals to be monitored. Some times fish are present, other times
they're not.


Don't know if this helps.


  Yes, it does. I'll read up on Kalman filters, on state-space models with
missing data modifications in Shumway  Stoffer (3rd Ed.), and on gamm.

Thanks,

Rich

__
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 Decomposition On Zoo Objects: Errors

2014-04-03 Thread Roy Mendelssohn
The state-space approach has the advantage in the appropriate situations that  
you can model the trends and seasonals and cycles in a way that doesn't assume 
stationarity and provides a lot of flexibility.  To me a lot of it depends on 
if the nature of the irregularity is an inherent property of the data 
themselves or of the observation process - for example if it makes sense to say 
the physical observable is there every month but we just have not been able to 
observe.  I have fit state-space models to reasonably sparse data with what 
appear to be good results.  

If you want I can send you some examples off-line.

-Roy


On Apr 3, 2014, at 2:54 PM, Rich Shepard rshep...@appl-ecosys.com wrote:

 On Thu, 3 Apr 2014, Roy Mendelssohn wrote:
 
 How irregular is irregular. kalman filter based methods, such as those in
 KFAS and DLM, can handle missing data, and often irregular data can be
 thought of as regular data with missing values, A lot depends on how
 irregular and how big the gaps, to the point where the analysis can be
 calculated but is not very meaningful.
 
 Roy,
 
  The degree of irregularity varies with the data set. It varies greatly.
 Sometimes, monthly samples are missed because the streambed is dry, or
 because there are several meters of snow on top of the channel. Sometimes
 regulators have permit holders stop analyzing for a chemical constituent,
 then there's an agency staff change and that constituent is back on the list
 of chemicals to be monitored. Some times fish are present, other times
 they're not.
 
 Don't know if this helps.
 
  Yes, it does. I'll read up on Kalman filters, on state-space models with
 missing data modifications in Shumway  Stoffer (3rd Ed.), and on gamm.
 
 Thanks,
 
 Rich
 
 __
 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.

**
The contents of this message do not reflect any position of the U.S. 
Government or NOAA.
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.
From those who have been given much, much will be expected 
the arc of the moral universe is long, but it bends toward justice -MLK Jr.

__
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 Decomposition On Zoo Objects: Errors

2014-04-03 Thread Rich Shepard

On Thu, 3 Apr 2014, Roy Mendelssohn wrote:


The state-space approach has the advantage in the appropriate situations
that you can model the trends and seasonals and cycles in a way that
doesn't assume stationarity and provides a lot of flexibility. To me a lot
of it depends on if the nature of the irregularity is an inherent property
of the data themselves or of the observation process - for example if it
makes sense to say the physical observable is there every month but we
just have not been able to observe. I have fit state-space models to
reasonably sparse data with what appear to be good results.


Roy,

  Hadn't thought about the nature of the irregularity. For all my data, the
nature is observational. Water and air chemistry (and physical parameters
such as flow and temperature) are always there. Biota might be different.
Plants tend to not move too quickly so they're always present ... or not.
But, animals (aquatic and terrestrial) may not be present or may be present
but not observed.


If you want I can send you some examples off-line.


  That would be much appreciated.

Thanks,

Rich

__
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] Time series

2014-04-02 Thread Marlin Keith Cox
A simplified ask is:  when I use the time series plot function, R treats
each time on 9/19/13 as an individual day, when clearly it isn't.

Thank you ahead of time.  Keith

ts(chum)
with(chum,plot.ts(Time,PA))

Chum-

  Time PA  9/18/13 18:29 16  9/19/13 13:29 14  9/19/13 16:29 13.2  9/19/13
17:29 13.1  9/19/13 18:29 13  9/20/13 18:29 12  9/21/13 18:29 10  9/22/13
18:29 9  9/23/13 18:29 7  9/24/13 18:29 5  9/25/13 18:29 3  9/26/13
18:29 2  9/27/13
18:29 1


M. Keith Cox, Ph.D.
Principal
MKConsulting
17105 Glacier Hwy
Juneau, AK 99801
U.S. 907.957.4606

[[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

2014-04-02 Thread Achim Zeileis

On Tue, 1 Apr 2014, Marlin Keith Cox wrote:


A simplified ask is:  when I use the time series plot function, R treats
each time on 9/19/13 as an individual day, when clearly it isn't.


The ts class can handle only regular time series. See the zoo or xts 
packages for dealing with time series that have an irregular time index. 
Here, you could use POSIXct or chron time stamps.



Thank you ahead of time.  Keith

ts(chum)
with(chum,plot.ts(Time,PA))

Chum-

 Time PA  9/18/13 18:29 16  9/19/13 13:29 14  9/19/13 16:29 13.2  9/19/13
17:29 13.1  9/19/13 18:29 13  9/20/13 18:29 12  9/21/13 18:29 10  9/22/13
18:29 9  9/23/13 18:29 7  9/24/13 18:29 5  9/25/13 18:29 3  9/26/13
18:29 2  9/27/13
18:29 1


M. Keith Cox, Ph.D.
Principal
MKConsulting
17105 Glacier Hwy
Juneau, AK 99801
U.S. 907.957.4606

[[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.



__
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

2014-04-02 Thread Pascal Oettli
Hello Keith,

Your example is clearly not reproducible and wrong (Chum and chum).
Please use dput() to attach sample dataset.
At first glance, you work with hourly data. Package such as xts
might be more useful.

Regards,
Pascal

On Wed, Apr 2, 2014 at 3:16 PM, Marlin Keith Cox marlink...@gmail.com wrote:
 A simplified ask is:  when I use the time series plot function, R treats
 each time on 9/19/13 as an individual day, when clearly it isn't.

 Thank you ahead of time.  Keith

 ts(chum)
 with(chum,plot.ts(Time,PA))

 Chum-

   Time PA  9/18/13 18:29 16  9/19/13 13:29 14  9/19/13 16:29 13.2  9/19/13
 17:29 13.1  9/19/13 18:29 13  9/20/13 18:29 12  9/21/13 18:29 10  9/22/13
 18:29 9  9/23/13 18:29 7  9/24/13 18:29 5  9/25/13 18:29 3  9/26/13
 18:29 2  9/27/13
 18:29 1


 M. Keith Cox, Ph.D.
 Principal
 MKConsulting
 17105 Glacier Hwy
 Juneau, AK 99801
 U.S. 907.957.4606

 [[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.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
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 processing - count of datestamp delta's, per group

2014-03-24 Thread Martin Tomko
Dear Stephen,
Thank you for your suggestion - I will give it a try. It looks like going
in the right direction with the by() function, but your assumption about
the successive observations is incorrect:

I want all the date differences between successive observations of each
separate user.²

So I tried to modify the function foo as follows:
foo2 - with(dataset,by(Date,User,function(yy)diff(yy)))

The structure of the resulting object is:

structure(list(A = structure(c(0, 3, 75, 41, 4, 6, 7, 19, 16,
30, 0, 3), units = days, class = difftime), B = structure(c(6,
53, 14, 8, 7, 5, 3, 0, 15, 3, 10, 24, 13, 1, 7, 21, 11, 5, 9,
28, 11, 3, 18, 12), units = days, class = difftime), C =
structure(c(8, 
11, 4, 1, 12, 37, 17, 4, 9, 13, 18, 24, 23, 24, 15, 42, 6, 34
), units = days, class = difftime), D = structure(c(2, 16,
15, 18, 14, 2, 19, 8, 35, 9, 2, 28, 11, 3, 1, 1, 13, 28, 15,
9, 30, 5, 1, 16, 22), units = days, class = difftime), E =
structure(c(10, 
30, 6, 20, 13, 7, 80, 32, 14, 57, 20, 3, 9, 0, 24, 0), units = days,
class = difftime)), .Dim = 5L, .Dimnames = structure(list(
User = c(A, B, C, D, E)), .Names = User), call =
quote(by.default(data = Date,
INDICES = User, FUN = function(yy) diff(yy))), class = by)


I can access it as: foo2$A for example.

I have then used the following approach to unlisting them:
x - unlist(foo2)
hist(x)
table(x)


This seems to do what I was after - thanks for your help!

Martin




Dr Martin Tomko
Lecturer/AURIN Technical Architecture Implementation Manager, Department
of Computing and Information Systems
 
Melbourne School of Engineering
The University of Melbourne, Victoria 3010
T: +61 (0) 9035 3298 | E: tom...@unimelb.edu.au | W: www.tomko.org
 

 
This email and any attachments may contain personal information or
information that is otherwise confidential or the subject of copyright.
Any use, disclosure or copying of any part of it is prohibited. The
University does not warrant that this email or any attachments are free
from viruses or defects. Please check any attachments for viruses and
defects before opening them. If this email is received in error please
delete it and notify us by return email.




On 23/03/2014 10:07 pm, Stephan Kolassa stephan.kola...@gmx.de wrote:

Hi Martin,

it sounds like you want the difference between the first and the last
observation per user, not, e.g., all the date differences between
successive observations of each separate user. Correct me if I'm wrong.
That said, let's build some toy data:

set.seed(1)
dataset - data.frame(User=sample(LETTERS[1:5],100,replace=TRUE),
   Date=sample(as.Date(2014-01-01)+0:364,100,replace=TRUE))

Now we can calculate these differences and plot a histogram or tabulate:

foo - with(dataset,by(Date,User,function(xx)diff(range(xx
hist(foo)
table(foo)

The key here is really the by() function, which calculates a function
(here an anonymous function function(xx)diff(range(xx))) applied to
some data (here dataset$Date) separately for each level of a grouping
factor (here dataset$User).

HTH,
Stephan


On 23.03.2014 01:32, Martin Tomko wrote:
 Apologies if the question is a but naïve, I am a novice in time series
data handling in R

 I have the following type of data, in a long format ( as called by the
spacetime vignette ­ the table contains also space, not noted here):

 User |  Date | Otherdata |
 A | 01/01/2014 | aa
 A | 01/01/2014 | bb
 A | 01/01/2014 | cc
 B | 01/01/2014 | aa
 B | 05/01/2014 | cc
 A | 07/01/2014 | aa
 C | 05/02/2014 | xx
 C | 20/02/2014 | yy

 Etc
 [A,B,C,Š] are user Ids (some strings).
 Date is converted into a Date format (2013-10-15)

 The table is sorted by User and then by Date, and is over 800K records
long. There are about 20K users.

 User |  Date | Otherdata |
 A | 2014-01-01 | aa
 A | 2014-01-01  | bb
 A | 2014-01-01  | cc
 A | 2014-01-07  | aa
 B | 2014-01-01  | aa
 B | 2014-01-05  | cc
 C | 2014-02-05  | xx
 C | 2014-02-20  | yy

 I want to:
 Get a frequency table ( and ultimately plot) of the count of
differences (in days) between records of a user. Meaning, I would first
get the unique days recorded:

 A | 2014-01-01
 A | 2014-01-07
 B | 2014-01-01
 B | 2014-01-05
 C | 2014-02-05
 C | 2014-02-20

 And then want to run the differences between timestamps within a group
defined by the user, in days:
 A| 6
 B| 4
 C|15

 Imagining that I have tens of thousands of records, I then want the
table with the counts of differences ( across all users) ( in our case
it would be 6, 4 and 15, all counte = 1)
 IN the larger sample, something like this:
 DeltaDays | Count
 1 | 150
 2 | 320
 Š
 N | X

 I know there are all sorts of packages for time analysis, but I could
not find a simple function like this (incl searching here
http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/somm
er03/ts_r_intro.pdf ). I assume that something working on a simple data
frame would be sufficient, but I am happy ( prefer?) to use TS. I would
appreciate any hints. The ultimate 

Re: [R] time series processing - count of datestamp delta's, per group

2014-03-23 Thread Stephan Kolassa

Hi Martin,

it sounds like you want the difference between the first and the last 
observation per user, not, e.g., all the date differences between 
successive observations of each separate user. Correct me if I'm wrong. 
That said, let's build some toy data:


set.seed(1)
dataset - data.frame(User=sample(LETTERS[1:5],100,replace=TRUE),
Date=sample(as.Date(2014-01-01)+0:364,100,replace=TRUE))

Now we can calculate these differences and plot a histogram or tabulate:

foo - with(dataset,by(Date,User,function(xx)diff(range(xx
hist(foo)
table(foo)

The key here is really the by() function, which calculates a function 
(here an anonymous function function(xx)diff(range(xx))) applied to 
some data (here dataset$Date) separately for each level of a grouping 
factor (here dataset$User).


HTH,
Stephan


On 23.03.2014 01:32, Martin Tomko wrote:

Apologies if the question is a but naïve, I am a novice in time series data 
handling in R

I have the following type of data, in a long format ( as called by the 
spacetime vignette – the table contains also space, not noted here):

User |  Date | Otherdata |
A | 01/01/2014 | aa
A | 01/01/2014 | bb
A | 01/01/2014 | cc
B | 01/01/2014 | aa
B | 05/01/2014 | cc
A | 07/01/2014 | aa
C | 05/02/2014 | xx
C | 20/02/2014 | yy

Etc
[A,B,C,…] are user Ids (some strings).
Date is converted into a Date format (2013-10-15)

The table is sorted by User and then by Date, and is over 800K records long. 
There are about 20K users.

User |  Date | Otherdata |
A | 2014-01-01 | aa
A | 2014-01-01  | bb
A | 2014-01-01  | cc
A | 2014-01-07  | aa
B | 2014-01-01  | aa
B | 2014-01-05  | cc
C | 2014-02-05  | xx
C | 2014-02-20  | yy

I want to:
Get a frequency table ( and ultimately plot) of the count of differences (in 
days) between records of a user. Meaning, I would first get the unique days 
recorded:

A | 2014-01-01
A | 2014-01-07
B | 2014-01-01
B | 2014-01-05
C | 2014-02-05
C | 2014-02-20

And then want to run the differences between timestamps within a group defined 
by the user, in days:
A| 6
B| 4
C|15

Imagining that I have tens of thousands of records, I then want the table with 
the counts of differences ( across all users) ( in our case it would be 6, 4 
and 15, all counte = 1)
IN the larger sample, something like this:
DeltaDays | Count
1 | 150
2 | 320
…
N | X

I know there are all sorts of packages for time analysis, but I could not find 
a simple function like this (incl searching here 
http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf
 ). I assume that something working on a simple data frame would be sufficient, 
but I am happy ( prefer?) to use TS. I would appreciate any hints. The ultimate 
analysis involves also space, so hints in the direction of space-time are 
welcome. Ultimately, I would like to separate records for each user into a 
dataset that can be handled separately, but splitting it into a large number of 
files does not seem wise. Any hint also appreciated.

Thanks,
Martin



[[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.



__
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] time series processing - count of datestamp delta's, per group

2014-03-22 Thread Martin Tomko
Apologies if the question is a but naïve, I am a novice in time series data 
handling in R

I have the following type of data, in a long format ( as called by the 
spacetime vignette – the table contains also space, not noted here):

User |  Date | Otherdata |
A | 01/01/2014 | aa
A | 01/01/2014 | bb
A | 01/01/2014 | cc
B | 01/01/2014 | aa
B | 05/01/2014 | cc
A | 07/01/2014 | aa
C | 05/02/2014 | xx
C | 20/02/2014 | yy

Etc
[A,B,C,…] are user Ids (some strings).
Date is converted into a Date format (2013-10-15)

The table is sorted by User and then by Date, and is over 800K records long. 
There are about 20K users.

User |  Date | Otherdata |
A | 2014-01-01 | aa
A | 2014-01-01  | bb
A | 2014-01-01  | cc
A | 2014-01-07  | aa
B | 2014-01-01  | aa
B | 2014-01-05  | cc
C | 2014-02-05  | xx
C | 2014-02-20  | yy

I want to:
Get a frequency table ( and ultimately plot) of the count of differences (in 
days) between records of a user. Meaning, I would first get the unique days 
recorded:

A | 2014-01-01
A | 2014-01-07
B | 2014-01-01
B | 2014-01-05
C | 2014-02-05
C | 2014-02-20

And then want to run the differences between timestamps within a group defined 
by the user, in days:
A| 6
B| 4
C|15

Imagining that I have tens of thousands of records, I then want the table with 
the counts of differences ( across all users) ( in our case it would be 6, 4 
and 15, all counte = 1)
IN the larger sample, something like this:
DeltaDays | Count
1 | 150
2 | 320
…
N | X

I know there are all sorts of packages for time analysis, but I could not find 
a simple function like this (incl searching here 
http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf
 ). I assume that something working on a simple data frame would be sufficient, 
but I am happy ( prefer?) to use TS. I would appreciate any hints. The ultimate 
analysis involves also space, so hints in the direction of space-time are 
welcome. Ultimately, I would like to separate records for each user into a 
dataset that can be handled separately, but splitting it into a large number of 
files does not seem wise. Any hint also appreciated.

Thanks,
Martin



[[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.


[R] Time Series Plots: Adding Custom Y-Axis Labels

2014-03-06 Thread Rich Shepard

  Working the examples in Introductory Time Series with R (pages 22-23).
When I use the plot command (e.g., plot(elect.decom - decompose(elec.ts,
type = mult)) the ylab command has no effect. Similarly, if I use xyplot.

  Is it possible to specify ylab values in time series plots? And what
strip.default() or strip.custom() options are needed to place specific
strings in the lattice xyplot strips? (I have read appropriate sections of
the Lattice book but have not found the proper syntax).

Rich

__
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 Data Analysis

2014-03-03 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Kapil Shukla
 Sent: Saturday, March 01, 2014 6:23 PM
 To: r-help@r-project.org
 Subject: [R] Time Series Data Analysis

 Hi All

 I am totally new to R so this question may sound basic to many of you.
 I am trying to use R for time series analysis of some financial
 instruments.

Well, the best package for beginners is R-intro.pdf which is located probably 
in doc directory.

 Currently i have hourly data of a stock which has OPEN/HIGH/LOW/CLOSE
 in a CSV file. I used read.table to import the data in R in to a
 dataframe but i am following below issues:

 1. Date is coming in character format and i am not sure whats the best
 package of function to format the date in DD/MM/YY HH:MM format 2.

to convert character to date/time use
?strptime

Then you can set xlim parameters.

 When i plot the data using PLOT() data points are so overlapping on the
 chart that its hard to identify the data points. I am not able to
 specify XLIM parameter as my dates are in character. I tried using the
 C() function to provide the first hour and last hour of the data but it
 won't accept it.

Why you wanted to set contrasts attribute to your factor? Or you used 
concatenation function c?


 Is there any better package for plotting time series data.
 3. Any package which can help me plot the candle stick chart for this
 OHLC data and help me do some statistical analysis on the data.

Second hit from google was package candlesticks. Did you used it? What 
statistical analysis do you have on mind, there is 2000+ packages in R which 
are mainly amed to do statistical analysis. Without further details you 
probably do not get reasonable answer

Regards
Petr

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




 Thanks in Advance.

 Regards
 Kapil

   [[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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he

Re: [R] Time Series on Binary Data.

2014-03-01 Thread Cristiano Varin
Among various possibilities, you might consider a logistic or probit regression 
model with ARMA errors specified via Gaussian copula. This approach is 
implemented in the package gcmr (Gaussian Copula Marginal Regression).  

Example: logistic model with covariates S1 and S2 and AR(1,2) errors

fit - gcmr( Response ~ S1 + S2 + ... , data = your.data, marginal = 
binomial.marg, cormat = arma.cormat(1,2), options( nrep=1000 ) )

See help(gcmr) for more details. 

Cristiano 
-
Cristiano Varin cristiano.va...@unive.it
Department of Environmental Sciences, 
Informatics and Statistics
Ca' Foscari University of Venice
San Giobbe, Cannaregio 873, 30121 Venezia, Italy 
Tel: +39 0412347439   Fax: +39 0412347444
http://cristianovarin.weebly.com

 Hi,
 
 I have a dichotomous data where some my independent variables are 
 categorical, some are continuous and some are binary(0/1)
 
 My dependent is a binary response (Fail/NoFail,0/1) .
 
 The data is some readings collected everyday over a period of time.
 
 The goal is to use this data and see if we can figure out cause of failure 
 ,the end response.
 
 Example data format
 
 
 Date, Type,Mileage,S1,S2,S3 , Response
 
 03/02/2013,A,32000,1,0,1,.., 1
 
 03/03/2013,B,32400,0,0,0,...,0
 
 03/04/2013,C,45000,0,1,1,..,1
 
 
 Can we do Time series modeling?? Any suggesstions on what type of other 
 exploratory analysis can be used to figure out patterns in data ??
 
 Thanks
 shi
  

__
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] Time Series Data Analysis

2014-03-01 Thread Kapil Shukla
Hi All

I am totally new to R so this question may sound basic to many of you. I am
trying to use R for time series analysis of some financial instruments.
Currently i have hourly data of a stock which has OPEN/HIGH/LOW/CLOSE in a
CSV file. I used read.table to import the data in R in to a dataframe but i
am following below issues:

1. Date is coming in character format and i am not sure whats the best
package of function to format the date in DD/MM/YY HH:MM format
2. When i plot the data using PLOT() data points are so overlapping on the
chart that its hard to identify the data points. I am not able to specify
XLIM parameter as my dates are in character. I tried using the C() function
to provide the first hour and last hour of the data but it won't accept it.
Is there any better package for plotting time series data.
3. Any package which can help me plot the candle stick chart for this OHLC
data and help me do some statistical analysis on the data.

Thanks in Advance.

Regards
Kapil

[[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.


[R] Time Series on Binary Data.

2014-02-27 Thread shilpi harpavat
Hi,

I have a dichotomous data where some my independent variables are categorical, 
some are continuous and some are binary(0/1)

My dependent is a binary response (Fail/NoFail,0/1) .

The data is some readings collected everyday over a period of time.

The goal is to use this data and see if we can figure out cause of failure ,the 
end response.

Example data format

 

 

Date, Type,Mileage,S1,S2,S3 , Response

03/02/2013,A,32000,1,0,1,.., 1

03/03/2013,B,32400,0,0,0,...,0

03/04/2013,C,45000,0,1,1,..,1

 

Can we do Time series modeling?? Any suggesstions on what type of other 
exploratory analysis can be used to figure out patterns in data ??

Thanks
shi
  
[[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.


[R] time series analysis

2014-02-27 Thread Yang Yang
Hi

Currently I am working on a river discharge data analysis. I have the daily
discharge record from 1935 to now. I want to extract the annual maximum
discharge for each hydrolocial year (*start from 01/11 to next year 31/10*).
However, I found that the hydroTSM package can only deal with the natural
year. I tried to use the zoo package, but I found it's difficult to
compute, as each year have different days. Does anyone have some idea?
Thanks.

the data looks like:

01-11-1935 66302-11-1935 59603-11-1935 45004-11-1935 38105-11-1935
35406-11-1935 312

my code:

mydata-read.table(discharge)
colnames(mydata) - c(date,discharge)

library(zoo)
z-zooreg(mydata[,2],start=as.Date(1935-11-1))

mydta$date - as.POSIXct(dat$date)

q.month-daily2monthly(z,FUN=max,na.rm = TRUE,date.fmt =
%Y-%m-%d,out.fmt=numeric)
q.month.plain=coredata(q.month)

z.month-zooreg(q.month.plain,start=1,frequency=12)

Thanks very much.

[[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 analysis

2014-02-27 Thread Pascal Oettli
Hello,

Maybe functions xts, endpoints and period.apply of the xts
package might help you.

Regards,
Pascal


On Fri, Feb 28, 2014 at 1:32 AM, Yang Yang simonyangy...@gmail.com wrote:
 Hi

 Currently I am working on a river discharge data analysis. I have the daily
 discharge record from 1935 to now. I want to extract the annual maximum
 discharge for each hydrolocial year (*start from 01/11 to next year 31/10*).
 However, I found that the hydroTSM package can only deal with the natural
 year. I tried to use the zoo package, but I found it's difficult to
 compute, as each year have different days. Does anyone have some idea?
 Thanks.

 the data looks like:

 01-11-1935 66302-11-1935 59603-11-1935 45004-11-1935 38105-11-1935
 35406-11-1935 312

 my code:

 mydata-read.table(discharge)
 colnames(mydata) - c(date,discharge)

 library(zoo)
 z-zooreg(mydata[,2],start=as.Date(1935-11-1))

 mydta$date - as.POSIXct(dat$date)

 q.month-daily2monthly(z,FUN=max,na.rm = TRUE,date.fmt =
 %Y-%m-%d,out.fmt=numeric)
 q.month.plain=coredata(q.month)

 z.month-zooreg(q.month.plain,start=1,frequency=12)

 Thanks very much.

 [[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.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
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 STL

2014-01-12 Thread PIKAL Petr
Hi

Do not extract columns from your data frame. Just put correct names to columns.

names(BHD)[29] - O2

Then you can construct time series objects on fly

with(BHD, ts(O2, frequency=12))

if it is monthly time series and use it in stl directly

stl(with(BHD, ts(O2, frequency=12)))

Or you can put it in cycle

cycvec - c(28,29,30)
lll -vector(mode = list, length = 3)
for(i in 1:3) {
t.object - ts(BHD[, cycvec[i]], frequency=12)
lll[[i]] -stl(t.oobject)
names(lll[[i]]) - names(BHD[, cycvec[i]])
}

Anyway, help pages for all mentioned commands are first source for information.
Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Thomas Barningham
 Sent: Friday, January 10, 2014 6:13 PM
 To: r-help@r-project.org
 Subject: [R] Time Series STL

 Hi,

 I'm relatively new to R and need to some help in converting some of my
 data into a ts object that can then be used to run an STL analysis.

 My initial input file is a .csv output from some atmospheric
 measurement instruments. The first column is the year fraction and
 extends over 2 years with a new data point being collected roughly
 every 2 minutes. Lots of data are recorded in the subsequent columns
 (such as met info) and concentrations of particular atmospheric species
 (which I want to run STL on).

 Here's my initial code:

 *#Read in file as an object, defined BHD from original file* *BHD -
 read.csv(C:/Work/PhD/R_Directory/BHD_2009_2012_all_samp_cal.csv,
 header=T, dec=., sep=,)*


 *#Define Columns from original files (comment out if using IDL output)*
 *yearfrac - BHD[,1]* *APO - BHD[,30]*
 *O2 - BHD [,29]*
 *CO2 - BHD[,28]*

 (end of code)

 What I want to do is take the objects defined above (APO, CO2, O2) and
 perform stl analyses on them, but I need to convert them to time series
 objects first based on the information in the yearfrac object.

 How do I go about this?!

 Thanks in advance
 Barney

 --
 Thomas Barningham
 Centre for Ocean and Atmospheric Sciences School of Environmental
 Sciences University of East Anglia Norwich Research Park Norwich
 NR4 7TJ

   [[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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects

[R] Time Series STL

2014-01-10 Thread Thomas Barningham
Hi,

I'm relatively new to R and need to some help in converting some of my data
into a ts object that can then be used to run an STL analysis.

My initial input file is a .csv output from some atmospheric measurement
instruments. The first column is the year fraction and extends over 2 years
with a new data point being collected roughly every 2 minutes. Lots of data
are recorded in the subsequent columns (such as met info) and
concentrations of particular atmospheric species (which I want to run STL
on).

Here's my initial code:

*#Read in file as an object, defined BHD from original file*
*BHD - read.csv(C:/Work/PhD/R_Directory/BHD_2009_2012_all_samp_cal.csv,
header=T, dec=., sep=,)*


*#Define Columns from original files (comment out if using IDL output)*
*yearfrac - BHD[,1]*
*APO - BHD[,30]*
*O2 - BHD [,29]*
*CO2 - BHD[,28]*

(end of code)

What I want to do is take the objects defined above (APO, CO2, O2) and
perform stl analyses on them, but I need to convert them to time series
objects first based on the information in the yearfrac object.

How do I go about this?!

Thanks in advance
Barney

-- 
Thomas Barningham
Centre for Ocean and Atmospheric Sciences
School of Environmental Sciences
University of East Anglia
Norwich Research Park
Norwich
NR4 7TJ

[[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 STL

2014-01-10 Thread Jeff Newmiller
This might not seem helpful, but there really is a communication gap here. You 
need to read the Posting Guide, post in plain text so your example code is not 
mangled by the HTML, and include a bit of data that is representative of the 
data you are working with. You may find some helpful advice here: 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example,
 including how to use the dput function.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Thomas Barningham stbarning...@gmail.com wrote:
Hi,

I'm relatively new to R and need to some help in converting some of my
data
into a ts object that can then be used to run an STL analysis.

My initial input file is a .csv output from some atmospheric
measurement
instruments. The first column is the year fraction and extends over 2
years
with a new data point being collected roughly every 2 minutes. Lots of
data
are recorded in the subsequent columns (such as met info) and
concentrations of particular atmospheric species (which I want to run
STL
on).

Here's my initial code:

*#Read in file as an object, defined BHD from original file*
*BHD -
read.csv(C:/Work/PhD/R_Directory/BHD_2009_2012_all_samp_cal.csv,
header=T, dec=., sep=,)*


*#Define Columns from original files (comment out if using IDL output)*
*yearfrac - BHD[,1]*
*APO - BHD[,30]*
*O2 - BHD [,29]*
*CO2 - BHD[,28]*

(end of code)

What I want to do is take the objects defined above (APO, CO2, O2) and
perform stl analyses on them, but I need to convert them to time series
objects first based on the information in the yearfrac object.

How do I go about this?!

Thanks in advance
Barney

__
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


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.


[R] Time series and lm

2013-12-17 Thread Marlin Keith Cox
Hello all, I have a time series defined by

chum$Time1-as.POSIXlt(chum$Time, format= %m/%d/%y %H:%M)

and a measured parameter

pa.s

When I create a linear model

with(chum.skin, lm(Time1~pa.s))

I get the following error.

Error in model.frame.default(formula = Time1 ~ pa.s, drop.unused.levels =
TRUE) : invalid type (list) for variable 'Time1'
I cannot figure it out.

Keith




M. Keith Cox, Ph.D.
Principal
MKConsulting
17105 Glacier Hwy
Juneau, AK 99801
U.S. 907.957.4606

[[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 and lm

2013-12-17 Thread William Dunlap
Use as.POSIXct instead of as.POSIXlt if you want to use lm() on the dates.
(The data.frame() function makes this transformation for you, but you
evaded data.frame() by adding the column with $-(), which does not
do the checks and transformations that data.frame() does.)

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 Marlin Keith Cox
 Sent: Tuesday, December 17, 2013 12:49 PM
 To: r-help@r-project.org
 Subject: [R] Time series and lm
 
 Hello all, I have a time series defined by
 
 chum$Time1-as.POSIXlt(chum$Time, format= %m/%d/%y %H:%M)
 
 and a measured parameter
 
 pa.s
 
 When I create a linear model
 
 with(chum.skin, lm(Time1~pa.s))
 
 I get the following error.
 
 Error in model.frame.default(formula = Time1 ~ pa.s, drop.unused.levels =
 TRUE) : invalid type (list) for variable 'Time1'
 I cannot figure it out.
 
 Keith
 
 
 
 
 M. Keith Cox, Ph.D.
 Principal
 MKConsulting
 17105 Glacier Hwy
 Juneau, AK 99801
 U.S. 907.957.4606
 
   [[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.

__
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

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

2013-10-03 Thread Daniel Hickman
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

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.

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

In case it helps,  excel file with the triple exponential smoothing formulas 
and original data can be found 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.


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.


[R] Time Series X labels

2013-07-30 Thread Lívio Cipriano
Hi,

When we plot a Time Series object with a annual frequency, in the X axes 
usually appears mark ticks with an interval of 5 years. How can customize the 
X axes putting a tick for every year?

Regards

Lívio Cipriano

__
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] Time Series with daily frequency

2013-07-30 Thread Lívio Cipriano
Hi,

I tried to use the ts function to create a Time Series object with daily 
frequency but I couldn't. It's not possible or I'm not using the right 
parameters?

Regards

Lívio Cipriano

__
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 with daily frequency

2013-07-30 Thread John Kane
Who knows? You have not told us what you are actually doing.
https://github.com/hadley/devtools/wiki/Reproducibility
 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

John Kane
Kingston ON Canada


 -Original Message-
 From: lcmail4li...@gmail.com
 Sent: Tue, 30 Jul 2013 13:33:29 +0100
 To: r-help@r-project.org
 Subject: [R] Time Series with daily frequency
 
 Hi,
 
 I tried to use the ts function to create a Time Series object with daily
 frequency but I couldn't. It's not possible or I'm not using the right
 parameters?
 
 Regards
 
 Lívio Cipriano
 
 __
 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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
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 with daily frequency

2013-07-30 Thread Rui Barradas

Hello,

You should show us an example of what you're doing.
Anyway, there's an agument frequency to ?ts. Maybe you could set it 
frequency = 365.


Also, see packages zoo and xts for the creation of time series objects 
with real time stamps.


Hope this helps,

Rui Barradas

Em 30-07-2013 13:33, Lívio Cipriano escreveu:

Hi,

I tried to use the ts function to create a Time Series object with daily
frequency but I couldn't. It's not possible or I'm not using the right
parameters?

Regards

Lívio Cipriano

__
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.


Re: [R] Time Series X labels

2013-07-30 Thread Rui Barradas

Hello,

The standard way of customizing the x axis is

plot(..., xaxt = n)
axis(1, at = where you want the ticks)

Hope this helps,

Rui Barradas

Em 30-07-2013 13:31, Lívio Cipriano escreveu:

Hi,

When we plot a Time Series object with a annual frequency, in the X axes
usually appears mark ticks with an interval of 5 years. How can customize the
X axes putting a tick for every year?

Regards

Lívio Cipriano

__
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.


Re: [R] Time Series with daily frequency

2013-07-30 Thread Lívio Cipriano
On 30 July 2013 17:50:08 Rui Barradas wrote:
 Maybe you could set it 
 frequency = 365.

No. It didn't worked. Was my first trial.

 
 Also, see packages zoo and xts for the creation of time series objects 
 with real time stamps.

I'll look in to them.

Regards

Lívio Cipriano

__
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] Time Series prediction

2013-05-27 Thread Giovanni Azua
Hello,

I would like to use a parametric TS model and predictor as benchmark to
compare against other ML methods I'm employing. I currently build a simple
e.g. ARIMA model using the convenient auto.arima function like this:

library(forecast)
df - read.table(/Users/bravegag/data/myts.dat)
# btw my test data doesn't have seasonality but periodicity so the value
# 2 is arbitrarily set, using a freq of yearly or 1 would make unhappy some
# R ts functions
tsdata - ts(df$signal, freq=2)
arimamodel - auto.arima(tsdata, max.p=15, max.q=10, stationary=FALSE,
ic=bic, stepwise=TRUE, seasonal=FALSE, parallel=FALSE, num.cores=4,
trace=TRUE, allowdrift=TRUE)
arimapred - forecast.Arima(arimamodel, h=20)
plot(arimapred)

The problem is that the forecast.Arima function is apparently doing a free
run i.e. it uses the forecast(t+1) value as input to compute forecast(t+2)
and I'm instead interested in a prediction mode where it always use the
observed tsdata(t+1) value to predict forecast(t+2), the observed
tsdata(t+2) to predict forecast(t+3) and so on.

Can anyone please advice how to achieve this?

TIA,
Best regards,
Giovanni

[[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.


[R] time-series aggregation of information

2013-05-17 Thread Chirag Maru
I have following data for which I need to calculate the weighted aggregate 
value of the parameter at each time.

Date,Parameter,Weight
2012-01-31,90,200
2012-01-31,80,400
2012-01-31,70,500
2012-01-31,60,800
2012-02-29,120,220
2012-02-29,110,410
2012-02-29,75,520
2012-02-29,65,840
2012-03-31,115,210
2012-03-31,100,405
2012-03-31,70,500
2012-03-31,60,800

So for the above sample the solution looks like:

Date,Weighted Parameter
2012-01-31,70
2012-02-29,82.96482412
2012-03-31,77.10182768

Could I potentially use tapply / aggregate for this?  Would like to avoid a for 
loop if possible.

Thank you!





The information transmitted is intended solely for the individual or entity to 
which it is addressed and may contain confidential and/or privileged material. 
Any review, retransmission, dissemination or other use of or taking action in 
reliance upon this information by persons or entities other than the intended 
recipient is prohibited. If you have received this email in error please 
contact the sender and delete the material from any computer.

Any information contained herein is neither an offer to sell nor a solicitation 
to buy any interest in any investment fund. An offer can only be made by the 
approved offering memorandum, which contains important information concerning 
risk factors and other material information and must be read carefully before 
any decision to invest is made. Securities and derivatives trading are 
speculative and involve a risk of substantial loss. Past results are not 
necessarily indicative of future performance.

All incoming and outgoing e-mails are archived and may be reviewed and/or 
produced at the request of regulators or in connection with civil litigation. 
IRON Holdings, LLC. accepts no liability for any errors or omissions arising as 
a result of transmission.

[[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 aggregation of information

2013-05-17 Thread David Winsemius

On May 17, 2013, at 11:48 AM, Chirag Maru wrote:

 I have following data for which I need to calculate the weighted aggregate 
 value of the parameter at each time.
 
 Date,Parameter,Weight
 2012-01-31,90,200
 2012-01-31,80,400
 2012-01-31,70,500
 2012-01-31,60,800
 2012-02-29,120,220
 2012-02-29,110,410
 2012-02-29,75,520
 2012-02-29,65,840
 2012-03-31,115,210
 2012-03-31,100,405
 2012-03-31,70,500
 2012-03-31,60,800
 
 So for the above sample the solution looks like:
 
 Date,Weighted Parameter
 2012-01-31,70
 2012-02-29,82.96482412
 2012-03-31,77.10182768
 
 Could I potentially use tapply / aggregate for this?  Would like to avoid a 
 for loop if possible.

 by(dat, dat[1], FUN=function(d) weighted.mean(d[[Parameter]], 
 w=d[[Weight]]) )
Date: 2012-01-31
[1] 70
 
Date: 2012-02-29
[1] 82.96482
 
Date: 2012-03-31
[1] 77.10183

It's a bit of a shame that there is no as.data.frame.by function. You can 
create a dataframe from the by object with as.data.frame.table with the only 
defect in the naming of the second column

as.data.frame.table(by(dat, dat[1], FUN=function(d) 
weighted.mean(d[[Parameter]], w=d[[Weight]]) ))

Date Freq
1 2012-01-31 70.0
2 2012-02-29 82.96482
3 2012-03-31 77.10183

 setNames(as.data.frame.table(by(dat, dat[1], FUN=function(d) 
weighted.mean(d[[Parameter]], w=d[[Weight]]) )), 
  c(Dts, wtdmeans))
 Dts wtdmeans
1 2012-01-31 70.0
2 2012-02-29 82.96482
3 2012-03-31 77.10183


-- 

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 aggregation of information

2013-05-17 Thread arun
Hi,
May be this helps:
dat- read.table(text=
Date,Parameter,Weight
2012-01-31,90,200
2012-01-31,80,400
2012-01-31,70,500
2012-01-31,60,800
2012-02-29,120,220
2012-02-29,110,410
2012-02-29,75,520
2012-02-29,65,840
2012-03-31,115,210
2012-03-31,100,405
2012-03-31,70,500
2012-03-31,60,800
,sep=,,header=TRUE,stringsAsFactors=FALSE)
library(plyr)
 ddply(dat,.(Date), summarize, wtdmeans=weighted.mean(Parameter,Weight))
#    Date wtdmeans
#1 2012-01-31 70.0
#2 2012-02-29 82.96482
#3 2012-03-31 77.10183
A.K.




- Original Message -
From: Chirag Maru chirag.m...@ironfinancial.com
To: r-help@R-project.org r-help@r-project.org
Cc: 
Sent: Friday, May 17, 2013 2:48 PM
Subject: [R] time-series aggregation of information

I have following data for which I need to calculate the weighted aggregate 
value of the parameter at each time.

Date,Parameter,Weight
2012-01-31,90,200
2012-01-31,80,400
2012-01-31,70,500
2012-01-31,60,800
2012-02-29,120,220
2012-02-29,110,410
2012-02-29,75,520
2012-02-29,65,840
2012-03-31,115,210
2012-03-31,100,405
2012-03-31,70,500
2012-03-31,60,800

So for the above sample the solution looks like:

Date,Weighted Parameter
2012-01-31,70
2012-02-29,82.96482412
2012-03-31,77.10182768

Could I potentially use tapply / aggregate for this?  Would like to avoid a for 
loop if possible.

Thank you!





The information transmitted is intended solely for the individual or entity to 
which it is addressed and may contain confidential and/or privileged material. 
Any review, retransmission, dissemination or other use of or taking action in 
reliance upon this information by persons or entities other than the intended 
recipient is prohibited. If you have received this email in error please 
contact the sender and delete the material from any computer.

Any information contained herein is neither an offer to sell nor a solicitation 
to buy any interest in any investment fund. An offer can only be made by the 
approved offering memorandum, which contains important information concerning 
risk factors and other material information and must be read carefully before 
any decision to invest is made. Securities and derivatives trading are 
speculative and involve a risk of substantial loss. Past results are not 
necessarily indicative of future performance.

All incoming and outgoing e-mails are archived and may be reviewed and/or 
produced at the request of regulators or in connection with civil litigation. 
IRON Holdings, LLC. accepts no liability for any errors or omissions arising as 
a result of transmission.

    [[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.


__
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 analysis

2013-05-10 Thread Kai Mx
Awesome, exactly what I was hoping for! Thanks so much! You are right -  I
put in the wrong end dates for the second day.

Best,

Kai




On Thu, May 9, 2013 at 4:01 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 Maybe the following will do it. Note, however, that in your data, for
 start day 2012-02-11, the end day is always 2012-02-12 so the time
 differences will be negative.



 fun2 - function(x){
 d - numeric(nrow(x) - 1)
 for(i in seq_len(nrow(x))[-1]){
 start - strptime(paste(x[i, 1], x[i, 2]), format =
 %Y-%m-%d %H:%M:%S)
 end - strptime(paste(x[i - 1, 3], x[i - 1, 4]), format =
 %Y-%m-%d %H:%M:%S)
 dd - difftime(start, end)
 if(attr(dd, units) == hours)
 d[i - 1] - dd*60
 else if(attr(dd, units) == days)
 d[i - 1] - dd*24*60
 else
 d[i - 1] - dd
 }
 d
 }

 lapply(split(df, df[,1]), fun2)




 Hope this helps,

 Rui Barradas

 Em 09-05-2013 13:44, Kai Mx escreveu:

 Hi Rui,
 thanks for the quick fix. I am still wrapping my mind around your
 expression, but unfortunately it doesn't quite give me what I want. You
 are
 calculating differences between the start times. However, I would like to
 know the 'idle' periods between the events, ie the time between the end of
 one event and the beginning of the next (but only for the events that
 start
 on the same day).

 Best,

 Kai


 On Thu, May 9, 2013 at 1:55 PM, Rui Barradas ruipbarra...@sapo.pt
 wrote:

  Hello,

 If I understand it well, try the following.


 tmp - lapply(tapply(as.POSIXct(paste(df[,1], df[,2])), df[,1],
 diff),

 `*`, 60)
 lapply(tmp, as.integer)


 Hope this helps,

 Rui Barradas

 Em 09-05-2013 11:45, Kai Mx escreveu:

  Hi everybody,
 I have an analysis problem that seems a little overwhelming to me, but
 is
 probably not too hard to solve for you guys. I have a (fairly large)
 dataframe that indicates usage of a resource on different days:

 df -data.frame (
 dstartday =c(rep('2012-02-10', 4), rep('2012-02-11', 5)),
 dstart =c('08:05:00','09:35:00', '12:00:00','13:00:00', '07:50:00',
 '9:45:00', '13:00:00', '14:05:00', '15:50:00'),
 dendday =c (rep('2012-02-10', 3), '2012-02-11',rep('2012-02-12',
 5)),
 dend = c ('08:35:00','09:40:00', '12:20:00', '01:00:00', '08:35:00',
 '11:00:00', '13:15:00', '15:00:00', '17:00:00')
 )

 Each row reflects an event that starts at the date and time that is
 indicated by dstartday/dstart and ends at dendday/dend.
 Now I would like to calculate the time intervals in minutes between the
 different events that start on a specific day, eg for '2012-02-10' it
 should be 60, 140, 40. The interval between the last event of the day
 and
 the first event of the next is not relevant and should be ignored.
 Events
 may run overnight, but there should not be any overlaps between start
 and
 end times.
 I have imported all the data as strings.
 Any thoughts and suggested readings/packages are really appreciated,
 thanks!

 Best,

 Kai

  [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help
 https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help
 
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 
 http://www.R-project.org/**posting-guide.htmlhttp://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.


[R] Time series analysis

2013-05-09 Thread Kai Mx
Hi everybody,
I have an analysis problem that seems a little overwhelming to me, but is
probably not too hard to solve for you guys. I have a (fairly large)
dataframe that indicates usage of a resource on different days:

df -data.frame (
  dstartday =c(rep('2012-02-10', 4), rep('2012-02-11', 5)),
  dstart =c('08:05:00','09:35:00', '12:00:00','13:00:00', '07:50:00',
'9:45:00', '13:00:00', '14:05:00', '15:50:00'),
  dendday =c (rep('2012-02-10', 3), '2012-02-11',rep('2012-02-12', 5)),
  dend = c ('08:35:00','09:40:00', '12:20:00', '01:00:00', '08:35:00',
'11:00:00', '13:15:00', '15:00:00', '17:00:00')
)

Each row reflects an event that starts at the date and time that is
indicated by dstartday/dstart and ends at dendday/dend.
Now I would like to calculate the time intervals in minutes between the
different events that start on a specific day, eg for '2012-02-10' it
should be 60, 140, 40. The interval between the last event of the day and
the first event of the next is not relevant and should be ignored. Events
may run overnight, but there should not be any overlaps between start and
end times.
I have imported all the data as strings.
Any thoughts and suggested readings/packages are really appreciated, thanks!

Best,

Kai

[[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 analysis

2013-05-09 Thread Rui Barradas

Hello,

If I understand it well, try the following.


tmp - lapply(tapply(as.POSIXct(paste(df[,1], df[,2])), df[,1], diff), 
`*`, 60)

lapply(tmp, as.integer)


Hope this helps,

Rui Barradas

Em 09-05-2013 11:45, Kai Mx escreveu:

Hi everybody,
I have an analysis problem that seems a little overwhelming to me, but is
probably not too hard to solve for you guys. I have a (fairly large)
dataframe that indicates usage of a resource on different days:

df -data.frame (
   dstartday =c(rep('2012-02-10', 4), rep('2012-02-11', 5)),
   dstart =c('08:05:00','09:35:00', '12:00:00','13:00:00', '07:50:00',
'9:45:00', '13:00:00', '14:05:00', '15:50:00'),
   dendday =c (rep('2012-02-10', 3), '2012-02-11',rep('2012-02-12', 5)),
   dend = c ('08:35:00','09:40:00', '12:20:00', '01:00:00', '08:35:00',
'11:00:00', '13:15:00', '15:00:00', '17:00:00')
)

Each row reflects an event that starts at the date and time that is
indicated by dstartday/dstart and ends at dendday/dend.
Now I would like to calculate the time intervals in minutes between the
different events that start on a specific day, eg for '2012-02-10' it
should be 60, 140, 40. The interval between the last event of the day and
the first event of the next is not relevant and should be ignored. Events
may run overnight, but there should not be any overlaps between start and
end times.
I have imported all the data as strings.
Any thoughts and suggested readings/packages are really appreciated, thanks!

Best,

Kai

[[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.



__
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 analysis

2013-05-09 Thread Kai Mx
Hi Rui,
thanks for the quick fix. I am still wrapping my mind around your
expression, but unfortunately it doesn't quite give me what I want. You are
calculating differences between the start times. However, I would like to
know the 'idle' periods between the events, ie the time between the end of
one event and the beginning of the next (but only for the events that start
on the same day).

Best,

Kai


On Thu, May 9, 2013 at 1:55 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 If I understand it well, try the following.


 tmp - lapply(tapply(as.POSIXct(**paste(df[,1], df[,2])), df[,1], diff),
 `*`, 60)
 lapply(tmp, as.integer)


 Hope this helps,

 Rui Barradas

 Em 09-05-2013 11:45, Kai Mx escreveu:

 Hi everybody,
 I have an analysis problem that seems a little overwhelming to me, but is
 probably not too hard to solve for you guys. I have a (fairly large)
 dataframe that indicates usage of a resource on different days:

 df -data.frame (
dstartday =c(rep('2012-02-10', 4), rep('2012-02-11', 5)),
dstart =c('08:05:00','09:35:00', '12:00:00','13:00:00', '07:50:00',
 '9:45:00', '13:00:00', '14:05:00', '15:50:00'),
dendday =c (rep('2012-02-10', 3), '2012-02-11',rep('2012-02-12', 5)),
dend = c ('08:35:00','09:40:00', '12:20:00', '01:00:00', '08:35:00',
 '11:00:00', '13:15:00', '15:00:00', '17:00:00')
 )

 Each row reflects an event that starts at the date and time that is
 indicated by dstartday/dstart and ends at dendday/dend.
 Now I would like to calculate the time intervals in minutes between the
 different events that start on a specific day, eg for '2012-02-10' it
 should be 60, 140, 40. The interval between the last event of the day and
 the first event of the next is not relevant and should be ignored. Events
 may run overnight, but there should not be any overlaps between start and
 end times.
 I have imported all the data as strings.
 Any thoughts and suggested readings/packages are really appreciated,
 thanks!

 Best,

 Kai

 [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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 analysis

2013-05-09 Thread Rui Barradas

Hello,

Maybe the following will do it. Note, however, that in your data, for 
start day 2012-02-11, the end day is always 2012-02-12 so the time 
differences will be negative.




fun2 - function(x){
d - numeric(nrow(x) - 1)
for(i in seq_len(nrow(x))[-1]){
start - strptime(paste(x[i, 1], x[i, 2]), format = %Y-%m-%d 
%H:%M:%S)
		end - strptime(paste(x[i - 1, 3], x[i - 1, 4]), format = %Y-%m-%d 
%H:%M:%S)

dd - difftime(start, end)
if(attr(dd, units) == hours)
d[i - 1] - dd*60
else if(attr(dd, units) == days)
d[i - 1] - dd*24*60
else
d[i - 1] - dd
}
d
}

lapply(split(df, df[,1]), fun2)



Hope this helps,

Rui Barradas

Em 09-05-2013 13:44, Kai Mx escreveu:

Hi Rui,
thanks for the quick fix. I am still wrapping my mind around your
expression, but unfortunately it doesn't quite give me what I want. You are
calculating differences between the start times. However, I would like to
know the 'idle' periods between the events, ie the time between the end of
one event and the beginning of the next (but only for the events that start
on the same day).

Best,

Kai


On Thu, May 9, 2013 at 1:55 PM, Rui Barradas ruipbarra...@sapo.pt wrote:


Hello,

If I understand it well, try the following.


tmp - lapply(tapply(as.POSIXct(**paste(df[,1], df[,2])), df[,1], diff),
`*`, 60)
lapply(tmp, as.integer)


Hope this helps,

Rui Barradas

Em 09-05-2013 11:45, Kai Mx escreveu:


Hi everybody,
I have an analysis problem that seems a little overwhelming to me, but is
probably not too hard to solve for you guys. I have a (fairly large)
dataframe that indicates usage of a resource on different days:

df -data.frame (
dstartday =c(rep('2012-02-10', 4), rep('2012-02-11', 5)),
dstart =c('08:05:00','09:35:00', '12:00:00','13:00:00', '07:50:00',
'9:45:00', '13:00:00', '14:05:00', '15:50:00'),
dendday =c (rep('2012-02-10', 3), '2012-02-11',rep('2012-02-12', 5)),
dend = c ('08:35:00','09:40:00', '12:20:00', '01:00:00', '08:35:00',
'11:00:00', '13:15:00', '15:00:00', '17:00:00')
)

Each row reflects an event that starts at the date and time that is
indicated by dstartday/dstart and ends at dendday/dend.
Now I would like to calculate the time intervals in minutes between the
different events that start on a specific day, eg for '2012-02-10' it
should be 60, 140, 40. The interval between the last event of the day and
the first event of the next is not relevant and should be ignored. Events
may run overnight, but there should not be any overlaps between start and
end times.
I have imported all the data as strings.
Any thoughts and suggested readings/packages are really appreciated,
thanks!

Best,

Kai

 [[alternative HTML version deleted]]

__**
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/**
posting-guide.html 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.


[R] time series plot: x-axis problem

2013-04-26 Thread Jerry
Hi,

I'm trying to plot a simple time series. I'm running into an issue with
x-axis

The codes below will produce a plot with correct x-axis showing from Jan to
Dec

 rr=c(3,2,4,5,4,5,3,3,6,2,4,2)

 (rr=ts(rr,start=c(2012,1),frequency=12))

 win.graph(width=6.5, height=2.5,pointsize=8)

 plot(rr, xlab=2012, ylab=event freq, xaxt = n, col=blue)

 axis(1, time(rr), rep(substr(month.abb, 1, 3), length = length(rr)),
cex.axis = .9, tcl = -.5, las = 2)


However, if I change the start point from Jan 2012 to May 2012, which is

 (rr=ts(rr,start=c(2012,5),frequency=12))


Then run the codes below

 plot(rr, xlab=2012 - 2013, ylab=event freq, xaxt = n, col=blue)

 axis(1, time(rr), rep(substr(month.abb, 1, 3), length = length(rr)),
cex.axis = .9, tcl = -.5, las = 2)


In the the new plot produced, x-axis is still showing from Jan to Dec, not
from May to April as I desired.

How to fix x-axis? Is it possible to fix it WITHOUT modifying the object
rr? Also, ideally, I would like to have each time point on x-axis showing
month/year, not just month. How to do that?

Any help and input will be much appreciated!

Thanks
Jerry

[[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.


  1   2   3   4   >