Predict method for dbreg objects

Description

Predict method for dbreg objects

Usage

## S3 method for class 'dbreg'
predict(
  object,
  newdata = NULL,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  ...
)

Arguments

object A ‘dbreg’ object.
newdata Data frame for predictions. Required for objects that were estimated using the ‘"mundlak"’ and ‘"moments"’ strategies, since ‘dbreg’ does not retain any data for these estimations.
interval Type of interval to compute: ‘"none"’ (default), ‘"confidence"’, or ‘"prediction"’. Note that ‘"confidence"’ intervals reflect uncertainty in the estimated mean, while ‘"prediction"’ intervals additionally account for residual variance. See predict.lm for details.
level Confidence level for intervals. Default is 0.95.
Additional arguments (currently unused).

Predicting on "demean" strategy objects

Predicting on ‘dbreg’ objects should generally work as expected. However, predictions from ‘"demean"’ strategy models carry two important caveats:

  1. Predictions require group means to transform back to the original scale. If ‘newdata’ contains the outcome variable, group means are computed from ‘newdata’ and used to return level predictions. If the outcome is absent, within-group predictions (deviations from group means) are returned instead, with a message.

  2. Confidence/prediction intervals are not supported. A demeaned model cannot account for uncertainty in the fixed-effects (since these were absorbed at estimation time), which in turn would yield intervals that are too narrow. Requesting intervals for ‘"demean"’ strategy models will return point predictions with a message. Users should re-estimate with a different strategy if intervals are needed.

See Also

[dbreg()] for examples.

Examples

library("dbreg")

mod = dbreg(Temp ~ Wind | Month, data = airquality)

# coefficients
coef(mod)
     Wind 
-0.743388 
coef(mod, fe = TRUE)  # include fixed effects
(Intercept)        Wind      Month6      Month7      Month8      Month9 
  74.188474   -0.743388   12.543643   16.362079   16.316286   10.279216 
# confidence intervals
confint(mod)
         2.5 %     97.5 %
Wind -1.037433 -0.4493427
# variance-covariance matrix
vcov(mod)
            (Intercept)        Wind      Month6      Month7      Month8
(Intercept)   4.2205624 -0.25730874 -1.57885933 -1.91972424 -1.95790554
Wind         -0.2573087  0.02213869  0.03001816  0.05934598  0.06263108
Month6       -1.5788593  0.03001816  2.54164270  1.31043885  1.31489316
Month7       -1.9197242  0.05934598  1.31043885  2.61902713  1.39786250
Month8       -1.9579055  0.06263108  1.31489316  1.39786250  2.63712696
Month9       -1.6011594  0.03193685  1.27327443  1.31558217  1.32032119
                 Month9
(Intercept) -1.60115942
Wind         0.03193685
Month6       1.27327443
Month7       1.31558217
Month8       1.32032119
Month9       2.54701213
attr(,"type")
[1] "iid"
attr(,"rss")
[1] 5604.977
attr(,"tss")
[1] 13617.88
# predictions
head(predict(mod, newdata = airquality))
[1] 68.68740 68.24137 64.82179 65.63951 63.55803 63.11199
head(predict(mod, newdata = airquality, interval = "confidence"))
       fit      lwr      upr
1 68.68740 66.16842 71.20639
2 68.24137 65.80451 70.67823
3 64.82179 62.61130 67.03227
4 65.63951 63.44749 67.83153
5 63.55803 61.22919 65.88686
6 63.11199 60.71775 65.50623