knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = identical(Sys.getenv("IN_PKGDOWN"), "true") ) library(plssem)
This vignette demonstrates how to fit an ordinal regression model with plssem
using the titanic dataset.
In plssem, regression-style model syntax like y ~ x1 + x2 is supported.
When the dependent variable (and/or predictors) are ordinal.
Ordinal variables can be supplied via the ordered argument, or by
making sure they are ordered in the dataset.
head(titanic[, c("Survived", "Age", "Sex", "Female", "Pclass")])
This model predicts survival as a function of age and sex.
m_linear <- "Survived ~ Age + Female" fit_linear <- pls( m_linear, data = titanic, ordered = "Survived", boot.R = 50, bootstrap = TRUE, boot.parallel = "multicore", boot.ncores = 2 ) summary(fit_linear)
Optional: evaluate predictive performance.
pls_predict(fit_linear, benchmark = "acc")
To include a non-linear (interaction) effect, add an interaction term. With
ordinal indicators and interactions, plssem automatically switches to the
Monte-Carlo ordinal PLSc estimator.
m_int <- "Survived ~ Age + Female + Age:Female" fit_int <- pls( m_int, data = titanic, ordered = "Survived", boot.R = 50, bootstrap = TRUE, boot.parallel = "multicore", boot.ncores = 2 ) summary(fit_int)
pls_predict(fit_int, benchmark = "acc")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.