gratia | based graphics and useful functions | Data Visualization library

 by   gavinsimpson R Version: v0.8.1 License: Non-SPDX

kandi X-RAY | gratia Summary

kandi X-RAY | gratia Summary

gratia is a R library typically used in Analytics, Data Visualization applications. gratia has no bugs, it has no vulnerabilities and it has low support. However gratia has a Non-SPDX License. You can download it from GitHub.

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

            kandi-support Support

              gratia has a low active ecosystem.
              It has 162 star(s) with 22 fork(s). There are 9 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 64 open issues and 141 have been closed. On average issues are closed in 257 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of gratia is v0.8.1

            kandi-Quality Quality

              gratia has 0 bugs and 0 code smells.

            kandi-Security Security

              gratia has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              gratia code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              gratia has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              gratia releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.
              It has 4 lines of code, 0 functions and 1 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gratia
            Get all kandi verified functions for this library.

            gratia Key Features

            No Key Features are available at this moment for gratia.

            gratia Examples and Code Snippets

            No Code Snippets are available at this moment for gratia.

            Community Discussions

            QUESTION

            Gratia package: probability instead of log odds for plotting generalized additive model (GAM)
            Asked 2022-Apr-01 at 20:26

            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:26

            You'll have to add the model constant term and transform by the inverse of the link function:

            Source https://stackoverflow.com/questions/71694817

            QUESTION

            Error when running a fixed effect in a GAM with an offset in R with gratia::draw()
            Asked 2022-Mar-16 at 10:20

            I have a data set that looks like this:

            ...

            ANSWER

            Answered 2022-Mar-16 at 10:20

            I 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:

            Source https://stackoverflow.com/questions/71413557

            QUESTION

            Strange `ErrorType` error referencing columns
            Asked 2022-Mar-13 at 07:37

            Given the following pandas Dataframe df -

            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) Barrack Family William and Rupert Trust 9957007 -1.44 -1.44 Barrack Family Cash - -1.44 -1.44 Barrack Family Gratia Holdings No. 2 LLC 8413655 55491732.66 -0.971018847 -0.971018847 11.52490309 55491732.66 Barrack Family Investment Grade Fixed Income - 18469768.6 18469768.6 Barrack Family High Yield Fixed Income - 3668982.44 -0.205356545 -0.205356545 4.441190127 3668982.44

            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:29

            You need a double square bracket when you are selecting a list:

            Source https://stackoverflow.com/questions/71454495

            QUESTION

            AttributeError: 'tuple' object has no attribute 'loc' when filtering on pandas dataframe
            Asked 2022-Mar-07 at 20:47

            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.44

            The 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:47
            return reporting_group_df, unknown_df, perf_asset_class_df, perf_entity_df, perf_entity_group_df
            

            Source https://stackoverflow.com/questions/71385082

            QUESTION

            ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all() with .loc
            Asked 2022-Mar-07 at 05:43

            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.44

            I 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:43

            Use |, 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:

            Source https://stackoverflow.com/questions/71376677

            QUESTION

            UserWarning: This pattern is interpreted as a regular expression, and has match groups
            Asked 2022-Mar-06 at 21:25

            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.44

            I 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:25

            Use the code below to suppress the warning:

            Source https://stackoverflow.com/questions/71374269

            QUESTION

            Why is expand.grid in R returning <0 rows>?
            Asked 2022-Feb-26 at 04:50

            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:53

            Try running each individual part of your problem to see what is happening

            Source https://stackoverflow.com/questions/71260745

            QUESTION

            Creating an editable partial effect plot in R with the gratia::draw() function that also has a rugplot
            Asked 2021-Dec-03 at 10:17

            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:17

            I 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...

            Source https://stackoverflow.com/questions/70204560

            QUESTION

            Troubles predicting fixed effects from a hierarchical GAM in mgcv
            Asked 2021-Jul-20 at 19:20

            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:14

            I 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:

            Source https://stackoverflow.com/questions/68438028

            QUESTION

            How to automatically install Bioconductor package on which a CRAN package depends through a long chain of dependencies?
            Asked 2020-Jun-20 at 20:24

            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:40

            Because 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.

            Source https://stackoverflow.com/questions/62486902

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install gratia

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link