Different coefficients with tab_model() and tidy()

259 Views Asked by At

I am getting different regression coefficients for the same model when using the tab_model() function from the sjTools package compared to tidy() from the broom package.

Why is that?

This is my data:

df <- structure(list(weed_coverage = c(0.04, 0.006, 0.03, 0.017, 0.044, 
0.03, 0.02, 0.05, 0.001, 0.008, 0.03, 0.015, 0.002, 0.015, 0.002, 
0.06, 0.002, 0.01, 0.009, 0.008), soil_moisture = c(11.03, 24.35, 
12.55, 31, 16.73, 9.28, 7.55, 33.42, 21.95, 25.02, 11.3, 36.3, 
14.82, 13.8, 13.48, 14.7, 11.2, 18, 36, 32.25), distance = structure(c(2L, 
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 
2L, 2L, 1L), .Label = c("2", "5"), class = "factor")), class = "data.frame", row.names = c(NA, 
-20L))
betareg (weed_coverage ~ soil_moisture * distance, data = df) -> model_b

tab_model(model_b)
tidy(model_b)

The output of tab_model(model_b):

The regression output of tab_model(model_b

The output of tidy(model_b):

> tidy(model_b)
# A tibble: 5 x 6
  component term                    estimate std.error statistic  p.value
  <chr>     <chr>                      <dbl>     <dbl>     <dbl>    <dbl>
1 mean      (Intercept)              -5.11      0.728      -7.02 2.18e-12
2 mean      soil_moisture             0.0354    0.0302      1.17 2.41e- 1
3 mean      distance5                 1.99      0.835       2.38 1.72e- 2
4 mean      soil_moisture:distance5  -0.0652    0.0372     -1.75 7.99e- 2
5 precision (phi)                    77.7      26.6         2.92 3.54e- 3
1

There are 1 best solutions below

2
On BEST ANSWER

They are the same, you just have to exponentiate the ones from tidy:

vars <- c(-5.11, 0.0354, 1.99, -0.0652)
exp(vars)
round(exp(vars),2)

#> exp(vals)
#[1] 0.006036083 1.036034040 7.315533762 0.936880069
#> round(exp(vals),2)
#[1] 0.01 1.04 7.32 0.94

results <- broom::tidy(model_b)
exp(res$estimate)
#[1] 6.041116e-03 1.036079e+00 7.305950e+00 9.369114e-01 5.575028e+33