Learn R Programming

cvms (version 0.2.0)

cv_plot: Wrapper for plotting common plots using ggplot2

Description

Creates various plots based on the output of cvms::cross_validate()

Usage

cv_plot(x, type)

Arguments

x

Object returned by cvms::cross_validate() (tbl)

type

Type of plot.

Gaussian

'RMSE' - boxplot

'r2' - boxplot

'IC' - boxplot

'coefficients' - boxplot

Binomial

"ROC" - ROC curve

Examples

Run this code
# NOT RUN {
# Attach packages
library(cvms)
library(groupdata2) # fold()

# Load data (included in cvms)
data <- participant.scores

# Fold data
data <- fold(data, k = 4,
             cat_col = 'diagnosis',
             id_col = 'participant')

# Cross-validate a gaussian model
CVgauss <- cross_validate(data,
                          "score~diagnosis",
                          family='gaussian')

# Plot results for gaussian model
cv_plot(CVgauss, type = 'RMSE')
cv_plot(CVgauss, type = 'r2')
cv_plot(CVgauss, type = 'IC')
cv_plot(CVgauss, type = 'coefficients')

# Cross-validate a binomial model
CVbinom <- cross_validate(data,
                          "diagnosis~score",
                          family='binomial')

# Plot results for binomial model
cv_plot(CVbinom, type = 'ROC')
# }

Run the code above in your browser using DataLab