Draws a data frame from the data-generating process of oprobit(),
ologit(), iop(), or iol(): an ordered latent equation
\(y^* = x'\beta + \epsilon\) cut at tau, and, when inflate is given,
a split equation \(s^* = z'\gamma + u\) that sends units with
\(s^* \le 0\) to the inflated category. Errors are standard normal
(link = "probit") or standard logistic ("logit"); with rho != 0
(probit only) \((u, \epsilon)\) are bivariate normal with that
correlation.
Usage
riop(
n,
beta,
tau,
gamma = NULL,
inflate = NULL,
rho = 0,
link = c("probit", "logit"),
X = NULL,
Z = NULL,
labels = NULL
)Arguments
- n
Number of observations (ignored when
Xis supplied).- beta
Outcome coefficients (length p).
- tau
Cutpoints, strictly increasing (length J - 1).
- gamma
Inflation coefficients, intercept first (length 1 + q);
NULLfor an uninflated process. A matrix with 1 + q rows and J - 1 columns gives every non-inflated category its own split equation (one column per non-inflated category, in category order): the generalised (category-specific split) process of Brown, Harris and Spencer (2020) fitted bysplit = "category".- inflate
The inflated category:
"bottom","middle","top", or a 0-based category index;NULLfor an uninflated process.- rho
Error correlation (probit with inflation only); a vector of length J - 1 (one per split equation) when
gammais a matrix.- link
"probit"or"logit".- X, Z
Optional covariate matrices (without intercept for
X; without intercept forZ, the intercept is added).- labels
Optional category labels (length J); default
0:(J-1).
Value
A data frame with the response y (an ordered factor when
labels is given, otherwise an integer 0..J-1), the covariates, and two
attributes: "regime" (the latent \(s\) indicator; 1 = ordered regime)
and "truth" (the parameter list).
Details
Covariates are drawn as: x1, ..., x<p> standard normal, z1, ...,
z<q> standard normal (the inflation equation also gets an intercept, the
first element of gamma), unless X / Z matrices are supplied.
See also
iop(), iol(), simulate.iord(); riord() is the low-level
response sampler given linear predictors (the d/p/q/r family), whereas
riop() draws whole data sets including the covariates.
Other simulation and diagnostics:
iord-distribution,
residuals.iord(),
simulate.iord()
Examples
d <- riop(500, beta = c(1, -0.5), tau = c(-0.5, 0.8), gamma = c(0.3, 1), inflate = "bottom")
table(d$y)
#>
#> 0 1 2
#> 323 100 77
mean(attr(d, "regime") == 0) # share of inflated-regime units
#> [1] 0.434
## a middle-inflated logit process with labelled categories
d2 <- riop(500, beta = c(0.8, -0.5), tau = c(-0.8, 0.8), gamma = c(0.2, 1),
inflate = "middle", link = "logit", labels = c("disagree", "neutral", "agree"))
table(d2$y)
#>
#> disagree neutral agree
#> 97 315 88