Skip to contents

Predictions from an ordered / inflated ordered fit

Usage

# S3 method for class 'iord'
predict(
  object,
  newdata = NULL,
  type = c("prob", "prob_conditional", "class", "prob_outcome", "regime", "inflated",
    "posterior", "zeros", "mean", "cumulative", "link", "link_inflation"),
  offset = NULL,
  offset_inflation = NULL,
  se.fit = FALSE,
  ...
)

Arguments

object

An "iord" object.

newdata

Optional data frame of covariate profiles; if omitted, the estimation data are used. Every covariate of both equations must be present (a missing one is an error); extra columns are ignored; a factor level not seen at estimation is an error; rows with missing covariate values give NA predictions.

type

What to return:

  • "prob" (default): the n x J matrix of category probabilities \(P(y = j)\) (for random-intercept fits: marginal over the random intercept, i.e. population-averaged);

  • "prob_conditional": for random-intercept fits, the category probabilities at \(u = 0\) (a median unit); identical to "prob" otherwise;

  • "class": the modal category (a factor with the response levels);

  • "prob_outcome": the ordered-stage probabilities \(P(y = j \mid s = 1)\) (equal to "prob" for uninflated models);

  • "regime": \(P(s = 1)\), the probability of the ordered (non-inflated) regime (1 for uninflated models);

  • "inflated": \(P(s = 0) = 1 - P(s = 1)\);

  • "posterior": the posterior probability that an observation in the inflated category is an inflated case, \(P(s = 0 \mid y = k) = (1 - P(s = 1)) / P(y = k)\), and 0 for observations in other categories (needs the response: available for the estimation data, or when newdata contains it); under a category-specific split, the probability that the observation was tempered into \(k\) from another category;

  • "zeros": the two components of \(P(y = k)\) – an n x 2 matrix with columns inflation (through the inflation process: \(1 - P(s = 1)\) under a common split, or the tempered mass under a category-specific split) and ordered (through the ordered stage: \(P(s = 1, y^* = k)\)), which sum to \(P(y = k)\) – Harris and Zhao's (2007) two types of zeros;

  • "mean": the expected category index \(\sum_j j\,P(y = j)\) on the 0, ..., J-1 scale;

  • "cumulative": the n x (J-1) matrix of \(P(y \le j)\);

  • "link": the outcome-equation linear predictor \(x'\beta\) (a matrix with one column per cutpoint when any term is non-parallel);

  • "link_inflation": the inflation-equation linear predictor \(z'\gamma\) (one column per split equation under a category-specific split).

Under a category-specific split (split = "category"), "regime" and "inflated" return an n x (J-1) matrix with one column per non-inflated category (\(P(s_j = 1)\) for a unit whose ordered outcome would be \(j\)).

offset, offset_inflation

Optional offsets for newdata (column names in newdata or numeric vectors); the fitted offsets are used when newdata is NULL.

se.fit

If TRUE (probability types only, including "zeros", "mean", and "cumulative"), also return delta-method standard errors: a list with fit and se.fit of the same shape.

...

Unused.

Value

A numeric vector, matrix, or factor as described under type; with se.fit = TRUE, a list fit / se.fit.

See also

first_difference() and ame() for changes in these probabilities; fitted() (the "prob" matrix at the estimation data); ranef() for random-intercept fits.

Other quantities of interest: ame(), first_difference(), plot.iop_fd()

Examples

data(bp)
m <- iop(violence ~ loggdppc + parliament + disaster | loggdppc + parliament + disaster,
         data = bp, inflate = "bottom")
#> The inflation equation contains no covariate that is excluded from the outcome equation; the split is then identified by functional form alone. An exclusion restriction is advisable.
head(predict(m), 3)                                  # P(y = j)
#>           none repression   civil war
#> [1,] 0.9652023 0.02342124 0.011376458
#> [2,] 0.9750543 0.01164405 0.013301697
#> [3,] 0.9747663 0.01698166 0.008252006
head(predict(m, type = "class"), 3)                  # modal category
#> [1] none none none
#> Levels: none repression civil war
head(predict(m, type = "prob_outcome"), 3)           # P(y = j | ordered regime)
#>           none repression civil war
#> [1,] 0.5784620  0.2837240 0.1378140
#> [2,] 0.2711306  0.3402180 0.3886514
#> [3,] 0.5782970  0.2837961 0.1379069
summary(predict(m, type = "inflated"))               # P(structurally peaceful)
#>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
#> 0.000e+00 2.950e-06 1.103e-02 2.174e-01 2.743e-01 9.998e-01 
## posterior probability that an observed "none" is a structural zero
summary(predict(m, type = "posterior")[bp$violence == "none"])
#>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
#> 0.000e+00 4.950e-06 5.735e-02 3.040e-01 7.142e-01 1.000e+00 
## covariate profiles, with delta-method standard errors
nd <- data.frame(loggdppc = c(7, 9), parliament = 0, disaster = 0)
predict(m, newdata = nd, se.fit = TRUE)
#> $fit
#>           none repression  civil war
#> [1,] 0.6849617  0.2302943 0.08474398
#> [2,] 0.8027035  0.1438250 0.05347151
#> 
#> $se.fit
#>            none repression   civil war
#> [1,] 0.01542900 0.01213905 0.008108648
#> [2,] 0.02988085 0.02308961 0.008791315
#> 
predict(m, newdata = nd, type = "regime")
#> [1] 0.9999973 0.6188046