title: How to do a one-sample location, two-way approximate Z test in R using estimates from the delta method?
body: <p>I used the delta method to estimate the difference between two coefficients from a glm fit (attached code below). Now, I want to compare this estimate to zero (i.e., a null hypothesis of no difference). One article mentions using a one-sample location, two-way approximate Z test to compute this difference.</p>
  <p>However, I cannot find an easy way to do that in R using the delta difference. I looked over the <a href="https://cran.r-project.org/web/packages/distributions3/vignettes/two-sample-z-test.html" rel="nofollow noreferrer">two-sample Z test documentation</a> and possibly thought of using the difference as a substitute in the z-stat formula...but I am not sure if that's the best way to go about it.</p>
  <pre><code>##GENERATE DATA SET
  y &lt;- c(1:12)
  x1 &lt;- rep(c(1000, 4000, 0), each = 4)
  x2 &lt;- rep(c(0, 1000, 4000), each = 4)
  df &lt;- data.frame(y, x1, x2)
  
  ##RUN GLM
  library(lmerTest)
  g1 &lt;- glm(log(y) ~ x1 + x2, data = df)
  
  ##Use delta-method to estimate the difference between coefficients of x1 and x2 (Ritz &amp; Streibig 2008)
  library(car)
  g1.delta &lt;- deltaMethod(g1,&quot;(-x1) - (-x2)&quot;)
  
  
                Estimate   SE         2.5 %       97.5 % 
  (-x1) - (-x2) 2.3217e-04 7.3180e-05 8.8738e-05  4e-04
  </code></pre>