Fast generalized linear model fitting
bigLm default
input model matrix. Must be a matrix object
additional arguments
numeric response vector of length nobs.
a description of the error distribution and link function to be used in the model.
For fastglm this can be a character string naming a family function, a family function or the
result of a call to a family function. For fastglmPure only the third option is supported.
(See family for details of family functions.)
an optional vector of 'prior weights' to be used in the fitting process. Should be a numeric vector.
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be a numeric vector of length equal to the number of cases
starting values for the parameters in the linear predictor.
starting values for the linear predictor.
values for the vector of means.
a decomposition name (`qr`, `qr_unpivoted`, `llt`, `ldlt`, `qr_full`, `svd`, or `auto`) or an integer scalar with value 0 for the column-pivoted QR decomposition, 1 for the unpivoted QR decomposition, 2 for the LLT Cholesky, or 3 for the LDLT Cholesky. For a dense design whose Cholesky factorization is singular or ill-conditioned, methods 2 and 3 refit with the column-pivoted QR decomposition and warn; `auto` does so silently.
threshold tolerance for convergence. Should be a positive real number
maximum number of IRLS iterations. Should be an integer
logical; if `TRUE` apply the Kosmidis–Firth mean bias-reducing adjusted score. Supported for unmodified binomial, Poisson, Gaussian, Gamma, inverse Gaussian, and fixed-theta negative-binomial families on dense, sparse, and `big.matrix` designs, and with any decomposition method.
retain full covariance, diagonal standard errors, or no inference. The no-inference option skips the final covariance calculation.
retain the design and response for subsequent inference.
A list with the elements
a vector of coefficients
a vector of the standard errors of the coefficient estimates
a scalar denoting the computed rank of the model matrix
a scalar denoting the degrees of freedom in the model
the vector of residuals
a numeric scalar - the root mean square for residuals
the vector of fitted values
[fastglm_fit()]
x <- matrix(rnorm(10000 * 100), ncol = 100)
y <- 1 * (0.25 * x[,1] - 0.25 * x[,3] > rnorm(10000))
system.time(gl1 <- glm.fit(x, y, family = binomial()))
#> user system elapsed
#> 0.300 0.005 0.305
system.time(gf1 <- fastglm(x, y, family = binomial()))
#> user system elapsed
#> 0.089 0.002 0.091
system.time(gf2 <- fastglm(x, y, family = binomial(), method = 1))
#> user system elapsed
#> 0.182 0.008 0.189
system.time(gf3 <- fastglm(x, y, family = binomial(), method = 2))
#> user system elapsed
#> 0.021 0.001 0.022
system.time(gf4 <- fastglm(x, y, family = binomial(), method = 3))
#> user system elapsed
#> 0.020 0.000 0.021
max(abs(coef(gl1) - gf1$coef))
#> [1] 1.165734e-15
max(abs(coef(gl1) - gf2$coef))
#> [1] 1.498801e-15
max(abs(coef(gl1) - gf3$coef))
#> [1] 1.276756e-15
max(abs(coef(gl1) - gf4$coef))
#> [1] 1.110223e-15
if (FALSE) { # \dontrun{
nrows <- 50000
ncols <- 50
bkFile <- "bigmat2.bk"
descFile <- "bigmatk2.desc"
bigmat <- filebacked.big.matrix(nrow=nrows, ncol=ncols, type="double",
backingfile=bkFile, backingpath=".",
descriptorfile=descFile,
dimnames=c(NULL,NULL))
for (i in 1:ncols) bigmat[,i] = rnorm(nrows)*i
y <- 1*(rnorm(nrows) + bigmat[,1] > 0)
system.time(gfb1 <- fastglm(bigmat, y, family = binomial(), method = 3))
} # }