Learn R Programming

uniLasso (version 2.11)

simulate_counterexample: simulate counterexample data

Description

A particular counterexample where the first two features are strongly positively correlated, yet they have coefficients of opposite sign in a multiple regression.

Usage

simulate_counterexample(ntrain, ntest)

Value

a list with components "x", "y", "xtest", "ytest", "mutest", and "sigma", where "mutest" is the true test mean, and "ytest <- mutest + rnorm(ntest)*sigma."

Arguments

ntrain

number of training examples.

ntest

number of test examples.

Examples

Run this code
dat = simulate_counterexample(300,3000)
fit = cv.uniLasso(dat$x, dat$y)
err = mean( (predict(fit, dat$xtest,s="lambda.min")- dat$mutest)^2)

Run the code above in your browser using DataLab