Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

psycModel (version 0.5.0)

polynomial_regression_plot: Polynomial Regression Plot

Description

[Experimental]
The function create a simple regression plot (no interaction). Can be used to visualize polynomial regression.

Usage

polynomial_regression_plot(
  model,
  model_data = NULL,
  predictor,
  graph_label_name = NULL,
  x_lim = NULL,
  y_lim = NULL,
  plot_color = FALSE
)

Value

an object of class ggplot

Arguments

model

object from lm

model_data

optional dataframe (in case data cannot be retrieved from the model)

predictor

predictor variable name (must be character)

graph_label_name

vector of length 3 or function. Vector should be passed in the form of c(response_var, predict_var1, predict_var2). Function should be passed as a switch function that return the label based on the name passed (e.g., a switch function)

x_lim

the plot's upper and lower limit for the x-axis. Length of 2. Example: c(lower_limit, upper_limit)

y_lim

the plot's upper and lower limit for the y-axis. Length of 2. Example: c(lower_limit, upper_limit)

plot_color

default if FALSE. Set to TRUE if you want to plot in color

Details

It appears that predict cannot handle categorical factors. All variables are converted to numeric before plotting.

Examples

Run this code
fit = lm(data = iris, Sepal.Length ~ poly(Petal.Length,2))
polynomial_regression_plot(model = fit,predictor = 'Petal.Length')

Run the code above in your browser using DataLab