poisson_GAGA {GAGAs} | R Documentation |
Fit a Poisson model via the GAGA algorithm
Description
Fit a Poisson model the Global Adaptive Generative Adjustment algorithm
Usage
poisson_GAGA(
X,
y,
alpha = 1,
itrNum = 30,
thresh = 0.001,
flag = TRUE,
lamda_0 = 0.5,
fdiag = TRUE,
subItrNum = 20
)
Arguments
X |
Input matrix, of dimension nobs*nvars; each row is an observation.
If the intercept term needs to be considered in the estimation process, then the first column of |
y |
Non-negative count response vector. |
alpha |
Hyperparameter. The suggested value for alpha is 1 or 2. When the collinearity of the load matrix is serious, the hyperparameters can be selected larger, such as 5. |
itrNum |
The number of iteration steps. In general, 20 steps are enough.
If the condition number of |
thresh |
Convergence threshold for beta Change, if |
flag |
It identifies whether to make model selection. The default is |
lamda_0 |
The initial value of the regularization parameter for ridge regression. The running result of the algorithm is not sensitive to this value. |
fdiag |
It identifies whether to use diag Approximation to speed up the algorithm. |
subItrNum |
Maximum number of steps for subprocess iterations. |
Value
Coefficient vector.
Examples
# Poisson
set.seed(2022)
p_size = 30
sample_size=300
R1 = 1/sqrt(p_size)
R2 = 5
ratio = 0.5 #The ratio of zeroes in coefficients
# Set the true coefficients
zeroNum = round(ratio*p_size)
ind = sample(1:p_size,zeroNum)
beta_true = runif(p_size,0,R2)
beta_true[ind] = 0
X = R1*matrix(rnorm(sample_size * p_size), ncol = p_size)
X[1:sample_size,1]=1
y = rpois(sample_size,lambda = as.vector(exp(X%*%beta_true)))
y = as.vector(y)
# Estimate
fit = GAGAs(X,y,alpha = 2,family="poisson")
Eb = fit$beta
cat("\n err:", norm(Eb-beta_true,type="2")/norm(beta_true,type="2"))
cat("\n acc:", cal.w.acc(as.character(Eb!=0),as.character(beta_true!=0)))