Learn R Programming

intsel (version 1.0.1)

predict.intsel: Predict Method for intsel fits

Description

description Obtains predictions from a fitted intsel object

Usage

# S3 method for intsel
predict(object, newx, type = "link", ...)

Value

A matrix containing the prediction.

Arguments

object

A fitted intsel object

newx

Optional, a matrix in which to look for variables with which to predict. If ommitted, the original data is used.

type

The type of prediction required. The default "link" is on the scale of the linear predictors; the alternative "response" is on the scale of the response variable.

...

Additional arguments passed to predict.

Examples

Run this code
n <- 1000
p.int <- 5
p.noint <- 3
intercept <- TRUE
p.screen <- 5

p.int.expand <- p.int*(p.int-1)/2
p.main <- p.int + p.noint
x <- matrix(rnorm(n * p.main), nrow = n, ncol = p.main)

# true model
# logit(p) = 0.1 + 0.3 x1 + 0.3 x2 + 0.3 x8 + 0.2 * x1 * x2

beta.true <- rep(0, p.main)
beta.true[c(1, 2, p.main)] <- 0.3
eta <- x %*% beta.true + 0.2 * x[, 1] * x[, 2]

if (intercept) eta <- eta + 0.1

py <- 1/(1 + exp(-eta))

y <- rbinom(n, 1, py)

nlam <- 30
lambdas <- exp(seq(log(0.1), log(0.00005), length.out = nlam))

# All the pairwise two-way interactions for the first p.screen variables 
# are included in the model and screened in a data-driven manner.
fit <- intsel(x = x,
              y = y,
              p.screen = 5,
              intercept = intercept,
              lambda = lambdas)
str(predict(fit))

Run the code above in your browser using DataLab