svReg: Fit the structural varying-coefficient regression (svReg) in...

Description Usage Arguments Value Examples

View source: R/svReg.R

Description

Fit the structural varying-coefficient regression (svReg) in the linear regression setting

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
svReg(
  X,
  Z = NULL,
  Y,
  df_X,
  df_Z,
  lambda_seq = NULL,
  alpha = 0.5,
  tt = 0.1,
  zlinear = TRUE,
  tol = 1e-07,
  iter = 500
)

Arguments

X

N by p matrix of main predictors

Z

N by K matrix of modifying variables. Modifying variables can take the form of continuous variables or categorical variables or both. Categorical variable should be coded by dummy variables (0-1).

Y

vector of response variable

df_X

vector of degrees of freedom for each group of main predictors.

df_Z

vector of degrees of freedom for each group of modifying variables.

lambda_seq

sequence of the tuning parameter, lambda. Can take the form of a sequence or a scalar.

alpha

weight parameter between group penalty and individual penalty. Default value is 0.5.

tt

learning rate for the gradient descent procedure. Default value is 0.1.

zlinear

if true, the linear terms of the modifying variables are included. These terms are not regularized. Default value is TRUE.

tol

tolerance for convergence. Convergence is determined by the value of the objective function: abs(objective_old - objective_new) is compared with the tolerance value. Default value is 1e-7.

iter

maximum number of iteration for one lambda. Default value is 500.

Value

lambda_seq: lambda sequence used in the algorithm

beta_mat: p by (length of lambda_seq) matrix of estimated beta for scaled and centered main predictors. Each column represents the vector of fitted beta for each lambda value. The order of lambda is the order of lambda_seq. For a scalar value of lambda_seq, the output is a p-dim vector of fitted beta.

theta_mat: p by K by (length of lambda_seq) array of estimated theta for scaled and centered main predictors and modifying variables.

beta0_vec: intercept term

theta0_vec: coefficient for the linear terms of the modifying variables. If zlinear = FALSE, the output is the vector of zeros.

beta_raw_mat: estimated beta for raw main predictors (non-standardized)

theta_raw_mat: estimated theta for raw modifying variables (non-standardized)

beta0_raw_vec: intercept term (non-standardized)

theta0_raw_vec: coefficient for the linear terms of the modifying variables (non-standardized)

fmin_vec: vector of objective function values for the lambda_seq values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x = matrix(rnorm(100*5, 0, 1),100,5)
z1 = matrix(rnorm(100*3, 0, 1),100,3)
z2 = matrix(as.factor(sample(0:3, 100*2, prob=c(1/4,1/4,1/4,1/4), replace = TRUE)),100,2)
z2 = as.data.frame(model.matrix(~., data=as.data.frame(z2))[,-1])
z = cbind(z1, z2)
z = as.matrix(z)
y = 2*x[,1] - (2+2*z[,1])*x[,2] + (2+3*z[,4]+2*z[,5]-2*z[,6])*x[,3] + rnorm(100, 0, 1)
sv1=svReg(X=x,Z=z,Y=y,df_X=rep(1,5),df_Z=c(1,1,1,3,3),lambda_seq=c(1,0.5))
sv2=svReg(X=x,Z=z,Y=y,df_X=rep(1,5),df_Z=c(1,1,1,3,3),lambda_seq=0.5)
sv3=svReg(X=x,Z=z,Y=y,df_X=rep(1,5),df_Z=c(1,1,1,3,3),lambda_seq=0.5,zlinear=FALSE)
x[,3] = 2/3*x[,1] + 2/3*x[,2] + 1/3*rnorm(100, 0, 1)
y = x[,1] + x[,2] + (2+3*z[,4]+2*z[,5]-2*z[,6])*x[,4] + rnorm(100, 0, 1)
sv4=svReg(X=x,Z=z,Y=y,df_X=c(3,1,1),df_Z=c(1,1,1,3,3),lambda_seq=c(1,0.5))

rakheon/c2plasso documentation built on July 12, 2020, 12:07 a.m.