Description Usage Arguments Value Methods (by class) Examples
partial_plot
accepts a fitted regression object and the name of the
variable you wish to view the
partial
regression plot of as a character string. It returns a ggplot
object
showing the independent variable values on the x-axis with the resulting
predictions from the independent variable's values and coefficients on the
y-axis. This shows the relationship that the model has estimated between the
independent variable the dependent variable. You can determine which
prediction level the plot is against using the response
parameter
which is a logical value defaulted to FALSE
.
1 2 3 4 | partial_plot(fitted_model, ...)
## S3 method for class 'gam'
partial_plot(fitted_model, variable, response = F, rug = F)
|
fitted_model |
a complete regression model object |
variable |
the name of the independent variable as a character string |
response |
logical indicating if the plot should be on the linear
prediction scale or the response scale. Defaults to |
rug |
logical indicating if a rug plot should be added on the independent variable axis |
a ggplot2
object of the partial regression plot
gam
: provides partial plots for fitted gam
models
1 2 3 4 5 6 7 8 | library(mgcv)
car_gam <- gam(mpg ~ s(hp), data = mtcars)
partial_plot(car_gam, "hp")
# Response level changes look for non-gaussian families
am_gam <- gam(factor(am) ~ s(hp), data = mtcars, family = "binomial")
partial_plot(am_gam, "hp") # on the log odds scale
partial_plot(am_gam, "hp", response = T) # on the probability scale
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.