IndrajeetPatil / ggstatsplot

Enhancing {ggplot2} plots with statistical analysis 📊📣
https://indrajeetpatil.github.io/ggstatsplot/
GNU General Public License v3.0
2.03k stars 190 forks source link

adding support for `gamlss` class objects in `ggcoefstats` #72

Closed IndrajeetPatil closed 5 years ago

IndrajeetPatil commented 6 years ago
library(gamlss)
#> Loading required package: splines
#> Loading required package: gamlss.data
#> Loading required package: gamlss.dist
#> Loading required package: MASS
#> Loading required package: nlme
#> Loading required package: parallel
#>  **********   GAMLSS Version 5.1-2  **********
#> For more on GAMLSS look at http://www.gamlss.org/
#> Type gamlssNews() to see new features/changes/bug fixes.
library(tidyverse)
library(ggstatsplot)

g <- gamlss(
  y ~ pb(x),
  sigma.fo = ~ pb(x),
  family = BCT,
  data = abdom,
  method = mixed(1, 20)
)
#> GAMLSS-RS iteration 1: Global Deviance = 4771.925 
#> GAMLSS-CG iteration 1: Global Deviance = 4771.013 
#> GAMLSS-CG iteration 2: Global Deviance = 4770.994 
#> GAMLSS-CG iteration 3: Global Deviance = 4770.994

broom::tidy(g, conf.int = TRUE)
#>   parameter        term     estimate   std.error   statistic       p.value
#> 1        mu (Intercept) -64.44299460 1.328921129 -48.4927158 1.889994e-210
#> 2        mu       pb(x)  10.69463541 0.057769202 185.1269371  0.000000e+00
#> 3     sigma (Intercept)  -2.65041283 0.108045909 -24.5304321  8.093605e-93
#> 4     sigma       pb(x)  -0.01002512 0.003784911  -2.6487067  8.290567e-03
#> 5        nu (Intercept)  -0.10715726 0.557434072  -0.1922331  8.476237e-01
#> 6       tau (Intercept)   2.49483399 0.301271895   8.2810047  7.765827e-16
confint(g)
#> Warning in vcov.gamlss(object, robust = robust): Additive terms exists in the  mu formula. 
#>   Standard errors for the linear terms maybe are not appropriate
#> Warning in vcov.gamlss(object, robust = robust): Additive terms exists in the  sigma formula. 
#>   Standard errors for the linear terms maybe are not appropriate
#>                 2.5 %    97.5 %
#> (Intercept) -67.05752 -61.82847
#> pb(x)        10.58121  10.80806

ggcoefstats(x = g)
#> Note: No 95% confidence intervals available for regression coefficients from gamlss object, so skipping whiskers in the plot.
#> 
#> Error in `levels<-`(`*tmp*`, value = as.character(levels)): factor level [2] is duplicated

Created on 2018-10-07 by the reprex package (v0.2.1)

IndrajeetPatil commented 6 years ago

Wait for this to be resolved on the broom-end: https://github.com/tidymodels/broom/issues/507