Ready to publish regression table in WORD using miceadds::glm.cluster

Hi everyone,

I am trying to do a logistic regression with robust clustered error using miceadds::glm.cluster:

model1 <- miceadds::glm.cluster(data=df_clean3, formula=recall ~ log(Population)+NoComplaintsReported+NoCrashesFiresReported+NoInjuriesReported+NoFatalityIncidentsReported+NoOtherFailuresReported+YearOpen+label, cluster="label", family="binomial")

I am working with a Professor and need to report a ready-to-publish regression table in Microsoft Word. I have tried the below methods, but each are not the "professionally prepared" version that I am looking for.

Can someone help me with this?

1-tab_df (from the sjPlot library): It stops with the error message that:

Error in UseMethod("family") :
no applicable method for 'family' applied to an object of class "NULL"

2- Stargazer: the output table does not look neat.

3- summ (from jtools library): the output table does not look neat.

4- apa.reg.table (from apaTables library): it stops with this error message:

Error in 2:last_model_number_predictors : argument of length 0

We need a reproducible example (reprex)

A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.

1 Like

Thank you for your guidance. Here is the Reprex for my problem:

library(miceadds)
#> Loading required package: mice
#> 
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following objects are masked from 'package:base':
#> 
#>     cbind, rbind
#> * miceadds 3.11-6 (2021-01-21 11:48:47)
library(apaTables)
library(sjPlot)
#> Install package "strengejacke" from GitHub (`devtools::install_github("strengejacke/strengejacke")`) to load all sj-packages at once!

df_clean3 <- structure(list(InvestigationID = c("PE09001", "EA09001", "EQ09001", 
                                   "DP09001", "EQ09002"), YearOpen = c(2009L, 2009L, 2009L, 2009L, 
                                                                       2009L), Population = c(2500L, 754500L, 232L, 230517L, 53788L), 
               NoComplaintsReported = c(3L, 42L, 0L, 0L, 0L), NoCrashesFiresReported = c(1L, 
                                                                                         18L, 0L, 0L, 0L), NoInjuryIncidentsReported = c(0L, 1L, 0L, 
                                                                                                                                         0L, 0L), NoInjuriesReported = c(0L, 1L, 0L, 0L, 0L), NoFatalityIncidentsReported = c(0L, 
                                                                                                                                                                                                                              0L, 0L, 0L, 0L), NoFatalitiesReported = c(0L, NA, 0L, 0L, 
                                                                                                                                                                                                                                                                        0L), NoOtherFailuresReported = c(0L, 114L, 0L, 0L, 0L), recall = c(1L, 
                                                                                                                                                                                                                                                                                                                                           1L, 1L, 0L, 1L), label = structure(c(3L, 18L, 33L, 35L, 8L
                                                                                                                                                                                                                                                                                                                                           ), .Label = c("Arc", "Benz", "Blue", "BMW", "Braun", "Carrier", 
                                                                                                                                                                                                                                                                                                                                                         "Caterpillar", "Chih", "Chrysler", "Coach", "Daimler", "Dorel", 
                                                                                                                                                                                                                                                                                                                                                         "Flyer", "Ford", "General", "Harley", "Heil", "Honda", "Hyundai", 
                                                                                                                                                                                                                                                                                                                                                         "Jaguar", "Jonway", "Kia", "Krawler", "Lippert", "Mack", 
                                                                                                                                                                                                                                                                                                                                                         "Mazda", "Mitsubishi", "Navistar", "North", "Omni", "Paccar", 
                                                                                                                                                                                                                                                                                                                                                         "Subaru", "Suburb", "Sutphen", "Toyota", "Volkswagen", "Volvo", 
                                                                                                                                                                                                                                                                                                                                                         "Winnebago"), class = "factor")), row.names = c(1L, 2L, 3L, 
                                                                                                                                                                                                                                                                                                                                                                                                         14L, 17L), class = "data.frame")

model1 <- miceadds::glm.cluster(data=df_clean3, formula=recall ~ log(Population)+NoComplaintsReported+NoCrashesFiresReported+NoInjuriesReported+NoFatalityIncidentsReported+NoOtherFailuresReported+YearOpen+label, cluster="label", family="binomial")

apa.reg.table(model1)
#> Error in 2:last_model_number_predictors: argument of length 0

tab_df(model1, title="logistic regression", file="logit-test.doc")
#> Error in UseMethod("family"): no applicable method for 'family' applied to an object of class "NULL"

Created on 2022-03-28 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.