rglmstan

How to extract standard error from coefficients in stan_glm


I have a model that looks like this:

fit <- stan_glm(switch ~ arsenic + dist100, 
                family=binomial(link="logit"), 
                data=wells, 
                refresh=0)

with an output that looks like this:

stan_glm
 family:       binomial [logit]
 formula:      switch ~ arsenic + dist100
 observations: 3020
 predictors:   3
------
            Median  MAD_SD 
(Intercept)  0.0054  0.0810
arsenic      0.4618  0.0415
dist100     -0.9025  0.1040

------

and I want the MAD_SD coefficients from the resulting fit. I usually use se(fit) and that gives me the coefficients, but for some reason I get the error

Error in se(fit) : argument "predicted" is missing, with no default

How do I remedy this error?


Solution

  • In case anybody wants to know the answer to this question, stan_glm objects are basically like big tibbles that map a name to an element. In this case, the element is named "ses" and it's a list. So you can do

    fit$ses[0]
    

    to index into it

    EDIT: Turns out, the reason that I needed to do this at all was because I imported a package AFTER stan_glm that also has a function called "se" and it got masked.