Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correlation estimates > 1 with unstructured working correlation #4

Open
DavidLukeThiessen opened this issue Jul 11, 2021 · 0 comments

Comments

@DavidLukeThiessen
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant