4

I wanted to model some data with heteroscedastic errors using a gls model of the form

library(nlme)
gls(y ~ x, data = data, weights=varPower(1, form= ~y))

That is, with the variance being a power function of the dependent variable y (or the independent variable x?). See link here for an example.

For my application I would also need 95% prediction intervals on the model predictions for a specific value of x. Would anybody know how to calculate these for a gls model with this kind of error structure? (gls does not appear to provide for a predict method with interval="prediction") Or alternative approaches that would allow for such an error structure and allow me to calculate prediction intervals? (A solution using weighted regression is posted here, but I would prefer to use gls instead, as that fits the appropriate power coefficient describing the mean-variance relationship)

Tom Wenseleers
  • 2,413
  • 1
  • 21
  • 39
  • Is it possible to apply robust, sandwich based standard errors to the GLS model? I think it is, but I don't know if it's been implemented. – AdamO Mar 05 '18 at 14:09
  • I had been looking around to see if this could be done, but I couldn't find how to do that so far... – Tom Wenseleers Mar 05 '18 at 14:15
  • I gave an answer. I think it can be done. The issue, I didn't see in the subtext of the title, is that sandwich doesn't give prediction intervals. It is about inference on regression coefficients. To obtain prediction intervals, you have to explicitly model the heteroscedasticity, above and beyond specifying a covariance structure. Consider using splines for the residuals: I have an answer about doing this here: https://stats.stackexchange.com/questions/37943/simultaneous-heteroscedasticity-and-heavy-tails-in-a-regression-model/320097#320097 – AdamO Mar 05 '18 at 15:03
  • OK I deleted the "answer" since it was not the answer to the question you were asking, but I reposted it [here](https://stats.stackexchange.com/questions/331840/how-to-calculate-sandwich-standard-errors-for-generalized-least-squares-models/331841#331841) if the method is still of any interest. It should be a useful example of manipulating these kinds of data, and using the splines approach I recommended. – AdamO Mar 05 '18 at 16:21
  • how about quantile regression? – tea_pea Mar 26 '18 at 20:14
  • Hmm I used quantile regression before but often had fitting problems with the quantreg package unfortunately, so I'd like to stick with gls if possible... – Tom Wenseleers Mar 27 '18 at 12:33

0 Answers0