When a working correlation structure is used in geeglm or geese the resulting correlation estimates can be outside [-1,1].
Ideally this should never happen. But until this can be corrected a warning should be created so the user is alerted to any potential problem.
library(MASS)
library(geepack)
library(tidyr)
generate_data <- function(nobs = 100) {
sig <- matrix(data = c(1, 0.5, 0.5,
0.5, 1, 0.9,
0.5, 0.9, 1),
nrow = 3, ncol = 3)
y <- mvrnorm(n = nobs,
mu = c(0, 0, 0),
Sigma = sig)
dat <- data.frame(id = factor(1:nobs),
y1 = y[,1],
y2 = y[,2],
y3 = y[,3])
pivot_longer(dat,
cols = c(y1, y2, y3),
names_to = "Time",
values_to = "vals")
}
set.seed(3045)
simdat <- generate_data(100)
mod <- geeglm(vals ~ 1, id = id,
data = simdat,
corstr = "unstructured")
summary(mod)
#>
#> Call:
#> geeglm(formula = vals ~ 1, data = simdat, id = id, corstr = "unstructured")
#>
#> Coefficients:
#> Estimate Std.err Wald Pr(>|W|)
#> (Intercept) 0.1008 0.0841 1.437 0.231
#>
#> Correlation structure = unstructured
#> Estimated Scale Parameters:
#>
#> Estimate Std.err
#> (Intercept) 1.083 0.1374
#> Link = identity
#>
#> Estimated Correlation Parameters:
#> Estimate Std.err
#> alpha.1:2 0.4274 0.07357
#> alpha.1:3 0.4448 0.06583
#> alpha.2:3 1.1153 0.04518
#> Number of clusters: 100 Maximum cluster size: 3
When a working correlation structure is used in
geeglmorgeesethe resulting correlation estimates can be outside [-1,1].Ideally this should never happen. But until this can be corrected a warning should be created so the user is alerted to any potential problem.