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

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/spcrglm.R

Description

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

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 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

Example output

$loadings.B
            [,1]      [,2]
[1,] -0.36805311 0.1857854
[2,]  0.87263136 0.0000000
[3,] -0.07687106 0.0000000
[4,]  0.00000000 0.0000000
[5,]  0.00000000 0.8765114

$gamma
[1]  1.41588373 -0.09754383

$gamma0
[1] -0.347348

$loadings.A
            [,1]        [,2]
[1,] -0.37795291  0.29284718
[2,]  0.89868311  0.06857861
[3,] -0.21947829 -0.06962436
[4,]  0.01010539  0.01815379
[5,]  0.03531890  0.95097865

$call
spcrglm(x = x, y = y, k = 2, family = "binomial", lambda.B = 2, 
    lambda.gamma = 1)

attr(,"class")
[1] "spcrglm"
$loadings.B
           [,1]        [,2]
[1,]  0.0000000  0.65881925
[2,]  0.0000000 -0.68366599
[3,] -0.6164008  0.00000000
[4,]  0.6365829  0.01699490
[5,]  0.0000000 -0.02919659

$gamma
[1] -0.08070618 -1.52222937

$gamma0
[1] -0.05449821

$loadings.A
            [,1]        [,2]
[1,]  0.08772815  0.62734172
[2,]  0.08495951 -0.76832480
[3,] -0.68482910  0.08190782
[4,]  0.71716214  0.09043375
[5,]  0.04210963  0.03510290

$call
spcrglm(x = x, y = y, k = 2, family = "poisson", lambda.B = 2, 
    lambda.gamma = 1)

attr(,"class")
[1] "spcrglm"
$loadings.B
           [,1]      [,2]
[1,]  0.0000000 0.0000000
[2,]  0.5439287 0.0000000
[3,] -0.6219988 0.0000000
[4,]  0.3163405 0.0000000
[5,]  0.0000000 0.9397095

$gamma
     [,1]      [,2]        [,3]       [,4]
[1,]    0 0.0000000 -0.15502689 0.05779251
[2,]    0 0.2253673 -0.05528075 0.00000000

$gamma0
[1]  0.02136976 -0.16796558 -0.11934521  0.26593826

$loadings.A
             [,1]        [,2]
[1,] -0.048045915  0.15753772
[2,]  0.621714468  0.01098778
[3,] -0.673372035 -0.01402038
[4,]  0.397149015 -0.02772730
[5,]  0.002339214  0.98696290

$call
spcrglm(x = x, y = y, k = 2, family = "multinomial", lambda.B = 2, 
    lambda.gamma = 2)

attr(,"class")
[1] "spcrglm"

spcr documentation built on Sept. 28, 2021, 5:08 p.m.

Related to spcrglm in spcr...