uwSimpleReg: Scatter Plot with Simple Linear Regression Line

Description Usage Arguments Value Author(s) See Also Examples

View source: R/uwSimpleReg.R

Description

This function creates a scatter plot of two continuous variables and adds the fitted simple linear regression line.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
uwSimpleReg(
  Data,
  respVar,
  depVar,
  printPVal = TRUE,
  printModel = TRUE,
  printRsq = TRUE,
  returnList = TRUE,
  ...
)

Arguments

Data

Data frame with response and dependent variable

respVar

String of the response variable's name in Data

depVar

String of the dependent variable's name in Data

printPVal

Logical: TRUE indicates p-value for beta1 = 0 is printed in margin of plot

printModel

Logical: TRUE indicates fitted model is printed in margin of plot

printRsq

Logical: TRUE indicates multiple R-squared is printed in margin of plot

returnList

Logical: TRUE returns list of Coefficient and P-Value

...

Any other arguments that can be used by plot()

Value

Plots a scatterplot and regression line. Returns list of beta1 coefficient and p-value

Author(s)

University of Wisconsin-Madison Biostatistics and Medical Informatics Department, Scott Hetzel M.S.

See Also

plot(), abline(), lm()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Xvar <- rnorm(50, -10, 1)
Yvar <- 0.5 * Xvar + rnorm(50, 0, 1)

dfLin <- data.frame(Xvar, Yvar)

layout(1)
uwSimpleReg(
  Data = dfLin, respVar = "Yvar", depVar = "Xvar",
  main = "Example of uwSimpleReg",
  ylab = "Example Response", xlab = "Example Explanatory",
  ylim = NULL, xlim = NULL, printPVal = TRUE, printModel = TRUE, printRsq = TRUE
)

jbirstler/biostatrpts documentation built on May 7, 2020, 12:10 a.m.