larmarange / broom.helpers

A set of functions to facilitate manipulation of tibbles produced by broom
https://larmarange.github.io/broom.helpers/
GNU General Public License v3.0
21 stars 8 forks source link

tbl_regression (package gtsummary) and ggcoef_model (package ggstats) not working on the output of a replicate svyglm model #240

Closed FrancoisGhesquiere closed 9 months ago

FrancoisGhesquiere commented 9 months ago

Dear,

I have noticed that the function tbl_regression from package gtsummary and ggcoef_model from package ggstats do not work on an output of svyglm model with replicate weights (although they both work fine with a ‘classical’ svyglm model).

I got the message : « Error in tcm * w : non-conformable arrays », for both functions

It would be great if we could use tbl_regression and ggcoef_model on complex survey with replicates regressions models.

See here under an example of code not working.

#loading packages survey, gtsummary and ggstats
library(survey)
library(gtsummary)
library(ggstats)

#creating dataframe
age <- c(23, 41, 32, 58, 26, 23, 70, 53, 32, 18)
income <- c(2300, 4200, 3200, 4000, 5000, 2500, 4200, 3000, 5100, 2000)
sex <- c("M", "F", "F", "M", "F", "F", "M", "M", "M", "F")
psu <- c(1, 2, 3, 1, 1, 2, 3, 4, 4,3)
str<- c(1,1,1,1,1,2,2,2,2,2)
weight <- c(10,20,10,20,20,30,40,10,10,20)
df <- data.frame(age,income,sex,psu,str,weight)

#creating survey object
data_svy<-svydesign(id = ~psu,strat=~str, weight= ~weight, nest= TRUE, data = df)

#creating survey replicate object
data_repsvy<-as.svrepdesign(data_svy, type = "JKn")

#regression
mod1<-svyglm(income~ age + sex ,design = data_repsvy)

#"classical" summary works fine
summary(mod1)

#tbl_regression not working
tbl_regression(mod1)

#ggcoef_model not working either
ggcoef_model(mod1)

Thanks in advance,

François Ghesquière

larmarange commented 9 months ago

C'est normalement corrigé via #239

FrancoisGhesquiere commented 9 months ago

Ca marche. Merci beaucoup pour la rapidité!!!


De : Joseph Larmarange @.> Envoyé : mercredi 29 novembre 2023 12:28 À : larmarange/broom.helpers @.> Cc : François Ghesquiere @.>; Author @.> Objet : Re: [larmarange/broom.helpers] tbl_regression (package gtsummary) and ggcoef_model (package ggstats) not working on the output of a replicate svyglm model (Issue #240)

C'est normalement corrigé via #239https://github.com/larmarange/broom.helpers/pull/239

— Reply to this email directly, view it on GitHubhttps://github.com/larmarange/broom.helpers/issues/240#issuecomment-1831715789, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDR6GQJQS5HQIUA2GLJNO53YG4L4ZAVCNFSM6AAAAAA76H64XGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZRG4YTKNZYHE. You are receiving this because you authored the thread.Message ID: @.***>

[logo IWEPS] François Ghesquiere Chargé de recherche

Institut wallon de l'évaluation, de la prospective et de la statistique Direction Statistique

Route de Louvain-la-Neuve, 2 B-5001 Namur (Belgrade)

Tél. : 081 468 468 www.iweps.behttp://www.iweps.be/

Suivez-nous sur :

[iweps]https://twitter.com/IWEPS_wallonie [iweps] https://www.facebook.com/IWEPS [iweps] https://www.linkedin.com/company/iweps

Clause de non-responsabilité : Ce message informel n'engage en aucune manière l'IWEPS. Seul un courrier à en-tête de l'Institut portant une (ou des) signature(s) manuscrite(s) autorisée(s) engage l'IWEPS.