Learn R Programming

pprof (version 1.0.3)

logis_cre: Main Function for fitting correlated random effect logistic model

Description

Fit a correlated random effect logistic model via glmer from the lme4 package.

Usage

logis_cre(data, Y.char, wb.char, other.char = NULL, ProvID.char, ...)

Value

A list of objects with S3 class "logis_cre":

coefficient

a list containing the estimated coefficients: FE, the fixed effects for each predictor and the intercept, and RE, the random effects for each provider.

variance

a list containing the variance estimates: FE, the variance-covariance matrix of the fixed effect coefficients, and RE, the variance of the random effects.

fitted

the fitted values of each individual.

observation

the original response of each individual.

linear_pred

the linear predictor of each individual.

data_include

the processed data used to fit the model, sorted by the provider identifier. This includes the within-group (*_within) and between-group (*_bar) components for variables specified in wb.char. For categorical covariates, it includes the dummy variables created for all categories except the reference level.

char_list

a list of the character vectors representing the column names for the response variable, provider identifier, the generated names for covariates with decomposition (wb.char, and covariates included without decomposition (other.char). For categorical variables, the names reflect the dummy variables created for each category.

Loglkd

the log-likelihood.

AIC

Akaike information criterion.

BIC

Bayesian information criterion.

Arguments

data

a data frame containing all variables.

Y.char

a character string specifying the column name of the response variable in the data.

wb.char

a character vector specifying covariates to be decomposed into within (*_within) and between (*_bar) components.

other.char

a character vector specifying additional covariates to include in the model without decomposition.

ProvID.char

a character string specifying the column name of the provider identifier in the data.

...

additional arguments passed to glmer for further customization.

Details

Fit a correlated random effect logistic model using glmer with a Mundlak within–between decomposition for selected covariates. For each decomposed covariate \(Z_k\), the function constructs \(Z_{k,\mathrm{bar},i} = \frac{1}{n_i}\sum_j Z_{k,ij}\) (the group mean, "between") and \(Z_{k,\mathrm{within},ij} = Z_{k,ij} - Z_{k,\mathrm{bar},i}\) (the within-group deviation), and estimates the model $$\mathrm{logit}\left(P(Y_{ij}=1)\right) = \mu + \alpha_i + \sum_k \beta_{k,W} Z_{k,\mathrm{within},ij} + \sum_k \beta_{k,B} Z_{k,\mathrm{bar},i} + \mathbf{X}_{ij}^\top\gamma,$$ where \(\alpha_i \sim \mathcal{N}(0,\sigma_\alpha^2)\) is a random intercept.

The function creates, for every name in wb.char, two columns: <var>_bar (group mean within ProvID.char) and <var>_within (observation minus its group mean). The fitted model formula is:


  Y ~ <all *_within> + <all *_bar> + <other.char> + (1 | ProvID)

This model is fitted using glmer with family = binomial(link = "logit").

In addition to these input formats, all arguments from the glmer function can be modified via ..., allowing for customization of model fitting options such as controlling the optimization method or adjusting convergence criteria.

If issues arise during model fitting, consider using the data_check function to perform a data quality check. For datasets with missing values, this function automatically removes observations (rows) with any missing values before fitting the model.

References

Bates D, Maechler M, Bolker B, Walker S (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48.

See Also

data_check

Examples

Run this code
data(ExampleDataBinary)
outcome <- ExampleDataBinary$Y
covar <- ExampleDataBinary$Z
ProvID <- ExampleDataBinary$ProvID
data <- data.frame(outcome, ProvID, covar)
outcome.char <- colnames(data)[1]
ProvID.char <- colnames(data)[2]
wb.char <- c("z1", "z2")
other.char <- c("z3", "z4", "z5")

# Fit a correlated random effect linear model
fit_cre <- logis_cre(data = data, Y.char = outcome.char, ProvID.char = ProvID.char,
wb.char = wb.char, other.char = other.char)

Run the code above in your browser using DataLab