computeDeltas: Computes Major Model Components Necessary for GOF Test

Description Usage Arguments Examples

View source: R/computeDeltas.R

Description

This function takes the important estimated model components and returns the two necessary arguments for computeD.

Usage

1
2
computeDeltas(theta_glmm, sigma_glmm, idx_glmm, theta_clogit, sigma_clogit,
  idx_clogit, ...)

Arguments

theta_glmm

estimated glmer coefficients

sigma_glmm

estimated variance w/r/t glmer model

idx_glmm

indices of specific glmer coefficients that vary between clusters

theta_clogit

estimated clogit coefficients

sigma_clogit

estimated variance w/r/t clogit model

idx_clogit

indices of clogit model (generally, all of them) that line up with idx_glmm.

...

additional arguments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(glmerGOF)
set.seed(1)
n <- 50
m <- 4
beta <- c(2, 2)
id <- rep(1:n, each=m)
x <- rnorm(m*n)
b <- rep(rnorm(n), each=m)
y <- rbinom(m*n, 1, plogis(cbind(1, x) %*% beta + b))
my_data <- data.frame(y,x,id)

variable_names <- list(DV = "y", grouping = "id")

library(lme4)
fit_glmm <- lme4::glmer(
  formula = y ~ x + (1|id),
  family = "binomial",
  data = my_data
)
library(survival)
fit_clogit <- survival::clogit(
  formula = y ~ x + strata(id),
  data = my_data,
  method = "exact"
)

test_results <- testGOF(
  data = my_data,
  fitted_model_clogit = fit_clogit,
  fitted_model_glmm  = fit_glmm,
  var_names = variable_names,
  gradient_derivative_method = "simple"
)
test_results

deltas <- do.call(computeDeltas, test_results$fits)

deltas
test_results$fits[c("delta", "sigma_delta")]

BarkleyBG/glmerGOF documentation built on July 18, 2019, 6:43 p.m.