getR2: get R2 from mvr object

Description Usage Arguments Examples

Description

Alternative to pls package's 'R2'. While 'R2' requires a 'newdata' dataframe which combines both predictors and target, 'getR2' lets you put in 'newx' and 'newy' separately. Aside from that, declaring 'estimate' in 'getR2' remind you which value you got.

Usage

1
2
getR2(mvr, ncomp = mvr$ncomp, estimate, newx = NULL, newy = NULL,
  showprint = TRUE)

Arguments

mvr

mvr object

ncomp

number of component

estimate

a subset of c("train", "CV", "test")

newx

predictors for test group

newy

measured value for test group

showprint

show result in console

Examples

1
2
3
4
5
6
require(pls)
data(yarn)
model <- plsr(density ~ NIR, 6, data = yarn, validation = "CV")
R2(model)
getR2(model, estimate = "train") # return R2 at particular ncomp without intercept value
getR2(model, estimate = "CV")

chengvt/cheng documentation built on May 13, 2019, 3:52 p.m.