-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include_reference = TRUE
erroneously works with datawizard::contr.deviation()
#966
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…deviation()` Fixes #962
strengejacke
commented
Apr 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add tests for:
library(parameters)
data("mtcars")
mtcars$cyl <- factor(mtcars$cyl)
mtcars$gear <- factor(mtcars$gear)
m <- lm(mpg ~ cyl + gear, data = mtcars, contrasts = list(cyl = datawizard::contr.deviation))
model_parameters(m, include_reference = TRUE)
#> Parameter | Coefficient | SE | 95% CI | t(27) | p
#> -------------------------------------------------------------------
#> (Intercept) | 19.70 | 1.18 | [ 17.28, 22.11] | 16.71 | < .001
#> cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001
#> cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001
#> gear [3] | 0.00 | | | |
#> gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498
#> gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#> using a Wald t-distribution approximation.
m <- lm(mpg ~ cyl + gear, data = mtcars)
model_parameters(m, include_reference = TRUE)
#> Parameter | Coefficient | SE | 95% CI | t(27) | p
#> -------------------------------------------------------------------
#> (Intercept) | 25.43 | 1.88 | [ 21.57, 29.29] | 13.52 | < .001
#> cyl [4] | 0.00 | | | |
#> cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001
#> cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001
#> gear [3] | 0.00 | | | |
#> gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498
#> gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#> using a Wald t-distribution approximation.
m <- lm(
mpg ~ cyl + gear,
data = mtcars,
contrasts = list(
cyl = datawizard::contr.deviation,
gear = contr.sum
)
)
model_parameters(m, include_reference = TRUE)
#> Parameter | Coefficient | SE | 95% CI | t(27) | p
#> -------------------------------------------------------------------
#> (Intercept) | 20.64 | 0.67 | [ 19.26, 22.01] | 30.76 | < .001
#> cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001
#> cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001
#> gear [1] | -0.94 | 1.09 | [ -3.18, 1.30] | -0.86 | 0.396
#> gear [2] | 0.38 | 1.11 | [ -1.90, 2.67] | 0.34 | 0.734
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#> using a Wald t-distribution approximation.
m <- lm(
mpg ~ cyl + gear,
data = mtcars,
contrasts = list(
cyl = contr.SAS,
gear = contr.sum
)
)
model_parameters(m, include_reference = TRUE)
#> Parameter | Coefficient | SE | 95% CI | t(27) | p
#> ------------------------------------------------------------------
#> (Intercept) | 15.83 | 1.24 | [13.28, 18.37] | 12.75 | < .001
#> cyl [8] | 0.00 | | | |
#> cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001
#> cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049
#> gear [1] | -0.94 | 1.09 | [-3.18, 1.30] | -0.86 | 0.396
#> gear [2] | 0.38 | 1.11 | [-1.90, 2.67] | 0.34 | 0.734
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#> using a Wald t-distribution approximation.
m <- lm(
mpg ~ cyl + gear,
data = mtcars,
contrasts = list(
cyl = contr.SAS,
gear = contr.treatment
)
)
model_parameters(m, include_reference = TRUE)
#> Parameter | Coefficient | SE | 95% CI | t(27) | p
#> ------------------------------------------------------------------
#> (Intercept) | 14.89 | 0.92 | [13.00, 16.77] | 16.19 | < .001
#> cyl [8] | 0.00 | | | |
#> cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001
#> cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049
#> gear [3] | 0.00 | | | |
#> gear [4] | 1.32 | 1.93 | [-2.63, 5.28] | 0.69 | 0.498
#> gear [5] | 1.50 | 1.85 | [-2.31, 5.31] | 0.81 | 0.426
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#> using a Wald t-distribution approximation.
Created on 2024-04-26 with reprex v2.1.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #962