Skip to contents

Source: Hastie, Tibshirani and Friedman, The Elements of Statistical Learning (2nd ed., 2009), section 3.2, equation (3.13): F = ((RSS0 - RSS1)/(p1 - p0)) / (RSS1/(N - p1 - 1)), which under the Gaussian null is F(p1 - p0, N - p1 - 1).

Usage

Fnested(model0, model1, X, y)

Arguments

model0, model1

Integer column indices of X in each model, 1-based; model0 must be nested in model1. An intercept is always added.

X

Numeric matrix of predictors without an intercept column.

y

Numeric response.

Value

list: statistic, p_value, df1, df2, rss0, rss1, p0, p1, n, method.

Examples

set.seed(1)
X <- matrix(rnorm(60), 20, 3)
Fnested(1L, c(1L, 2L, 3L), X, X[, 1] + rnorm(20))$statistic
#> [1] 1.165961