Not all series have the same frequency for ts objects

Viewed 2306

I have the following from the package astsa in R.

data("cmort")  
data("tempr")  
data("part")   
t <- ts(1:length(cmort))

I am trying to plot the scatterplot matrix of these variables by using:

pairs(cbind(cmort, t, part))

But I got the error error

What is this error about? Whether all the variables are ts objects and have the same frequency.

1 Answers

That's exactly what is wrong. Look at the frequency of the three vectors:

> frequency(part)
[1] 52
> frequency(cmort)
[1] 52
> frequency(t)
[1] 1

The fix is to create a t vector that has the same frequency attribute.

t <- ts(1:length(cmort),frequency=52)
pairs(cbind(cmort,t,part))
Related