# Novice Question: Where do the constants come from?

#### illmattic

##### New Member
Hello,

I have come across this in a book and I have a question about how to recreate this. When trying to calculate the residuals in a autoregression model, where do these constants (A,B) come from?

Thank you
Matt

#### Dason

They're typically estimated from the data

#### noetsi

##### Fortran must die
I am not sure what an autoregressive model is. Is this ARMA, regression with ARMA error, ARIMA?

I would think if you are running this in R or SAS it would generate these for you.

#### Dason

The question specifically states AR(1). You know that AR stands for auto-regressive right? And that ARIMA is really AR-I-MA for auto-regressive integrated moving average which just combines AR and MA models and allows for differencing directly in the model (the I component).

#### noetsi

##### Fortran must die
The question specifically states AR(1). You know that AR stands for auto-regressive right? And that ARIMA is really AR-I-MA for auto-regressive integrated moving average which just combines AR and MA models and allows for differencing directly in the model (the I component).
yeah I know that dason. I do time series for a living, I know what AR(1) is. I am not certain what disagreement you have with my answer. I was pointing out that for some software and some methods the software may calculate the residuals for you and the intercept as well. So you don't have to do that by hand. A here is the constant, B the slope as in any regression model. Generally in time series the error term has to be adjusted for AR error (or in some models for MA error as well) and stationarity is required. That is the normal assumptions, before the transformations, about the error term are not accurate.

#### illmattic

##### New Member
Thanks for all the replies.

They're typically estimated from the data
How would one go about estimating them if the time series is an exchange rate?

I would think if you are running this in R or SAS it would generate these for you.
I am running this with Python but when I run the residual code, it comes back with NaNs and I'm not sure why. Perhaps if I understood the statistics better I would understand why.

Matt

#### noetsi

##### Fortran must die
How you go about estimating them depends on what specific method you are using.

#### illmattic

##### New Member
Could there be a reason why residuals couldn't be calculated from autoregression?

#### illmattic

##### New Member
Can the same result be accomplished by having the independent variable be my times series shifted back 1 and conduct regular regression with ordinary least squares and then find the residuals for this?

#### noetsi

##### Fortran must die
You can calculate residuals that have auto regression in them. Residuals are simply the difference between what you predict with the model and the observed results. There is no way that having autoregression could make it impossible to generate residuals, residuals are how you test for errors in the assumptions usually (specialized tests using lags is how you test for autoregression, some tests are better than others). You might look up the use of HAC to deal with autoregression (or the use of ARMA or ARIMA models).

#### noetsi

##### Fortran must die
You can calculate residuals that have auto regression in them. Residuals are simply the difference between what you predict with the model and the observed results. There is no way that having autoregression could make it impossible to generate residuals, residuals are how you test for errors in the assumptions usually (specialized tests using lags is how you test for autoregression, some tests are better than others). You might look up the use of HAC to deal with autoregression (or the use of ARMA or ARIMA models).

#### noetsi

##### Fortran must die
time series is one of the most difficult types of statistics and not many outside economics do it. I wish you the best.

#### noetsi

##### Fortran must die
There are no true experts in time series on this board. And have been very few ever.