Effect size and confidence interval for difference in two regression coefficients I have an effect size that is a difference between two regression coefficients $\Delta\beta=\beta_a-\beta_b$. The response and predictor units are the same in each model, and the question relates directly to the difference in slopes of the two regression models.
I am however a bit lost how to calculate a confidence interval for this difference?
Here's a not perfect but functional example in R:
library(tidyverse)
data(mtcars)

dat <- mtcars |> 
    mutate(group = rep(c("a", "b"), times = nrow(mtcars)/2)) |>
    group_by(group) |>
    mutate(y = hp/mean(hp), x = disp/mean(disp)) |>
    ungroup()

mod_a <- lm(data = filter(dat, group == "a"), y~x)
mod_b <- lm(data = filter(dat, group == "b"), y~x)

summary(mod_a)
summary(mod_b)

mod_a$coefficients[2]-mod_b$coefficients[2]

What would be an appropriate method for calculating a confidence interval for this difference? I know of ways to test if they are difference (compare global model with interaction term vs global model without interaction term using LRT for example), but when it comes to a figure, I would like to show more than a p-value.
Thanks in advance!

By modeling the complete dataset with an interaction between group and x, you directly get the estimated difference in slopes and a corresponding confidence interval.
library(tidyverse)
data(mtcars)

dat <- mtcars |>
  mutate(group = rep(c("a", "b"), times = nrow(mtcars)/2)) |>
  group_by(group) |>
  mutate(y = hp/mean(hp), x = disp/mean(disp)) |>
  ungroup()

mod <- lm(y~x*group, data = dat)
summary(mod)

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   0.2899     0.1653   1.754   0.0903 .  
x             0.7100     0.1485   4.782 5.03e-05 ***
groupb        0.0833     0.2248   0.371   0.7137    
x:groupb     -0.0833     0.1999  -0.417   0.6802 

confint(mod)

                  2.5 %    97.5 %
(Intercept) -0.04859366 0.6284942
x            0.40590034 1.0141992
groupb      -0.37709339 0.5436837
x:groupb    -0.49286492 0.3262746

The coefficient of the interaction term is the estimated difference in slopes between groups a and b. The difference is estimated to be $-0.083$ with a 95% confidence interval $(-0.493;\,0.326)$ and a $p$-value of $0.6802$. The slope for group a is thus $0.710$ and the slope for group b is smaller by $-0.0833$, so it is $0.627$.
You could further modify the model so that the groups have a common intercept: mod <- lm(y~x + x:group, data = dat).
