compute_insample: In-Sample Error

Description Usage Arguments Details Value References

View source: R/assessment.R

Description

This function computes training error, in-sample error, and optimism in MC simulation setting.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
compute_insample(
  data,
  ny,
  fit,
  rand,
  mcname = "mc",
  xname = "x",
  yname = "y",
  fitname = "fx",
  pred_name = "pred",
  insample_name = "y",
  error = c("squared", "absolute"),
  distribution = FALSE,
  mod,
  formula,
  ...
)

Arguments

data

MC data set generated by mc_data.

ny

the number of response at each x point

fit

True model function with x-named argument.

rand

Random sample generator function for error term. By default, rnorm

mcname

column name of the MC sample. By default, "mc".

xname

column name of the data. By default, "x".

yname

column name of the response. By default, "y".

fitname

column name of the true fit. By default, "fx".

pred_name

column name of the predicted values. By default, "pred".

insample_name

multiple column names when computing insample error

error

Choice of loss function. See loss.

distribution

return the error for each MC sample? FALSE by default. If TRUE, it gives the data.table.

mod

Model function.

formula

an object of class formula.

...

Additional arguments for mod. If you wand argument for rand, define one.

Details

In-sample error differs from Expected test error in that it is computed in the same predictor values. Instead, it uses new response values at each predictor point.

Err_{in} = \frac{1}{N} ∑_{i = 1}^N E_{y_0} [L(Y_i^{(0)}, \hat{f}(x_i)) \mid T]

Optimism is the difference between the insample error and the training error.

Value

Training error, Insample error, Optimism

References

Hastie, T., Tibshirani, R.,, Friedman, J. (2001). The Elements of Statistical Learning. New York, NY, USA: Springer New York Inc..


ygeunkim/youngtool documentation built on Dec. 14, 2019, 7:42 p.m.