gratia | based graphics and useful functions | Data Visualization library
kandi X-RAY | gratia Summary
kandi X-RAY | gratia Summary
Graceful ‘ggplot’-based graphics and utility functions for working with generalized additive models (GAMs) fitted using the ‘mgcv’ package. Provides a reimplementation of the plot() method for GAMs that ‘mgcv’ provides, as well as ‘tidyverse’ compatible representations of estimated smooths.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gratia
gratia Key Features
gratia Examples and Code Snippets
Community Discussions
Trending Discussions on gratia
QUESTION
I was trying to plot a logistic GAM model using the gratia package (since it uses ggplot2), however I would like the effects (or partial effects) to be plotted in terms of probabilities instead of log odds.
I have tried by hand using probabilities, however I prefer to use the gratia package. Would there be a way to plot the probabilities specifically using the package?
The model (I created some data):
...ANSWER
Answered 2022-Apr-01 at 20:26You'll have to add the model constant term and transform by the inverse of the link function:
QUESTION
I have a data set that looks like this:
...ANSWER
Answered 2022-Mar-16 at 10:20I can't reproduce this error with version 0.7.1 (on GitHub, but about to be submitted to CRAN) and I don't think anything of relevance to the reported problem changed between 0.7.0 (the current CRAN version) and this patched version.
With your data in tmp
:
QUESTION
Given the following pandas Dataframe df
-
I am trying to only keep rows that where Entity/Grouping
column values == Cash
AND where any of the following column values are NaN
-
Adjusted TWR (Current Quarter, No Div, USD)
Adjusted TWR (YTD, No Div, USD)
Annualized Adjusted TWR (Since Inception, No Div, USD)
Current code: the following function takes df
and tries to perform the above said and return, ready for use in another function -
ANSWER
Answered 2022-Mar-13 at 07:29You need a double square bracket when you are selecting a list:
QUESTION
Given the following DataFrame -
json_path Reporting Group Entity/Grouping Entity ID Adjusted Value (Today, No Div, USD) Adjusted TWR (Current Quarter, No Div, USD) Adjusted TWR (YTD, No Div, USD) Annualized Adjusted TWR (Since Inception, No Div, USD) Adjusted Value (No Div, USD) TWR Audit Note data.attributes.total.children.[0].children.[0].children.[0] Barrack Family William and Rupert Trust 9957007 -1.44 -1.44 data.attributes.total.children.[0].children.[0].children.[0].children.[0] Barrack Family Cash - -1.44 -1.44 data.attributes.total.children.[0].children.[0].children.[1] Barrack Family Gratia Holdings No. 2 LLC 8413655 55491732.66 -0.971018847 -0.971018847 11.52490309 55491732.66 data.attributes.total.children.[0].children.[0].children.[1].children.[0] Barrack Family Investment Grade Fixed Income - 18469768.6 18469768.6 data.attributes.total.children.[0].children.[0].children.[1].children.[1] Barrack Family High Yield Fixed Income - 3668982.44 -0.205356545 -0.205356545 4.441190127 3668982.44The following code should filter out rows where rows != 'Cash' (Entity/Grouping
column) and that have a blank value in either Adjusted TWR (Current Quarter, No Div, USD)
column, Adjusted TWR (YTD, No Div, USD)
column or Annualized Adjusted TWR (Since Inception, No Div, USD)
column.
Code: The following code expects to achieve this -
...ANSWER
Answered 2022-Mar-07 at 20:47return reporting_group_df, unknown_df, perf_asset_class_df, perf_entity_df, perf_entity_group_df
QUESTION
Given the following pandas DataFrame -
json_path Reporting Group Entity/Grouping Entity ID Adjusted Value (Today, No Div, USD) Adjusted TWR (Current Quarter, No Div, USD) Adjusted TWR (YTD, No Div, USD) Annualized Adjusted TWR (Since Inception, No Div, USD) Adjusted Value (No Div, USD) TWR Audit Note data.attributes.total.children.[0].children.[0].children.[0] Barrack Family William and Rupert Trust 9957007 -1.44 -1.44 data.attributes.total.children.[0].children.[0].children.[0].children.[0] Barrack Family Cash - -1.44 -1.44 data.attributes.total.children.[0].children.[0].children.[1] Barrack Family Gratia Holdings No. 2 LLC 8413655 55491732.66 -0.971018847 -0.971018847 11.52490309 55491732.66 data.attributes.total.children.[0].children.[0].children.[1].children.[0] Barrack Family Investment Grade Fixed Income - 18469768.6 18469768.6 data.attributes.total.children.[0].children.[0].children.[1].children.[1] Barrack Family High Yield Fixed Income - 3668982.44 -0.205356545 -0.205356545 4.441190127 3668982.44I am trying to filter on rows that != Cash
('Entity/Grouping'
column) and that have a blank value in 'Adjusted TWR (Current Quarter, No Div, USD)'
column, 'Adjusted TWR (YTD, No Div, USD)'
column or 'Annualized Adjusted TWR (Since Inception, No Div, USD)'
column.
Code: I am trying to achieve this by the following code -
ANSWER
Answered 2022-Mar-07 at 05:43Use |
, not or
to combine boolean Series.
In your case you can simplify using comparison to empty string on a slice of all target columns and any
:
QUESTION
Given the following pandas DataFrame -
json_path Reporting Group Entity/Grouping Entity ID Adjusted Value (Today, No Div, USD) Adjusted TWR (Current Quarter, No Div, USD) Adjusted TWR (YTD, No Div, USD) Annualized Adjusted TWR (Since Inception, No Div, USD) Adjusted Value (No Div, USD) TWR Audit Note data.attributes.total.children.[0].children.[0].children.[0] Barrack Family William and Rupert Trust 9957007 -1.44 -1.44 data.attributes.total.children.[0].children.[0].children.[0].children.[0] Barrack Family Cash - -1.44 -1.44 data.attributes.total.children.[0].children.[0].children.[1] Barrack Family Gratia Holdings No. 2 LLC 8413655 55491732.66 -0.971018847 -0.971018847 11.52490309 55491732.66 data.attributes.total.children.[0].children.[0].children.[1].children.[0] Barrack Family Investment Grade Fixed Income - 18469768.6 18469768.6 data.attributes.total.children.[0].children.[0].children.[1].children.[1] Barrack Family High Yield Fixed Income - 3668982.44 -0.205356545 -0.205356545 4.441190127 3668982.44I try and save only rows that contain 4x occurances of .children.[]
using the following statement -
Code: perf_by_entity_df = df[df['json_path'].str.contains(r'(\.children\.\[\d+\]){4}')]
However receive the following:
Error:UserWarning: This pattern is interpreted as a regular expression, and has match groups. To actually get the groups, use str.extract.
Any suggestions why this is happening?
...ANSWER
Answered 2022-Mar-06 at 21:25Use the code below to suppress the warning:
QUESTION
I'm trying to use expand.grid
to eventually plot estimates from a statistical model. But the output is:
ANSWER
Answered 2022-Feb-25 at 03:53Try running each individual part of your problem to see what is happening
QUESTION
The question I have has mostly been answered by the following post: Cannot update/edit ggplot2 object exported from a package (`gratia`) in R. When I refer to the mydraw.gam function, it comes from code in that post. What I am trying to do is use the mydraw.gam function with a rugplot that looks like the gratia::draw() function.
This is my data:
...ANSWER
Answered 2021-Dec-03 at 10:17I would just use smooth_estimates()
and its draw()
method to plot a single smooth from the model. You can then add to it using standard ggplot2 functionality...
QUESTION
I have been fitting different hierarchical GAMs (hereafter: HGAM) using mgcv
in R. I can extract and plot their predictions for their random effects without problems. Conversely, extracting and plotting their predictions for their fixed effects only works for some models, and I don't know why.
Here is a practical example, which refers to the color spectra of flowers from two species (Taxon
) sampled at various localities (also discussed here):
ANSWER
Answered 2021-Jul-20 at 11:14I think you are conflating several things here; The by
trick to turn off random effects only works for bs = "re"
smooths. Locality
is a factor (otherwise your random effect isn't a random intercept) and setting it to 0
is creating a new level (although it could be creating an NA as 0
isn't among the original levels.
If what you want to do is turn off anything to do with Locality
, you should use exclude
; however you have the invocation wrong. The reason why it's not working is because you are creating a character vector with a single element "c(Locality)"
. This fails for obvious reasons once you realize that c(Locality)
doesn't related to anything in your model. What you need to provide here is a vector of smooth names as printed by summary()
. For example, to exclude the smooth s(Locality, bs = "re")
, {mgcv} knows this as s(Locality)
, so you would use exclude = "s(Locality)"
.
In your case, it is tedious to type out all the "s(wl):LocalityLevelX"
labels for each smooth. As you have only two taxa, it would be easier to use the complimentary argument terms
, where you list smooth labels that you want to include in the model. So you could do terms = c("s(wl):TaxonSpeciesB", "s(wl):TaxonSpeciesC")
or whatever summary()
displays for these smooths.
You also need to include the Taxon
term in terms
, which I think needs to be:
QUESTION
I have a package metagam
which is on CRAN, and it passes all of CRAN's automated tests. However, the package depends on the Bioconductor package multtest
through the chain of dependencies metagam
<- metap
<- mutoss
<- multtest
. This is visualized below for the dependencies of the metap
package.
ANSWER
Answered 2020-Jun-20 at 14:40Because Bioconductor has twice-yearly releases, and this differs from CRAN release practices, the 'right' thing to do is to use Bioconductor tools to install your package, so BiocManager::install("metap")
. It does not matter that metap is a CRAN package. BiocManager installs the correct version of the Bioconductor package for the user's version of R.
If this solution isn't palatable, then the next-best right thing to do is to adjust your dependencies to avoid direct or indirect dependencies on Bioconductor packages.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gratia
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page