0
$\begingroup$

I am new to time series analysis and I am trying out some codes seen in some tutorials. I am using stock prices as the time series data.

library(quantmod)
aapl=getSymbols("AAPL",from="2015-01-01",auto.assign=F)
is.ts(aapl)
ts.aapl=as.ts(aapl)
is.ts(ts.aapl)
x=Cl(ts.aapl)
head(x)
plot(decompose(s))
plot(stl(x))

But its showing these errors

> plot(decompose(x))
Error in decompose(x) : time series has no or less than 2 periods
> plot(stl(x))
Error in stl(x) : series is not periodic or has less than two periods

is the error is due to its lack of seasonality and trend?

$\endgroup$
1
$\begingroup$

The error is likely due to the fact that your x is an irregular time series: there are temporal gaps, e.g. no data on 2015-01-03, 2015-01-04. You will have to implement your own version of decompose, e.g. following this approach:

https://stackoverflow.com/questions/12623027/how-to-analyse-irregular-time-series-in-r

$\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.