-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
summary.estimate_slopes()
no longer working.
#371
Open
strengejacke
wants to merge
8
commits into
main
Choose a base branch
from
strengejacke/issue345
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
This comment was marked as outdated.
This comment was marked as outdated.
I see, from the gam-example, and now understand the "segments" idea. Ignore this for now, let's try to make the |
More like this? library(modelbased)
model <- mgcv::gam(Sepal.Width ~ s(Petal.Length), data = iris)
slopes <- estimate_slopes(model, by = "Petal.Length", length = 50)
#> No numeric variable was specified for slope estimation. Selecting `trend
#> = "Petal.Length"`.
summary(slopes)
#> Average Marginal Effects
#>
#> Start | End | Direction | Confidence
#> ------------------------------------------
#> 1.00 | 1.60 | positive | Not Significant
#> 1.72 | 1.96 | negative | Not Significant
#> 2.08 | 3.05 | negative | Significant
#> 3.17 | 3.41 | negative | Not Significant
#> 3.53 | 3.65 | positive | Not Significant
#> 3.77 | 4.25 | positive | Significant
#> 4.37 | 6.18 | positive | Not Significant
#> 6.30 | 6.90 | negative | Not Significant
#>
#> Marginal effects estimated for Petal.Length
#> Type of slope was dY/dX
model <- mgcv::gam(Sepal.Width ~ s(Petal.Length, by = Species), data = iris)
slopes <- estimate_slopes(model,
trend = "Petal.Length",
by = c("Petal.Length", "Species"), length = 20
)
summary(slopes)
#> Average Marginal Effects
#>
#> Group | Start | End | Direction | Confidence
#> -------------------------------------------------------
#> setosa | 1.00 | 1.62 | positive | Not Significant
#> versicolor | 3.17 | 5.04 | positive | Significant
#> virginica | 4.73 | 5.66 | positive | Significant
#> virginica | 5.97 | 6.90 | positive | Not Significant
#>
#> Marginal effects estimated for Petal.Length
#> Type of slope was dY/dX Created on 2025-01-29 with reprex v2.1.1 |
m <- lm(Sepal.Width ~ Petal.Length * Petal.Width, data = iris)
modelbased::estimate_slopes(m, "Petal.Length", by = "Petal.Width") |> summary()
#> Average Marginal Effects
#>
#> Start | End | Direction | Confidence
#> ------------------------------------------
#> 0.10 | 0.90 | negative | Significant
#> 1.17 | 1.70 | negative | Not Significant
#> 1.97 | 2.23 | positive | Not Significant
#> 2.50 | 2.50 | positive | Significant
#>
#> Marginal effects estimated for Petal.Length
#> Type of slope was dY/dX
modelbased::estimate_slopes(m, "Petal.Length", by = "Petal.Width", length = 150) |> summary()
#> Average Marginal Effects
#>
#> Start | End | Direction | Confidence
#> ------------------------------------------
#> 0.10 | 1.15 | negative | Significant
#> 1.16 | 1.69 | negative | Not Significant
#> 1.71 | 2.44 | positive | Not Significant
#> 2.45 | 2.50 | positive | Significant
#>
#> Marginal effects estimated for Petal.Length
#> Type of slope was dY/dX Created on 2025-01-29 with reprex v2.1.1 |
Ill be travelling over this weekend so I'll get to this next week! |
Yeah, I don't think this PR is too urgent. |
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 #345