# Estimating standard errors using the Delta Method in R

R

Statistics

I just discovered the msm package in R that offers the `deltamethod`

function for calculating the standard error of a transformation of estimated regression coefficients. A tutorial could be found here. I had to use it recently to calculate the standard error for a difference in proportions when logistic regression model was used to estimate the log-odds of an event:

```
```{r}
<- glm(Response ~ treat, data=my_data, family=binomial(link='logit')) # treat is binary
fit <- 1/(1 + exp(-coef(fit)[1] - coef(fit)[2])) - 1/(1 + exp(-coef(fit)[1])) # difference in proportion
diff library(msm)
<- deltamethod(~ 1/(1 + exp(-x1 - x2)) - 1/(1 + exp(-x1)), coef(fit), vcov(fit)) # returns standard error
se.diff ```
```