BoxCox.FitAR {FitAR} | R Documentation |
This is a methods function to do a Box-Cox analysis for models fit using FitAR and FitARLS.
## S3 method for class 'FitAR': BoxCox(object, interval = c(-1, 1), type = "BoxCox", InitLambda = "none", ...)
object |
output from FitAR or FitARLS |
interval |
interval to be searched for optimal transformation |
type |
Ignored unless, InitLambda!="none". Type of transformation, default is "BoxCox". Otherwise a simple power transformation. |
InitLambda |
default "none". Otherwise a numerical value giving the transformation parameter. |
... |
optional arguments passed to optimize |
If no transformation is used on the data, then the original data is used. But if a transformation has already been used, we need to inverse transform the data to recover the untransformed data.
For lambda!=0, the Box-Cox transformation is of x is (x-1)^lambda/lambda whereas the regular power transformation is simply x^lambda. When lambda=0, it is log in both cases.
If the minimum data value is <= 0, a small positive constant, equal to the negative of the minimum plus 0.25, is added to all the data values.
No value returned. Graphical output produced as side-effect. The plot shows relative likelihood function as well as the MLE and a confidence interval.
The MASS package has a similar function boxcox
but this is implemented
only for regression and analysis of variance.
A.I. McLeod
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. Journal of Royal Statistical Society, Series B, vol. 26, pp. 211-246.
McLeod, A.I. and Zhang, Y. (2006a). Partial autocorrelation parameterization for subset autoregression. Journal of Time Series Analysis, 27, 599-612.
McLeod, A.I. and Zhang, Y. (2006b, under review). Subset Autoregression Modelling. Journal of Statistical Sofware.
#lynx time series. ARp subset model. out<-FitARLS(lynx, c(1,2,4,10,11)) BoxCox(out) # #sunspots. ARz subset model. z<-sunspot.year+0.25 p<-SelectModel(z, SubsetModel="z", lag.max=25, Best=1) out<-FitAR(z, p) BoxCox(out) # #compare with AR(10) z<-sunspot.year+0.25 out<-FitAR(z, 10) BoxCox(out) # #Back transform after fitting model to log(lynx) p<-SelectModel(log(lynx),SubsetModel="z",Best=1) ans<-FitAR(log(lynx), p) BoxCox(ans, InitLambda=0) # #again with ARp subset model p<-SelectModel(log(lynx),SubsetModel="p",Best=1) ans<-FitARLS(log(lynx), p) BoxCox(ans, InitLambda=0)