confidence: Plot confidence intervals for variables from your linear...

Description Usage Arguments Examples

View source: R/confidence.R

Description

This function takes the linear regression model you estimate with lm() for your final projects and returns a coefficient plot appropriate for you to use in your poster or final paper.

Usage

1
2
3
confidence(model, vars = NULL, var.labels = NULL, level = 0.95,
  grid = T, grid.int = 5, mai = NULL, ps = 12, pt.type = 16,
  pt.size = 1, pt.color = "black", lwd = 1, lty = 2, legend = F)

Arguments

model

Model takes the object name of your linear regression model. Example - if you run the following command: m1 <- lm(y~x), then enter m1 for this argument.

var.labels

New variable names for the plot to be entered as characters here. Note, this must be the same length as the variables in your model. If you have four variables, you must enter four names. See example code below.

grid

Include vertical grid lines in the plot. Default is True.

grid.int

Spacing interval for grid lines. Default value is 5.

mai

Change plot margins (inches).

ps

Change text size in plot. This will be useful for your posters (30 would be good for a poster, 12 for a paper).

pt.type

Point style of regression parameter point estimate. Default is 16, circle. See ?points for information on different styles.

pt.size

Side of point estimate, default is 1.

pt.color

Color of point estimate, default is 'black', Any color argument will work here.

lwd

Line width for confidence intervals, default is 1.

lty

Line type for confidence intervals, default is 2 (dashed line). See the lty argument in ?par for additional details on line types.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Estimate a regression using 'mtcars' data:
m <- lm(mpg~disp+hp+wt,data=mtcars)
confidence(m)

# Plot without intercept:
confidence(m,vars=c('disp','hp','wt'))

# Plot with intercept and one covariate:
confidence(m,vars=c('(Intercept)','wt'))

# Plot with two model variables AND new variable names:
confidence(m,vars=c('disp','wt'),var.labels=c('Displacement','Weight'))

# Plot with higher confidence interval and legend:
confidence(m,level=0.99,legend=TRUE)

# Dynamic margins for longer variable names:
confidence(m, vars=c('hp','wt'),var.labels=c('A really long name for variable: Horse Power','Weight'))

loganstundal/POL3085 documentation built on May 21, 2019, 10:32 a.m.