## S3 method for class 'formula':
glmreg(formula, data, weights, offset=NULL, contrasts=NULL,
x.keep=FALSE, y.keep=TRUE, ...)
## S3 method for class 'matrix':
glmreg(x, y, weights, offset=NULL, ...)
## S3 method for class 'default':
glmreg(x, ...)
model.frame
.standardize=TRUE
, weights are renormalized to weights/sum(weights). If standardize=FALSE
, weights are kept as original inputfamily="gaussian"
.
Non-negative counts for family="poisson"
or family="negbin"
. For
family="binomial"
should be either a factor with two levels or
a vector of prlevels
from the
respective modelsglmreg_fit
"glmreg"
for the various types of models.length(lambda)
nvars x
length(lambda)
matrix of coefficients.lambda
values used"gaussian"
, this
is the R-square). The deviance calculations incorporate weights if
present in the model. The deviance is defined to be 2*(loglike_sat -
loglike), where loglike_sat is the log-likelihood for the saturated
model (a model with a free parameter per observation).lambda
is fit by coordinate
descent. For family="gaussian"
this is the lasso, mcp or scad sequence if
alpha=1
, else it is the enet, mnet or snet sequence.
For the other families, this is a lasso (mcp, scad) or elastic net (mnet, snet) regularization path
for fitting the generalized linear regression
paths, by maximizing the appropriate penalized log-likelihood.
Note that the objective function for "gaussian"
is $$1/2*
weights*RSS + \lambda*penalty,$$ if standardize=FALSE
and $$1/2*
\frac{weights}{\sum(weights)}*RSS + \lambda*penalty,$$ if standardize=TRUE
. For the other models it is
$$-\sum (weights * loglik) + \lambda*penalty$$ if standardize=FALSE
and $$-\frac{weights}{\sum(weights)} * loglik + \lambda*penalty$$ if standardize=TRUE
.Zhu Wang, Shuangge Ma, Michael Zappitelli, Chirag Parikh, Ching-Yun Wang and Prasad Devarajan (2014) Penalized Count Data Regression with Application to Hospital Stay after Pediatric Cardiac Surgery, Statistical Methods in Medical Research. 2014 Apr 17. [Epub ahead of print]
print
, predict
, coef
and plot
methods, and the cv.glmreg
function.#binomial
x=matrix(rnorm(100*20),100,20)
g2=sample(0:1,100,replace=TRUE)
fit2=glmreg(x,g2,family="binomial")
#poisson and negative binomial
data("bioChemists", package = "pscl")
fm_pois <- glmreg(art ~ ., data = bioChemists, family = "poisson")
coef(fm_pois)
fm_nb1 <- glmreg(art ~ ., data = bioChemists, family = "negbin", theta=1)
coef(fm_nb1)
fm_nb2 <- glmregNB(art ~ ., data = bioChemists)
coef(fm_nb2)
Run the code above in your browser using DataLab