This function computes predictions based on fitted linear quantile models.

# S3 method for class 'rq.counts'
predict(object, newdata, offset,
  na.action = na.pass, type = "response",
  namevec = NULL, ...)

Arguments

object

an rq.counts object.

newdata

an optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.

offset

an offset to be used with newdata.

na.action

function determining what should be done with missing values in newdata. The default is to predict NA.

type

the type of prediction required. The default "response" is on the scale of the response variable, i.e. the values are back-transformed using the inverse of the transformation \(h^{-1}(Xb)\); the alternative "link" is on the scale of the linear predictors \(h(y) = Xb\); finally, predictions for marginal effects are given with "maref".

namevec

character giving the name of the covariate with respect to which the marginal effect is to be computed. If type = "maref", this argument is required. See maref.rq.counts.

...

not used.

Value

a vector or a matrix or an array of predictions.

Author

Marco Geraci

Examples


# Esterase data
data(esterase)

# Fit quantiles 0.25 and 0.75
fit <- rq.counts(Count ~ Esterase, tau = 0.5, data = esterase, M = 50)
cbind(fit$fitted.values, predict(fit, type = "response"))
#>          [,1]      [,2]
#> 1    125.0889  125.0889
#> 2    141.4300  141.4300
#> 3    144.9469  144.9469
#> 4    147.0990  147.0990
#> 5    147.8235  147.8235
#> 6    149.2832  149.2832
#> 7    157.5741  157.5741
#> 8    159.1304  159.1304
#> 9    159.1304  159.1304
#> 10   159.9144  159.9144
#> 11   160.7022  160.7022
#> 12   162.2895  162.2895
#> 13   163.8925  163.8925
#> 14   163.8925  163.8925
#> 15   165.5115  165.5115
#> 16   167.1465  167.1465
#> 17   168.7976  168.7976
#> 18   171.3051  171.3051
#> 19   178.1760  178.1760
#> 20   179.9364  179.9364
#> 21   180.8232  180.8232
#> 22   182.6099  182.6099
#> 23   183.5098  183.5098
#> 24   184.4143  184.4143
#> 25   185.3232  185.3232
#> 26   186.2365  186.2365
#> 27   189.9354  189.9354
#> 28   189.9354  189.9354
#> 29   191.8124  191.8124
#> 30   194.6628  194.6628
#> 31   196.5866  196.5866
#> 32   199.5081  199.5081
#> 33   201.4800  201.4800
#> 34   201.4800  201.4800
#> 35   204.4744  204.4744
#> 36   204.4744  204.4744
#> 37   206.4954  206.4954
#> 38   206.4954  206.4954
#> 39   210.5978  210.5978
#> 40   211.6361  211.6361
#> 41   211.6361  211.6361
#> 42   212.6795  212.6795
#> 43   213.7281  213.7281
#> 44   214.7818  214.7818
#> 45   217.9744  217.9744
#> 46   220.1292  220.1292
#> 47   220.1292  220.1292
#> 48   220.1292  220.1292
#> 49   222.3054  222.3054
#> 50   224.5031  224.5031
#> 51   226.7226  226.7226
#> 52   226.7226  226.7226
#> 53   226.7226  226.7226
#> 54   233.5138  233.5138
#> 55   234.6654  234.6654
#> 56   235.8226  235.8226
#> 57   235.8226  235.8226
#> 58   236.9856  236.9856
#> 59   240.5090  240.5090
#> 60   246.4984  246.4984
#> 61   247.7141  247.7141
#> 62   248.9358  248.9358
#> 63   253.8834  253.8834
#> 64   256.3940  256.3940
#> 65   261.4900  261.4900
#> 66   270.6535  270.6535
#> 67   273.3303  273.3303
#> 68   276.0336  276.0336
#> 69   294.2697  294.2697
#> 70   294.2697  294.2697
#> 71   298.6467  298.6467
#> 72   298.6467  298.6467
#> 73   298.6467  298.6467
#> 74   300.1201  300.1201
#> 75   304.5842  304.5842
#> 76   307.5971  307.5971
#> 77   313.7129  313.7129
#> 78   313.7129  313.7129
#> 79   318.3795  318.3795
#> 80   332.8006  332.8006
#> 81   336.0932  336.0932
#> 82   341.0932  341.0932
#> 83   344.4679  344.4679
#> 84   346.1678  346.1678
#> 85   353.0517  353.0517
#> 86   356.5448  356.5448
#> 87   360.0726  360.0726
#> 88   370.8671  370.8671
#> 89   370.8671  370.8671
#> 90   376.3853  376.3853
#> 91   403.2438  403.2438
#> 92   409.2443  409.2443
#> 93   413.2942  413.2942
#> 94   419.4445  419.4445
#> 95   447.1724  447.1724
#> 96   447.1724  447.1724
#> 97   476.7353  476.7353
#> 98   488.6198  488.6198
#> 99   560.8682  560.8682
#> 100  606.8577  606.8577
#> 101  703.5041  703.5041
#> 102  717.5042  717.5042
#> 103  735.3971  735.3971
#> 104  787.9084  787.9084
#> 105  803.5894  803.5894
#> 106  815.5547  815.5547
#> 107  835.8945  835.8945
#> 108  959.5442  959.5442
#> 109  983.4772  983.4772
#> 110 1064.1503 1064.1503
#> 111 1388.5688 1388.5688
#> 112 1395.4285 1395.4285
#> 113 1416.2118 1416.2118