generate_data {kko}R Documentation

generate response from nonparametric additive model

Description

The function generate response from additive models of various components.

Usage

generate_data(X, reg_coef, model = "linear", err_sd = 1)

Arguments

X

design matrix of additive model; rows are observations and columns are variables.

reg_coef

regression coefficient vector.

model

types of components. Default is "linear". Other choices are

linear linear regression.
poly polynomial of degree sampled from 2 to 4.
sinpoly sum of polynomial of sin and cos.
sinratio ratio of sin.
sinmix sampled from poly and sinratio.
err_sd

standard deviation of regression error.

Value

reponse vector

Author(s)

Xiaowu Dai, Xiang Lyu, Lexin Li

Examples

p=5 # number of predictors
s=2  # sparsity, number of nonzero component functions
sig_mag=100 # signal strength
n= 200 # sample size
model="poly" # component function type
X=matrix(rnorm(n*p),n,p) %*%chol(toeplitz(0.3^(0:(p-1))))   # generate design
reg_coef=c(rep(1,s),rep(0,p-s))  # regression coefficient
reg_coef=reg_coef*(2*(rnorm(p)>0)-1)*sig_mag
y=generate_data(X,reg_coef,model) # reponse vector



[Package kko version 1.0.1 Index]