easystats / report

:scroll: :tada: Automated reporting of objects in R
https://easystats.github.io/report/
Other
693 stars 69 forks source link

table_*() should include SE and CI for standardized coefficients as well #94

Open strengejacke opened 3 years ago

strengejacke commented 3 years ago
library(report)
model <- lm(Sepal.Length ~ Petal.Length + Species, data = iris)
r <- report(model)

table_short(r)
#> Parameter            | Coefficient |             CI |      p | Coefficient (std.) |  Fit
#> ----------------------------------------------------------------------------------------
#> (Intercept)          |        3.68 | [ 3.47,  3.89] | < .001 |               1.50 |     
#> Petal.Length         |        0.90 | [ 0.78,  1.03] | < .001 |               1.93 |     
#> Species [versicolor] |       -1.60 | [-1.98, -1.22] | < .001 |              -1.93 |     
#> Species [virginica]  |       -2.12 | [-2.66, -1.58] | < .001 |              -2.56 |     
#>                      |             |                |        |                    |     
#> R2                   |             |                |        |                    | 0.84
#> R2 (adj.)            |             |                |        |                    | 0.83

table_long(r)
#> Parameter            | Coefficient |   SE |             CI |     t |  df |      p | Coefficient (std.) |    Fit
#> ---------------------------------------------------------------------------------------------------------------
#> (Intercept)          |        3.68 | 0.11 | [ 3.47,  3.89] | 34.72 | 146 | < .001 |               1.50 |       
#> Petal.Length         |        0.90 | 0.06 | [ 0.78,  1.03] | 13.96 | 146 | < .001 |               1.93 |       
#> Species [versicolor] |       -1.60 | 0.19 | [-1.98, -1.22] | -8.28 | 146 | < .001 |              -1.93 |       
#> Species [virginica]  |       -2.12 | 0.27 | [-2.66, -1.58] | -7.74 | 146 | < .001 |              -2.56 |       
#>                      |             |      |                |       |     |        |                    |       
#> AIC                  |             |      |                |       |     |        |                    | 106.23
#> BIC                  |             |      |                |       |     |        |                    | 121.29
#> R2                   |             |      |                |       |     |        |                    |   0.84
#> R2 (adj.)            |             |      |                |       |     |        |                    |   0.83
#> RMSE                 |             |      |                |       |     |        |                    |   0.33

Created on 2020-09-19 by the reprex package (v0.3.0)

I think this is not urgent, maybe can be addressed with point 3) from https://github.com/easystats/report/issues/65 in one step.

IndrajeetPatil commented 3 years ago

table_* functions are from old API, right?

Current output contains CIs for standardized coefficients, but not standard error.

library(report)
#> report is in alpha - help us improve by reporting bugs on github.com/easystats/report/issues
model <- lm(Sepal.Length ~ Petal.Length + Species, data = iris)
report_table(model)
#> Parameter            | Coefficient |         95% CI | t(146) |      p | Std. Coef. | Std. Coef. 95% CI |    Fit
#> ---------------------------------------------------------------------------------------------------------------
#> (Intercept)          |        3.68 | [ 3.47,  3.89] |  34.72 | < .001 |       1.50 |    [ 1.12,  1.87] |       
#> Petal.Length         |        0.90 | [ 0.78,  1.03] |  13.96 | < .001 |       1.93 |    [ 1.66,  2.20] |       
#> Species [versicolor] |       -1.60 | [-1.98, -1.22] |  -8.28 | < .001 |      -1.93 |    [-2.40, -1.47] |       
#> Species [virginica]  |       -2.12 | [-2.66, -1.58] |  -7.74 | < .001 |      -2.56 |    [-3.21, -1.90] |       
#>                      |             |                |        |        |            |                   |       
#> AIC                  |             |                |        |        |            |                   | 106.23
#> BIC                  |             |                |        |        |            |                   | 121.29
#> R2                   |             |                |        |        |            |                   |   0.84
#> R2 (adj.)            |             |                |        |        |            |                   |   0.83
#> Sigma                |             |                |        |        |            |                   |   0.34

Created on 2021-04-06 by the reprex package (v2.0.0)

mattansb commented 3 years ago

Shouldn't all the AIC, BIC, etc be in a footnote?

strengejacke commented 3 years ago

Either that, or this layout looks quite clear and compact: https://github.com/easystats/report/issues/65

bwiernik commented 3 years ago

R2 and sigma would ideally have intervals (and R2 could have a p value).

Regarding SE/CI for standardized coefficients, it would be ideal if an option were available to compute these accounting for the uncertainty in the SD used for standardization: https://psycnet.apa.org/record/2013-34330-001 https://idp.springer.com/authorize/casa?redirect_uri=https://link.springer.com/article/10.1007/s11336-013-9380-y

We implement that here: https://github.com/psychmeta/psychmeta/blob/fb6816579db4f0878c5586520268ec38edee15a1/R/lm_mat.R#L187

mattansb commented 3 years ago

@bwiernik I think if those are implemented in performance it would be easy to pull into report (a-la "build it and they will come" 😁)