geelm.fit {geeasy} | R Documentation |
Fit Generalized Estimating Equation-based Linear Models
Description
Estimate mean structure parameters and their corresponding standard errors for generalized linear models with clustered or correlated observations by use of generalized estimating equations.
Usage
geelm.fit(x, y, id, offset, family, weights, control, corstr, start = NULL)
geelm(
formula,
id = NULL,
waves = NULL,
data = parent.frame(),
family = gaussian,
corstr = "independence",
Mv = 1,
weights = NULL,
corr.mat = NULL,
offset = NULL,
engine = "geeasy",
output = "geelm",
control = geelm.control()
)
Arguments
x , y |
For For |
id |
A vector identifying the clusters. If NULL, then each observation is assigned its own cluster. |
offset |
this can be used to specify an a priori known
component to be included in the linear predictor during fitting.
This should be |
family |
A description of the error distribution and link function to be used
in the model. The argument can be one of three options: a |
weights |
an optional vector of ‘prior weights’ to be used
in the fitting process. Should be |
control |
A list of parameters for controlling the fitting process. |
corstr |
A character string specifying the correlation structure.
The default is "independence". Allowed structures are: |
start |
starting values for the parameters in the linear predictor. |
formula |
A formula expression similar to that for |
waves |
An numeric vector identifying the time ordering within clusters
(i.e. levels of |
data |
An optional data frame containing the variables in the model. |
Mv |
For |
corr.mat |
The correlation matrix for |
engine |
Engine used to fit the model. The default, |
output |
Output object type. There are two options; 1) |
Details
Users may specify functions for link and variance functions, but the functions must be vectorized functions.
Offsets can be specified in the model formula, as in glm()
or they may be
specified using the offset
argument. If offsets are specified in both ways,
their sum is used as an offset.
For the "userdefined"
correlation option, the function accepts a
matrix with consecutive integers. Each such integer represent a distinct
parameter that will be estimated. All entries given as 1 will be assumed
to be the same as each other and will be assumed to be possibly different
from entries with a 2, and so on.geelm
only looks at the upper
triangle of the matrix. Any entry given as 0 will be fixed at 0.
If observations are dropped because they have a weight of 0, then the
denominator for the moment estimates of the correlation matrices are
calculated using the number of non-zero Pearson residuals for the
correlation structures unstructured
, userdefined
and
m-dependent
with Mv>1
. Therefore, residuals numerically
equal to 0 may cause problems in the calculation of correlation parameters.
Concerning the family
argument: If the supplied argument is a character
string, then the string should correspond to one of the family objects.
In order to define a link function, a list must be created with the
components (LinkFun, VarFun, InvLink, InvLinkDeriv)
, all of which are
vectorized functions. If the components in the list are not named
as (LinkFun, VarFun, InvLink, InvLinkDeriv)
, then geelm
assumes that the functions are given in that order. LinkFun and VarFun
are the link and variance functions. InvLink and InvLinkDeriv are the inverse
of the link function and the derivative of the inverse of the link function
and so are decided by the choice of the link function.
Value
An object of class geelm
(inherits from geeglm
) representing the fit.
It contains the following slots:
$coefficients
: Coefficients from the mean structure model (betas) on their
original scales
$residuals
: Pearson residuals, in the order of the inputted dataset (with NAs omitted).
$fitted.values
: Fitted values (response scale), in the order of the inputted dataset
(with NAs omitted).
$rank
: The rank of the model matrix, i.e. the number of estimated mean structure
coefficients.
$qr
: QR decomposition of the model matrix (NA omitted).
$family
: A family object specifying which exponential family was used for fitting
the mean structure model, see family
for more information.
$linear.predictors
: The linear predictor on the original scale.
$weights
: Weights used for computations, in the order of the inputted dataset
(NAs omitted).
$prior.weights
: The original weights used to produce this geeglm object (set
by user or defaulted to 1 for all observations).
$df.residuals
: Residual degrees of freedom.
$y
: Outcome variable, in the order of the inputted dataset (NAs omitted).
$model
: The model.frame, ordered as the original inputted data with NAs omitted.
$call
: The original function call that produced this geeglm object.
$formula
: The formula used in the original call.
$terms
: The terms of the formula used in the original call.
$data
: The original dataset that was used for producing this geeglm object.
$offset
: Offset used for fitting the model, ordered as the original inputted data
with NAs omitted.
$control
: Value of control parameters used for fitting the model.
$method
: Internal function used for fitting the model.
$contrasts
: Contrasts used in the model matrix.
$xlevels
: Levels of factor variables used in the model formula (if any).
$geese
: An object containing further information about the variance estimation,
including a variance matrix for the beta-coefficients ($vbeta
), the estimated
coefficients for the working correlation matrix ($alpha
), the estimated dispersion
parameter ($gamma
), and the individual cluster sizes ($clusz
). See
geese
for more information.
$modelInfo
: Information about the link functions used for fitting the mean, variance
and scale structures of the model.
$id
: IDs used for identifying the clusters, ordered as the original inputted data
with NAs omitted.
$corstr
: Name of the correlation structured imposed on the model. If the
correlation structure requires further information, it is stored in a suitably named
attribute. For example, for m-dependent correlation structures, the m scalar is available
in an attribute named Mv
.
$cor.link
: Link function used for the correlation structure.
$std.err
: Method used to estimate the standard error of the mean structure
coefficients (betas).
Functions
-
geelm.fit()
:
Author(s)
Anne Helby Petersen, Lee McDaniel & Nick Henderson
See Also
Examples
# load data
data("respiratory")
respiratory$useid <- interaction(respiratory$center, respiratory$id)
# fit model
m <- geelm(outcome ~ treat + sex + age + baseline,
data = respiratory, id = useid,
family = "binomial", corstr = "exchangeable")
## Not run:
get_jack_se <- function(object, dat){
parm <- sapply(1:nrow(dat),
function(i){
dat.i <- dat[-i,]
coef(update(object, data=dat.i))
})
parm <- t(parm)
parm.mean <- apply(parm, 2, mean)
parm.cent <- sapply(1:nrow(parm),
function(i){
parm[i, ] - parm.mean
})
parm.cent <- t(parm.cent)
jack.var <- ((nrow(dat)-1) / nrow(dat)) * t(parm.cent) %*% parm.cent
jack.se <- sqrt(diag(jack.var))
jack.se
}
# load data
data("respiratory")
respiratory$useid <- interaction(respiratory$center, respiratory$id)
# fit model
obj <- geelm(outcome ~ treat + sex + age + baseline,
data = respiratory, id = useid,
family = "binomial", corstr = "exchangeable")
dat <- respiratory
get_jack_se(obj, dat)
summary(obj) |> coef()
## End(Not run)