mse: Prediction error rates

View source: R/mse.R

mseR Documentation

Prediction error rates

Description

Calculation and plotting of prediction error rates (RMSEP, SEP, etc. or classification error rate) for models with quantitative or qualitative responses.

Note: In function mse, The R2 rate is calculated by R2 = 1 - MSEP(fitted model) / MSEP(no model), where MSEP = Sum((y_i - fit_i)^2)/n and "no model" is the overall mean of y. For predictions over CV or Test sets, and/or for non linear models, it can be different from the square of the correlation coefficient between the observed values and prediction.

See examples in plsr, plsda, etc.

Usage


mse(fm, formula = ~ 1, nam = NULL, digits = 3)

err(fm, formula = ~ 1, nam = NULL, digits = 4)

plotmse(obj, namx = "ncomp", nam = "msep", group = NULL,  col = NULL,
  legend = TRUE, legend.title = NULL, ncol = 1, ...)

Arguments

fm

An object containing at least data frames y (data) and fit (predictions). See for instance objects y and fit returned by function plsr.

formula

A right-hand-side formula defing the aggregation levels on which are calculated the error rates.

namx

For plotmse: Name (character string) of the column in obj to plot as x-axis. Default to nam = "ncomp".

nam

For mse: Name (character string) of the column to consider in fm$y for calulating the prediction error rate. If NULL (default), the last column of fm$y is considered. For plotmse: Name (character string) of the column in obj to plot as y-axis. Default to nam = "msep".

digits

The number of digits for the numerical outputs.

Arguments specific to plotmse:

obj

Data frame returned by mse or err.

group

A vector of length equal to the number of rows of obj defining the groups of rows to be plotted with different colors (default is NULL).

col

A color, or a vector of colors (of length equal to the number of groups), defining the color(s) of the lines representing the error rates.

legend

Only if there are groups. Logical indicationg is a legend is drawn for groups (Default to FALSE).

legend.title

Character string indicationg a title for the legend.

ncol

Number of columns drawn in the legend box.

...

Other arguments to pass in functions plot or lines

.

Value

A dataframe.


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.