Description Usage Arguments Examples
This function takes the linear regression model you estimate with lm() for your final projects and returns a plot of an effect for a selected variable.
1 2 3 4 5 6 | effect(model, var, level = 0.95, categoricalIV = F, x.label = NULL,
y.label = NULL, title = NULL, grid = F, rug = F,
ci.color = "lightgray", line.width = 1, line.color = "black",
pt.color = "black", pt.size = 1, pt.type = 16, plot.title = NULL,
x.value.labels = NULL, connect = FALSE, connect.lwd = 1,
connect.col = "black")
|
model |
The object name of your linear regression model. Example - if you run the following command: model1 <- lm(y~x), then enter 'model1' for this argument. |
var |
The variable to plot change in predicted values of 'y.' Your 'x' variable. |
level |
Confidence level, .95 is the default. |
categoricalIV |
Indicator for whether the plotted IV is a dummy variable, default is FALSE |
x.label |
Option to change x-axis label in plot |
y.label |
Option to change y-axis label in plot |
grid |
Option to plot with grid lines, default is FALSE |
rug |
Option to plot with rug to represent data density in plot, default is FALSE |
ci.color |
Color for confidence interval polygons, default is 'lightgray'. |
line.width |
Option to change fit regression line thickness, default is 1. |
pt.color |
Point color for average estimated effect of dummy independent variable, default is 'black'. |
pt.size |
Point size for average estimated effect of dummy independent variable, default is 1. |
pt.type |
Point style of regression parameter point estimate. Default is 16, circle. See ?points for information on different styles. |
plot.title |
Option to add title to plot |
x.value.labels |
Optional list of character names (must match length of categories) |
connect |
For categorical IV plots, add connecting line between points. |
connect.lwd |
Optional line width argument for connecting line in categorical IV plots. |
connect.col |
Optional line color option for connecting line in categorical IV plots. |
plot.title |
Optional plot title. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Estimate a regression using 'mtcars' data:
m <- lm(mpg~disp+hp+wt+am,data=mtcars)
# Plot effect of 'wt' variable
effect(m,'wt')
# Plot effect of dummy variable, 'am' with custom labels
effect(m,'am',categoricalIV=TRUE,x.value.labels=c('Automatic','Manual'))
# Plot with user-defined x-axis label
effect(m,'wt',x.label='Vehicle Weight')
# Plot with grid lines and rug
effect(m,'wt',x.label='Vehicle Weight',grid=TRUE,rug=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.