Prints an ocf.marginal object.

# S3 method for class 'ocf.marginal'
print(x, latex = FALSE, ...)

Arguments

x

An ocf.marginal object.

latex

If TRUE, prints LATEX code.

...

Further arguments passed to or from other methods.

Value

Prints an ocf.marginal object.

Details

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.

References

  • Di Francesco, R. (2023). Ordered Correlation Forest. arXiv preprint arXiv:2309.08755.

See also

Author

Riccardo Di Francesco

Examples

## 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.008  -0.167   0.159
#> x2  -0.034   0.066  -0.033
#> x3  -0.089   0.014   0.075
#> x4  -0.047  -0.148   0.194
#> x5  -0.022   0.027  -0.004
#> x6   0.009  -0.027   0.018
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.008 & -0.167 & 0.159 \\ 
#>         \texttt{x2} & -0.034 & 0.066 & -0.033 \\ 
#>         \texttt{x3} & -0.089 & 0.014 & 0.075 \\ 
#>         \texttt{x4} & -0.047 & -0.148 & 0.194 \\ 
#>         \texttt{x5} & -0.022 & 0.027 & -0.004 \\ 
#>         \texttt{x6} & 0.009 & -0.027 & 0.018 \\ 
#> 
#>         \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.069 & -0.116 & 0.185 \\ 
#>                      & (0.031) & (0.141) & (0.084) \\ 
#>         \texttt{x2} & -0.002 & 0.008 & -0.006 \\ 
#>                      & (0.027) & (0.05) & (0.016) \\ 
#>         \texttt{x3} & -0.061 & 0.011 & 0.05 \\ 
#>                      & (0.047) & (0.076) & (0.077) \\ 
#>         \texttt{x4} & -0.028 & -0.021 & 0.049 \\ 
#>                      & (0.012) & (0.039) & (0.034) \\ 
#>         \texttt{x5} & -0.035 & 0.033 & 0.002 \\ 
#>                      & (0.024) & (0.022) & (0.009) \\ 
#>         \texttt{x6} & -0.002 & -0.009 & 0.011 \\ 
#>                      & (0.02) & (0.042) & (0.028) \\ 
#> 
#>         \addlinespace[3pt]
#>         \\[-1.8ex]\hline
#>         \hline \\[-1.8ex]
#>         \end{tabular}
#>         \end{adjustbox}
#>         \caption{Marginal effects.}
#>         \label{table:ocf.marginal.effects}
#>     \end{table}
#> \endgroup