Prints an ocf.marginal
object.
# S3 method for class 'ocf.marginal'
print(x, latex = FALSE, ...)
Prints an ocf.marginal
object.
Compilation of the LATEX code requires the following packages: booktabs
, float
, adjustbox
. If
standard errors have been estimated, they are printed in parenthesis below each point estimate.
Di Francesco, R. (2025). Ordered Correlation Forest. Econometric Reviews, 1–17. https://doi.org/10.1080/07474938.2024.2429596.
## Generate synthetic data.
set.seed(1986)
data <- generate_ordered_data(100)
sample <- data$sample
Y <- sample$Y
X <- sample[, -1]
## Fit ocf.
forests <- ocf(Y, X)
## Marginal effects at the mean.
me <- marginal_effects(forests, eval = "atmean")
print(me)
#> ocf marginal effects results
#>
#> Data info:
#> Number of classes: 3
#> Sample size: 100
#>
#> Tuning parameters:
#> Evaluation: atmean
#> Bandwidth: 0.1
#> Number of trees: 2000
#> Honest forests: FALSE
#> Honesty fraction: 0
#>
#> Marginal Effects:
#> P'(Y=1) P'(Y=2) P'(Y=3)
#> x1 -0.020 -0.086 0.106
#> x2 -0.497 0.701 -0.204
#> x3 -0.090 -0.004 0.094
#> x4 -0.564 -1.294 1.858
#> x5 -0.036 0.043 -0.007
#> x6 0.000 0.000 0.000
print(me, latex = TRUE)
#> \begingroup
#> \setlength{\tabcolsep}{8pt}
#> \renewcommand{\arraystretch}{1.1}
#> \begin{table}[H]
#> \centering
#> \begin{adjustbox}{width = 0.75\textwidth}
#> \begin{tabular}{@{\extracolsep{5pt}}l c c c}
#> \\[-1.8ex]\hline
#> \hline \\[-1.8ex]
#> & Class 1 & Class 2 & Class 3 \\
#> \addlinespace[2pt]
#> \hline \\[-1.8ex]
#>
#> \texttt{x1} & -0.02 & -0.086 & 0.106 \\
#> \texttt{x2} & -0.497 & 0.701 & -0.204 \\
#> \texttt{x3} & -0.09 & -0.004 & 0.094 \\
#> \texttt{x4} & -0.564 & -1.294 & 1.858 \\
#> \texttt{x5} & -0.036 & 0.043 & -0.007 \\
#> \texttt{x6} & 0 & 0 & 0 \\
#>
#> \addlinespace[3pt]
#> \\[-1.8ex]\hline
#> \hline \\[-1.8ex]
#> \end{tabular}
#> \end{adjustbox}
#> \caption{Marginal effects.}
#> \label{table:ocf.marginal.effects}
#> \end{table}
#> \endgroup
## Add standard errors.
honest_forests <- ocf(Y, X, n.trees = 4000, honesty = TRUE)
honest_me <- marginal_effects(honest_forests, eval = "atmean", inference = TRUE)
print(honest_me, latex = TRUE)
#> \begingroup
#> \setlength{\tabcolsep}{8pt}
#> \renewcommand{\arraystretch}{1.1}
#> \begin{table}[H]
#> \centering
#> \begin{adjustbox}{width = 0.75\textwidth}
#> \begin{tabular}{@{\extracolsep{5pt}}l c c c}
#> \\[-1.8ex]\hline
#> \hline \\[-1.8ex]
#> & Class 1 & Class 2 & Class 3 \\
#> \addlinespace[2pt]
#> \hline \\[-1.8ex]
#>
#> \texttt{x1} & -0.095 & -0.151 & 0.246 \\
#> & (0.03) & (0.154) & (0.143) \\
#> \texttt{x2} & -0.05 & 0.121 & -0.071 \\
#> & (0.278) & (0.495) & (0.193) \\
#> \texttt{x3} & -0.061 & 0.011 & 0.05 \\
#> & (0.053) & (0.09) & (0.078) \\
#> \texttt{x4} & -0.303 & -0.124 & 0.427 \\
#> & (0.14) & (0.439) & (0.346) \\
#> \texttt{x5} & -0.041 & 0.037 & 0.004 \\
#> & (0.034) & (0.026) & (0.011) \\
#> \texttt{x6} & 0 & 0 & 0 \\
#> & (0) & (0) & (0) \\
#>
#> \addlinespace[3pt]
#> \\[-1.8ex]\hline
#> \hline \\[-1.8ex]
#> \end{tabular}
#> \end{adjustbox}
#> \caption{Marginal effects.}
#> \label{table:ocf.marginal.effects}
#> \end{table}
#> \endgroup