Closed AlvaroTorresMartos closed 4 months ago
Thanks for the issue, @AlvaroTorresMartos!
tidy.lm.beta()
simply reports the confidence internals that lm.beta()
does:
# load libraries for models and data
library(broom)
library(lm.beta)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
# fit models
mod <- stats::lm(speed ~ ., data = cars)
std <- lm.beta(mod)
# summarize model fit with tidiers
tidy(std, conf.int = TRUE) %>% select(conf.low, conf.high)
#> # A tibble: 2 × 2
#> conf.low conf.high
#> <dbl> <dbl>
#> 1 NA NA
#> 2 0.772 0.842
# use lm.beta's own method
confint(std)
#> 2.5 % 97.5 %
#> (Intercept) NA NA
#> dist 0.7717199 0.8420699
Created on 2024-03-07 with reprex v2.1.0
If you're seeing an exception to this in your problem context, please feel free to reopen with a minimal reprex (reproducible example). :)
Thank you very much for responding, if there is a bug I understand it is up to the author of the lm.beta package to fix it. Thank you for developing broom package, it is an incredibly useful tool.
Best regards, Álvaro
El jue, 7 mar 2024 a las 17:54, Simon P. Couch @.***>) escribió:
Thanks for the issue, @AlvaroTorresMartos https://github.com/AlvaroTorresMartos!
tidy.lm.beta() simply reports the confidence internals that lm.beta() does:
load libraries for models and data
library(broom) library(lm.beta) library(dplyr)#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union
fit modelsmod <- stats::lm(speed ~ ., data = cars)std <- lm.beta(mod)
summarize model fit with tidiers
tidy(std, conf.int = TRUE) %>% select(conf.low, conf.high)#> # A tibble: 2 × 2#> conf.low conf.high#>
#> 1 NA NA #> 2 0.772 0.842 use lm.beta's own method
confint(std)#> 2.5 % 97.5 %#> (Intercept) NA NA#> dist 0.7717199 0.8420699
Created on 2024-03-07 with reprex v2.1.0 https://reprex.tidyverse.org
If you're seeing an exception to this in your problem context, please feel free to reopen with a minimal reprex https://github.com/tidyverse/reprex#what-is-a-reprex (reproducible example). :)
— Reply to this email directly, view it on GitHub https://github.com/tidymodels/broom/issues/1190#issuecomment-1983996893, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASSFJNNPNA3DLEBABOHGY3LYXCLT7AVCNFSM6AAAAABEK5G3CSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBTHE4TMOBZGM . You are receiving this because you were mentioned.Message ID: @.***>
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
When using the
tidy()
function from thebroom
package with the argumentconf.int = TRUE
on an object created with thelm()
function, the result is correct. Below is the code and output for both cases.This is not true if you use
tidy()
withconf.int=TRUE
on an object created withlm.beta
. In principle, significant beta coefficients must be non-zero, and therefore the confidence interval must not contain zero.Correct result: Code
Output
Wrong result: Code
Output
I think that calculating the confidence intervals of the standardized coefficients can be simplified by merging the two results and running the following code:
merged_results %>% dplyr::mutate(std.conf.low = (conf.low*std_estimate)/estimate, std.conf.high= (conf.high*std_estimate)/estimate)