PLOT_MODEL {SIMPLE.REGRESSION} | R Documentation |
Plots predicted values for a regression model
Description
Plots predicted values of the outcome variable for specified levels of predictor variables for OLS_REGRESSION, MODERATED_REGRESSION, LOGISTIC_REGRESSION, and COUNT_REGRESSION models from this package.
Usage
PLOT_MODEL(model,
IV_focal_1, IV_focal_1_values=NULL,
IV_focal_2=NULL, IV_focal_2_values=NULL,
IVs_nonfocal_values = NULL,
bootstrap=FALSE, N_sims=1000, CI_level=95,
xlim=NULL, xlab=NULL,
ylim=NULL, ylab=NULL,
title = NULL,
verbose=TRUE)
Arguments
model |
The returned output from the OLS_REGRESSION, MODERATED_REGRESSION, LOGISTIC_REGRESSION, or COUNT_REGRESSION functions in this package. |
IV_focal_1 |
The name of the focal, varying predictor variable.
|
IV_focal_1_values |
(optional) Values for IV_focal_1, for which predictions of the
outcome will be produced and plotted.
IV_focal_1_values will appear on the x-axis in the plot.
If IV_focal_1 is numeric and IV_focal_1_values is not provided,
then a sequence based on the range of the model data values for IV_focal_1 will be used.
If IV_focal_1 is a factor & IV_focal_1_values is not provided, then the
factor levels from the model data values for IV_focal_1 will be used.
|
IV_focal_2 |
(optional) If desired, the name of a second focal predictor variable for the plot.
|
IV_focal_2_values |
(optional) Values for IV_focal_2 for which predictions of the
outcome will be produced and plotted.
If IV_focal_2 is numeric and IV_focal_2_values is not provided, then
the following three values for IV_focal_2_values, derived from the model data,
will be used for plotting: the mean, one SD below the mean, and one SD above the mean.
If IV_focal_2 is a factor & IV_focal_2_values is not provided, then the
factor levels from the model data values for IV_focal_2 will be used.
|
IVs_nonfocal_values |
(optional) A list with the desired constant values for the non focal predictors,
if any. If IVs_nonfocal_values is not provided, then the mean values of numeric non focal
predictors and the baseline values of factors will be used as the defaults.
It is also possible to specify values for only some of the IVs_nonfocal variables
on this argument.
|
bootstrap |
(optional) Should bootstrapping be used for the confidence intervals? The options are TRUE or FALSE (the default). |
N_sims |
(optional) The number of bootstrap simulations.
|
CI_level |
(optional) The desired confidence interval, in whole numbers.
|
xlim |
(optional) The x-axis limits for the plot.
|
xlab |
(optional) A x-axis label for the plot.
|
ylim |
(optional) The y-axis limits for the plot.
|
ylab |
(optional) A y-axis label for the plot.
|
title |
(optional) A title for the plot.
|
verbose |
Should detailed results be displayed in console? |
Details
Plots predicted values of the outcome variable for specified levels of predictor variables for OLS_REGRESSION, MODERATED_REGRESSION, LOGISTIC_REGRESSION, and COUNT_REGRESSION models from this package.
A plot with both IV_focal_1 and IV_focal_2 predictor variables will look like an interaction plot. But it is only a true interaction plot if the required product term(s) was entered as a predictor when the model was created.
Value
A matrix with the levels of the variables that were used for the plot along with the predicted values, confidence intervals, and se.fit values.
Author(s)
Brian P. O'Connor
Examples
ols_GS <-
OLS_REGRESSION(data=data_Green_Salkind_2014, DV='injury',
hierarchical = list( step1=c('age','quads','gluts','abdoms'),
step2=c('arms','grip')) )
PLOT_MODEL(model = ols_GS,
IV_focal_1 = 'gluts', IV_focal_1_values=NULL,
IV_focal_2='age', IV_focal_2_values=NULL,
IVs_nonfocal_values = NULL,
bootstrap=TRUE, N_sims=1000, CI_level=95,
ylim=NULL, ylab=NULL, title=NULL,
verbose=TRUE)
ols_LW <-
MODERATED_REGRESSION(data=data_Lorah_Wong_2018, DV='suicidal', IV='burden', MOD='belong_thwarted',
IV_range='tumble',
MOD_levels='quantiles',
quantiles_IV=c(.1, .9), quantiles_MOD=c(.25, .5, .75),
COVARS='depression',
plot_type = 'interaction', DV_range = c(1,1.25))
PLOT_MODEL(model = ols_LW,
IV_focal_1 = 'burden', IV_focal_1_values=NULL,
IV_focal_2='belong_thwarted', IV_focal_2_values=NULL,
bootstrap=TRUE, N_sims=1000, CI_level=95)
logmod_Meyers <-
LOGISTIC_REGRESSION(data= data_Meyers_2013, DV='graduated',
forced= c('sex','family_encouragement') )
PLOT_MODEL(model = logmod_Meyers,
IV_focal_1 = 'family_encouragement', IV_focal_1_values=NULL,
IV_focal_2=NULL, IV_focal_2_values=NULL,
bootstrap=FALSE, N_sims=1000, CI_level=95)
pois_Krem <-
COUNT_REGRESSION(data=data_Kremelburg_2011, DV='OVRJOYED', forced=NULL,
hierarchical= list( step1=c('AGE','SEX_factor'),
step2=c('EDUC','REALRINC','DEGREE')) )
PLOT_MODEL(model = pois_Krem,
IV_focal_1 = 'AGE',
IV_focal_2='DEGREE',
IVs_nonfocal_values = list( EDUC = 5, SEX_factor = '2'),
bootstrap=FALSE, N_sims=1000, CI_level=95)