Dear Statalists,
I’m applying xtqreg on a panel of dimension i = 24 and t = 731 using bootstrapping for the standard errors and I would like to get the residuals.
Unfortunately predict […], residuals give the infamous error : "option residuals not allowed, r(198)" even after updating the package.
When I run the built-in option: “predict(yhat)” I get the following error message:
The same happen with greater replications.
To get fitted values, I then tried to use “predict yhat” and ran smoothly (as in (2) in the code below). In addition, I also tried avoiding bootstrapping and use the built-in option of xtqreg (as in (1)). Comparing the two approaches, I get of course identical coefficients, different standard errors, yet completely different fitted values for the same quantile.
Can someone help me understand why? Looking at the residuals (below), I personally have more confidence in the built-in option. Is it because the built-in option ignores statistically insignificant point estimates?
Thanks a lot for your help and have a good one!
I’m applying xtqreg on a panel of dimension i = 24 and t = 731 using bootstrapping for the standard errors and I would like to get the residuals.
Unfortunately predict […], residuals give the infamous error : "option residuals not allowed, r(198)" even after updating the package.
When I run the built-in option: “predict(yhat)” I get the following error message:
Code:
bootstrap, cluster(hour) rep(20) seed(123): xtqreg price solar wind load cable lag_price holiday mon tue thu fri sat sun jan feb mar may jun jul aug sep oct nov dec, quantile(0.5) predict(yhat) ------ Error ------ Bootstrap replications (20): xxxxxxxxxxxxxxxxxxxx done x: Error occurred when bootstrap executed xtqreg. insufficient observations to compute bootstrap standard errors; no results will be saved r(2000);
To get fitted values, I then tried to use “predict yhat” and ran smoothly (as in (2) in the code below). In addition, I also tried avoiding bootstrapping and use the built-in option of xtqreg (as in (1)). Comparing the two approaches, I get of course identical coefficients, different standard errors, yet completely different fitted values for the same quantile.
Can someone help me understand why? Looking at the residuals (below), I personally have more confidence in the built-in option. Is it because the built-in option ignores statistically insignificant point estimates?
Thanks a lot for your help and have a good one!
Code:
* no bootstrap (1)
xtqreg price solar wind load cable lag_price holiday mon tue thu fri sat sun jan feb mar may jun jul aug sep oct nov dec, ls q(0.5) predict(yhat)
gen res__5 = yhat__5 – price
* bootstrap (2)
foreach q in 1 2 3 4 5 6 7 8 9 {
bootstrap, cluster(hour) rep(20) seed(123): xtqreg price solar wind load cable lag_price holiday mon tue thu fri sat sun jan feb mar may jun jul aug sep oct nov dec, quantile(0.`q')
*save results
eststo q_`q'
}
est restore q_5
predict yhat_q5
gen res_q5 = yhat_q5 - price
Code:
Fitted values and residuals from (1) and (2) Bootstrap (2) Buil-in (1) yhat_q5 res_q5 yhat__5 res__5 82.72142 81.34142 2.114745 .7347449 86.12959 86.0396 4.127318 4.037318 90.62315 90.54315 8.959707 8.879707 94.21761 94.16761 14.13149 14.08149 101.3495 101.2695 26.46717 26.38717 107.6854 107.5954 40.13287 40.04287 114.6512 114.1212 48.60219 48.07219 122.9444 120.9144 54.53706 52.50706 [...]

Comment