Search code examples
rpanel-datastargazer

stargazer Error: $ operator not defined for this S4 class


I'm to apply stargazer with "wbm"

this is my model

modelMQ <- wbm(Management_Q ~ Emergency | Teaching, data = Pnurses)

but when I try to use stargazer

stargazer(modelMQ, Type = "text", title = "Hybrid", out="Hybrid.csv", align=TRUE , no.space = TRUE)

I get this error

Error in objects[[i]]$zelig.call : $ operator not defined for this S4 class

Does anybody know how I can solve that? I use the same for lm and it works perfectly


Solution

  • This kind of model does not appear to be supported by stargazer, but it is supported by the modelsummary package. (Disclaimer: I am the author.)

    library(panelr)
    library(modelsummary)
    
    wages <- panel_data(WageData, id = id, wave = t)
    mod <- wbm(lwage ~ union, data = dat)
    
    modelsummary(mod)
    
    Model 1
    union 0.055
    (0.025)
    (Intercept) 6.675
    (0.021)
    imean(union) 0.003
    (0.036)
    SD (Intercept) 0.382
    SD (Observations) 0.259
    Num.Obs. 4165
    R2 Marg. 0.000
    R2 Cond. 0.685
    AIC 2262.8
    BIC 2294.5
    RMSE 0.24