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

feature request: supporting mcglm regression model #267

Closed
IndrajeetPatil opened this issue Jun 13, 2020 · 2 comments
Closed

feature request: supporting mcglm regression model #267

IndrajeetPatil opened this issue Jun 13, 2020 · 2 comments
Labels
Enhancement 💥 Implemented features can be improved or revised

Comments

@IndrajeetPatil
Copy link
Member

# setup
set.seed(123)
library(mcglm)
#> ----------------------------------------------------------------------
#>   mcglm: Multivariate Covariance Generalized Linear Models
#> 
#>   For support, collaboration or bug report, visit: 
#>     https://github.com/wbonat/mcglm
#> 
#>   mcglm version 0.6.0 (build on 2020-06-08) is now loaded.
#> ----------------------------------------------------------------------
library(Matrix)

# matrix linear predictor
counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12)
outcome <- gl(3, 1, 9)
treatment <- gl(3, 3)
d.AD <- data.frame(treatment, outcome, counts)
Z0 <- mc_id(d.AD)

# model
fit.qglm <- 
  mcglm(
  linear_pred = c(counts ~ outcome + treatment),
  matrix_pred = list("resp1" = Z0),
  link = "log",
  variance = "tweedie",
  data = d.AD,
  control_algorithm = list(
    verbose = FALSE,
    method = "chaser",
    tuning = 0.8
  )
)
#> Automatic initial values selected.

# summary
summary(fit.qglm)
#> Warning in sqrt(diag(object$vcov)): NaNs produced

#> Warning in sqrt(diag(object$vcov)): NaNs produced

#> Warning in sqrt(diag(object$vcov)): NaNs produced

#> Warning in sqrt(diag(object$vcov)): NaNs produced
#> Call: counts ~ outcome + treatment
#> 
#> Link function: log
#> Variance function: tweedie
#> Covariance function: identity
#> Regression:
#>                 Estimates Std.error       Z value     Pr(>|z|)
#> (Intercept)  3.044522e+00 0.1943517  1.566502e+01 2.623653e-55
#> outcome2    -4.542553e-01 0.2299154 -1.975750e+00 4.818313e-02
#> outcome3    -2.929871e-01 0.2191931 -1.336662e+00 1.813329e-01
#> treatment2  -1.981259e-16 0.2274467 -8.710868e-16 1.000000e+00
#> treatment3  -6.040927e-17 0.2274467 -2.655975e-16 1.000000e+00
#> 
#> Dispersion:
#>   Estimates Std.error Z value Pr(>|z|)
#> 1    1.2933       NaN     NaN      NaN
#> 
#> Algorithm: chaser
#> Correction: TRUE
#> Number iterations: 2
@IndrajeetPatil IndrajeetPatil added the Enhancement 💥 Implemented features can be improved or revised label Jun 13, 2020
@strengejacke
Copy link
Member

These types of models are really interesting, because you can use them in a similar way as SEM, so you could, e.g. model cross lagged panel designs, or do mediation analysis... However, dealing with multivariate response models is really exhausting.

@IndrajeetPatil
Copy link
Member Author

Closing this since the package is no longer on CRAN:
https://cran.r-project.org/web/packages/mcglm/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 💥 Implemented features can be improved or revised
Projects
None yet
Development

No branches or pull requests

2 participants