Learn R Programming

Sieve (version 2.1)

GenSamples: Generate some simulation/testing samples with nonlinear truth.

Description

This function is used in several examples in the package.

Usage

GenSamples(
  s.size,
  xdim = 1,
  x.dis = "uniform",
  x.para = NULL,
  frho = "linear",
  frho.para = 100,
  y.type = "continuous",
  noise.dis = "normal",
  noise.para = 0.5
)

Value

a data.frame. The variable Y is the outcome (either continuous or binary). Each of the rest of the variables corresponds to one dimension of the feature vector.

Arguments

s.size

a number. Sample size.

xdim

a number. Dimension of the feature vectors X.

x.dis

a string. It specifies the distribution of feature X. The default is uniform distribution over xdim-dimensional unit cube.

x.para

extra parameter to specify the feature distribution.

frho

a string. It specifies the true regression/log odds functions used to generate the data set. The default is a linear function.

frho.para

extra parameter to specify the true underlying regression/log odds function.

y.type

a string. Default is y.type = 'continuous', meaning the outcome is numerical and the problem is regression. Set it to y.type = 'binary' for binary outcome.

noise.dis

a string. For the distribution of the noise variable (under regression probelm settings). Default is Gaussian distribution.

noise.para

a number. It specifies the magnitude of the noise in regression settings.

Examples

Run this code
xdim <- 1 #1 dimensional feature
#generate 1000 training samples
TrainData <- GenSamples(s.size = 1000, xdim = xdim)
#generate some noise-free testing samples
TestData <- GenSamples(s.size = 1000, xdim = xdim, noise.para = 0)

Run the code above in your browser using DataLab