1
$\begingroup$

I have a time series with observations that were collected quasi fortnightly over several years. However, there are between 23 and 26 observations per year. The time series is not equidistant, due to bad weather or holidays where no sampling occurred. Is it legitimate to average these observations to obtain a frequency that can be used in a R time series object?

To illustrate, here is some code (time series of pH values in rain water):

Data <- read.table("http://dl.dropbox.com/u/2108381/Data.txt")
Data.col <- data.frame(Time = Data[1:122,1], Value = Data[123:244,1]) 
Dat.num <- as.numeric(Data.col$Value)
pH.TimeSeries <- ts(Dat.num, start = c(2006,2), frequency = 24.4)
pH.decomp <- decompose(pH.TimeSeries)
plot(pH.decomp)

Is it allowed to approach time series analysis like this? Can I make the decomposition like this? And, is it allowed to average the frequencies over the years? The "decompose" plots make sense since there is a seasonal peak and an upward trend in pH in the summer.

Any direct answer to this challenge or linkage to other websites/posts is greatly appreciated. Some google-fu from my side was to no avail. Please let me know if there are ways to improve this question.

$\endgroup$
2
$\begingroup$

My first thought would be that you can't average out your frequency like that. I think it will introduce frequencies that aren't really there.

Could you aggregate things to create a monthly (average) reading and do something on a monthly basis? Or is that not good enough?

EDIT: Now that I've thought about it, I'd basically create a time series with a frequency of 24, aggregating (averaging bins) data into half-months: Jan1, Jan2, Feb1, Feb2, ..., Dec1, Dec2. If there are no readings in a bin, enter NA.

If you end up with NA's, use StructTS, which allows NA's. Otherwise, I'd try stl in preference to decompose.

I'm also wondering if you could use loess or approx or package akima's interp to interpolate your data to a regular (half-months) series and go with that. But I suspect it would introduce artifacts.

$\endgroup$
  • $\begingroup$ It might be a good idea to create monthly averages. This still should be good enough. I can still make the decomposition then, right? Thanks for your time. $\endgroup$ – Strohmi Aug 30 '12 at 14:07
  • $\begingroup$ I'd wait on other answers and votes before taking action. I work with time series, but am not a time series guru, so there may well be other options that might help you preserve some of the detail you got. (From your example, you did get more than two readings per month, though not a regular every-two-weeks reading.) $\endgroup$ – Wayne Aug 30 '12 at 14:09
0
$\begingroup$

Read the CRAN Task View on Time Series - you might want to try storing your data as a zoo object, or an xts object (these allow irregularly-spaced time series).

As for the analysis, well you should figure out what question you want to ask and then work from there. Don't run the functions you've got (decompose) and then say 'ooh what does that tell me' (okay, maybe when working in exploratory mode, but at some point you might have to write a model down).

http://cran.r-project.org/web/views/TimeSeries.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.