This is the repository of the `R` package `tidymv`. This package provides functions for the visualisation of GAM(M)s using tidy tools from the `tidyverse`. `tidymv` is based on the `itsadug` package, and indeed it uses some of its functions under the hood.
##Installation
To install the package, use devtools::install_github("stefanocoretta/tidymv@v1.1.0", build_vignettes = TRUE). To learn how to use the package, do vignette("plot-gamms", package = "tidymv") after the installation.
Reference and difference smooths of factor predictos from a `gam` model can be plotted with `plot_gamsd()`.
To illustrate how to use `plot_gamsd()`, let's first prepare some dummy data with a factor variable and run `gam()` on this data. The `gam` model includes a reference smooth `s(x2)`, a by-factor difference smooth `s(x2, by = fac)`, and a smooth `s(x0)`.
```{r gam}
set.seed(10)
data<- gamSim(4)
model<- gam(
y~
fac+
s(x2) +
s(x2, by=fac) +
s(x0),
data=data
)
```
We can now plot the estimated smooths for the two levels of `fac`, and the difference smooth.
It is only possible to compare two levels at once, so here we plot `1` and `2`.
Portions of the estimated smooths that are significantly different are indicated by a shaded red area both in the estimated smooths panel (top) and the difference smooth panel (bottom).
Significance is based on the difference smooth: at any point, if the confidence interval of the difference smooth does not include 0, the difference between the estimated smooths is significant.
```{r plot-1-2}
plot_gamsd(
model=model,
view="x2",
comparison=list(fac= c("1", "2"))
)
```
Here we compare `1` with `3`, and we plot in black and white (gray scale).
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
Some generated files are not rendered by default. Learn more.
Large diffs are not rendered by default.