Skip to main content
added 12 characters in body
Source Link
Christoph Hanck
  • 34.8k
  • 3
  • 78
  • 137

I have created a VAR model in R (using the command VAR) and my model reports an R-squared of about 0.8 for the variable I'm most interested in. I'm trying to replicate that result by calculating the R-squared by hand. I have extracted the fitted values (using the command fitted(model_name)) and then I have used the following equation:

$$R^2 = 1- { \sum_{} (y-\hat y)^2 \over \sum_{}(y - \overline y)^2}.$$$$R^2 = 1- { \sum_{t} (y_t-\hat y_t)^2 \over \sum_{t}(y_t - \overline y)^2},$$

Withwith $y$$y_t$ = actual value, $ \hat y$$ \hat y_t$ = predicted (fitted) value and $ \overline y$ = the average of the actual value.

I am taking into account the fact that my model uses two lags, so I have two fitted values less than the total amount of points used to train. I'm making sure to pair the actual and predicted values correctly.

I have tried using this equation before in regular linear regression and I am able to replicate the value I get from R, however I cannot do it with this VAR model. Is it because when the R-squared is calculated for time series, something different is done? I have tried googling this and cannot find any reference to a different equation for the case of time series.

Any comments or suggestions as to what could be wrong will be greatly appreciated.

I have created a VAR model in R (using the command VAR) and my model reports an R-squared of about 0.8 for the variable I'm most interested in. I'm trying to replicate that result by calculating the R-squared by hand. I have extracted the fitted values (using the command fitted(model_name)) and then I have used the following equation:

$$R^2 = 1- { \sum_{} (y-\hat y)^2 \over \sum_{}(y - \overline y)^2}.$$

With $y$ = actual value, $ \hat y$ = predicted (fitted) value and $ \overline y$ = the average of the actual value.

I am taking into account the fact that my model uses two lags, so I have two fitted values less than the total amount of points used to train. I'm making sure to pair the actual and predicted values correctly.

I have tried using this equation before in regular linear regression and I am able to replicate the value I get from R, however I cannot do it with this VAR model. Is it because when the R-squared is calculated for time series, something different is done? I have tried googling this and cannot find any reference to a different equation for the case of time series.

Any comments or suggestions as to what could be wrong will be greatly appreciated.

I have created a VAR model in R (using the command VAR) and my model reports an R-squared of about 0.8 for the variable I'm most interested in. I'm trying to replicate that result by calculating the R-squared by hand. I have extracted the fitted values (using the command fitted(model_name)) and then I have used the following equation:

$$R^2 = 1- { \sum_{t} (y_t-\hat y_t)^2 \over \sum_{t}(y_t - \overline y)^2},$$

with $y_t$ = actual value, $ \hat y_t$ = predicted (fitted) value and $ \overline y$ = the average of the actual value.

I am taking into account the fact that my model uses two lags, so I have two fitted values less than the total amount of points used to train. I'm making sure to pair the actual and predicted values correctly.

I have tried using this equation before in regular linear regression and I am able to replicate the value I get from R, however I cannot do it with this VAR model. Is it because when the R-squared is calculated for time series, something different is done? I have tried googling this and cannot find any reference to a different equation for the case of time series.

Any comments or suggestions as to what could be wrong will be greatly appreciated.

Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link

How to calculate (by hand) the R-squared of a VAR time series model built using R?

I have created a VAR model in R (using the command VAR) and my model reports an R-squared of about 0.8 for the variable I'm most interested in. I'm trying to replicate that result by calculating the R-squared by hand. I have extracted the fitted values (using the command fitted(model_name)) and then I have used the following equation:

$$R^2 = 1- { \sum_{} (y-\hat y)^2 \over \sum_{}(y - \overline y)^2}.$$

With $y$ = actual value, $ \hat y$ = predicted (fitted) value and $ \overline y$ = the average of the actual value.

I am taking into account the fact that my model uses two lags, so I have two fitted values less than the total amount of points used to train. I'm making sure to pair the actual and predicted values correctly.

I have tried using this equation before in regular linear regression and I am able to replicate the value I get from R, however I cannot do it with this VAR model. Is it because when the R-squared is calculated for time series, something different is done? I have tried googling this and cannot find any reference to a different equation for the case of time series.

Any comments or suggestions as to what could be wrong will be greatly appreciated.