public class AR
extends java.lang.Object
implements java.io.Serializable
Contrary to the movingaverage (MA) model, the autoregressive model is not always stationary as it may contain a unit root.
The notation AR(p)
indicates an autoregressive
model of order p. For an AR(p)
model to be weakly stationary,
the inverses of the roots of the characteristic polynomial must be less
than 1 in modulus.
Two general approaches are available for determining the order p. The first approach is to use the partial autocorrelation function, and the second approach is to use some information criteria.
Autoregression is a good start point for more complicated models. They often fit quite well (donâ€™t need the MA terms). And the fitting process is fast (MLEs require some iterations). In applications, easily fitting autoregressions is important for obtaining initial values of parameters and in getting estimates of the error process. Least squares is a popular choice, as is the YuleWalker procedure. Unlike the YuleWalker procedure, least squares can produce a nonstationary fitted model. Both the YuleWalker and least squares estimators are noniterative and consistent, so they can be used as starting values for iterative methods like MLE.
Modifier and Type  Class and Description 

static class 
AR.Method
The fitting method.

Constructor and Description 

AR(double[] x,
double[] ar,
double b,
AR.Method method)
Constructor.

Modifier and Type  Method and Description 

double 
adjustedRSquared()
Returns adjusted R^{2} statistic.

double[] 
ar()
Returns the linear coefficients of AR (without intercept).

int 
df()
Returns the degreeoffreedom of residual standard error.

static AR 
fit(double[] x,
int p)
Fits an autoregressive model with YuleWalker procedure.

double[] 
fittedValues()
Returns the fitted values.

double 
forecast()
Returns 1step ahead forecast.

double[] 
forecast(int l)
Returns lstep ahead forecast.

double 
intercept()
Returns the intercept.

double 
mean()
Returns the mean of time series.

static AR 
ols(double[] x,
int p)
Fits an autoregressive model with least squares method.

static AR 
ols(double[] x,
int p,
boolean stderr)
Fits an autoregressive model with least squares method.

int 
p()
Returns the order of AR.

double[] 
residuals()
Returns the residuals, that is response minus fitted values.

double 
RSquared()
Returns R^{2} statistic.

double 
RSS()
Returns the residual sum of squares.

java.lang.String 
toString() 
double[][] 
ttest()
Returns the ttest of the coefficients (including intercept).

double 
variance()
Returns the residual variance.

double[] 
x()
Returns the time series.

public AR(double[] x, double[] ar, double b, AR.Method method)
x
 the time seriesar
 the estimated weight parameters of AR(p).b
 the intercept.method
 the fitting method.public double[] x()
public double mean()
public int p()
public double[][] ttest()
public double[] ar()
public double intercept()
public double[] residuals()
public double[] fittedValues()
public double RSS()
public double variance()
public int df()
public double RSquared()
In the case of ordinary leastsquares regression, R^{2} increases as we increase the number of variables in the model (R^{2} will not decrease). This illustrates a drawback to one possible use of R^{2}, where one might try to include more variables in the model until "there is no more improvement". This leads to the alternative approach of looking at the adjusted R^{2}.
public double adjustedRSquared()
public static AR fit(double[] x, int p)
x
 the time series.p
 the order.public static AR ols(double[] x, int p)
x
 the time series.p
 the order.public static AR ols(double[] x, int p, boolean stderr)
x
 the time series.p
 the order.stderr
 the flag if estimate the standard errors of parameters.public double forecast()
public double[] forecast(int l)
public java.lang.String toString()
toString
in class java.lang.Object