Learn R Programming

spareg (version 1.1.1)

constructor_screencoef: Constructor Function for Building 'screencoef' Objects

Description

The created function will return a object of class 'screencoef' which constitutes of a list. The attributes of the generating object will include by default type, which can take one of two values "prob" (indicating probabilistic screening should be employed), "fixed" (indicating that the top nscreen variables should be employed).

Usage

constructor_screencoef(name, generate_fun)

Value

a function which in turn creates an object of class 'screencoef'

Arguments

name

character

generate_fun

function for generating the screening coefficient. This function should have arguments and y (vector of responses -- standardized for Gaussian family), x (the matrix of standardized predictors) and a 'screencoef' object.

Details

Creates an object class 'screencoef' using arguments passed by user.

Examples

Run this code
generate_scr_sirs <- function(y, x, object) {
  res_screen <- do.call(function(...)
    VariableScreening::screenIID(x, y, ...),
    object$control)
  coefs <- res_screen$measurement
  coefs
}
screen_sirs <- constructor_screencoef("screen_sirs",
  generate_fun = generate_scr_sirs)
example_data <- simulate_spareg_data(n = 100, p = 400, ntest = 100)
spar_example <- spar(example_data$x, example_data$y,
  screencoef = screen_sirs(control = list(method = "SIRS")),
  rp = rp_sparse())
spar_example

Run the code above in your browser using DataLab