---
title: "Educational dataset example"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Educational dataset example}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
library(OrdinalCompositions)
#library(ggplot2)
data("educFM", package = "OrdinalCompositions")

father <- as.matrix(educFM[,2:4])
ya <- father / rowSums(father)

mother <- as.matrix(educFM[,5:7])
xa <- mother / rowSums(mother)

x <- cbind(xa[,3], xa[,2], xa[,1])
y <- cbind(ya[,3], ya[,2], ya[,1])

N <- nrow(y)

ydata <- split(y, seq_len(N))
xdata <- split(x, seq_len(N))

weights_orig <- c(1,1)
```

---

```{r model}
res <- ordinal_regression_simplex(
  xdata,
  ydata,
  weights = weights_orig,
  lambda2_grid = 0,
  method = "gcv",
  do_bootstrap = TRUE,
  B = 200,
  compute_opi = TRUE,
  compute_R2 = TRUE,
  compute_OCC = TRUE
)
```

---

```{r results}
cat("Estimated A_hat\n")
print(round(res$A_hat, 4))

cat("Wasserstein R2\n")
print(res$R2)

cat("OPI\n")
print(res$OPI)

cat("OCC\n")
print(res$OCC)

cat("Frechet mean matrix\n")
print(round(res$bootstrap$Frechet, 4))
```

