King
King

Reputation: 67

constant variance for a time series data in R

So i have been trying to find out a test for constant variance in time series data but failed to find a proper way to do it. I Have used Bartlett's test for checking constant variance in a regression model earlier but couldn't find one for time series data. Kindly guide me with a solution.

Upvotes: 1

Views: 2611

Answers (1)

DaveR
DaveR

Reputation: 2358

For stationarity you can use any test like: box-ljung or KPSS For variance you can use the McLeod.Li.test or Box.Coxlambda. Personally I prefer the Box.Coxlambda

library(fpp)
data(elec) # random dataset
kpss.test(elec) # p = 0.01, series is not stationary
kpss.test(diff(elec, ndiffs(elec)) ) # after differencing, series is stationary 

#variance 
lambda <- BoxCox.lambda(elec) # = 0.27
lambda # if lambda was around 1, then you do not need any power transform
new_ts <- BoxCox(elec,lambda)

Upvotes: 2

Related Questions