generate_ordered_data | R Documentation |
Generate a synthetic data set with an ordered non-numeric outcome, together with conditional probabilities and covariates' marginal effects.
generate_ordered_data(n)
n |
Sample size. |
First, a latent outcome is generated as follows:
Y_i^* = g ( X_i ) + \epsilon_i
with:
g ( X_i ) = X_i^T \beta
X_i := (X_{i, 1}, X_{i, 2}, X_{i, 3}, X_{i, 4}, X_{i, 5}, X_{i, 6})
X_{i, 1}, X_{i, 3}, X_{i, 5} \sim \mathcal{N} \left( 0, 1 \right)
X_{i, 2}, X_{i, 4}, X_{i, 6} \sim \textit{Bernoulli} \left( 0, 1 \right)
\beta = \left( 1, 1, 1/2, 1/2, 0, 0 \right)
\epsilon_i \sim logistic (0, 1)
Second, the observed outcomes are obtained by discretizing the latent outcome into three classes using uniformly spaced threshold parameters.
Third, the conditional probabilities and the covariates' marginal effects at the mean are generated using standard textbook formulas. Marginal effects are approximated using a sample of 1,000,000 observations.
A list storing a data frame with the observed data, a matrix of true conditional probabilities, and a matrix of true marginal effects at the mean of the covariates.
Riccardo Di Francesco
Di Francesco, R. (2025). Ordered Correlation Forest. Econometric Reviews, 1–17. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/07474938.2024.2429596")}.
ocf
## Generate synthetic data.
set.seed(1986)
data <- generate_ordered_data(1000)
head(data$true_probs)
data$me_at_mean
sample <- data$sample
Y <- sample$Y
X <- sample[, -1]
## Fit ocf.
forests <- ocf(Y, X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.