spcrglm: Fit a sparse principal component regression for generalized...

View source: R/spcrglm.R

spcrglmR Documentation

Fit a sparse principal component regression for generalized linear models (SPCR-glm)

Description

This function computes a principal component regression for generalized linear models via sparse regularization.

Usage

spcrglm(x, y, k, family=c("binomial","poisson","multinomial"), lambda.B, 
	lambda.gamma, w=0.1, xi=0.01, adaptive=FALSE, q=1, center=TRUE, scale=FALSE)

Arguments

x

A data matrix.

y

A response data.

k

The number of principal components.

family

Response type.

lambda.B

The regularization parameter for the parameter B.

lambda.gamma

The regularization parameter for the coefficient vector γ.

w

Weight parameter with w ≥ 0. The default is 0.1.

xi

The elastic net mixing parameter with 0≤ α ≤ 1. The default is 0.01.

adaptive

If "TRUE", the adaptive SPCR-glm (aSPCR-glm) is used.

q

The tuning parameter that controls weights in aSPCR-glm. The default is 1.

center

If "TRUE", the data matrix is centered.

scale

If "TRUE", the data matrix is scaled.

Value

loadings.B

the loading matrix B

gamma

the coefficient

gamma0

intercept

loadings.A

the loading matrix A

Author(s)

Shuichi Kawano
skawano@ai.lab.uec.ac.jp

References

Kawano, S., Fujisawa, H., Takada, T. and Shiroishi, T. (2018). Sparse principal component regression for generalized linear models. Compuational Statistics & Data Analysis, 124, 180–196.

See Also

cv.spcrglm

Examples

# binomial
n <- 100
np <- 5
nu0 <- c(-1, 1)
set.seed(4)
x <- matrix( rnorm(np*n), n, np )
y <- rbinom(n,1,1-1/(1+exp(  (nu0[1]*x[ ,1] + nu0[2]*x[ ,2]  ))))
spcrglm.fit <- spcrglm(x=x, y=y, k=2, family="binomial", lambda.B=2, lambda.gamma=1)
spcrglm.fit

# Poisson
set.seed(4)
y <- rpois(n, exp(  (nu0[1]*x[ ,1] + nu0[2]*x[ ,2] ) ))
spcrglm.fit <- spcrglm(x=x, y=y, k=2, family="poisson", lambda.B=2, lambda.gamma=1)
spcrglm.fit

# multinomial
set.seed(4)
y <- sample(1:4, n, replace=TRUE)
spcrglm.fit <- spcrglm(x=x, y=y, k=2, family="multinomial", lambda.B=2, lambda.gamma=2)
spcrglm.fit

spcr documentation built on Oct. 16, 2022, 9:05 a.m.

Related to spcrglm in spcr...