plotLinReg: Plot linear regression and confidence interval of regression

Description Usage Arguments Value See Also Examples

View source: R/plotLinReg.R

Description

This function provides help to display a series of bivariate points given in 'dat' (multiple data formats possible), to model a linear regression and plot the results. Furthermore, a confidence interval to the regression may be added to the plot, regression parameters get be displayed.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
plotLinReg(
  dat,
  indepVarLst = NULL,
  dependVar = NULL,
  cusTxt = NULL,
  regrLty = 1,
  regrLwd = 1,
  regrCol = 1,
  confInt = 0.95,
  confCol = NULL,
  xLab = NULL,
  yLab = NULL,
  xLim = NULL,
  yLim = NULL,
  tit = NULL,
  nSignif = 3,
  col = 1,
  pch = 1,
  silent = FALSE,
  callFrom = NULL
)

Arguments

dat

(numeric, data.frame or list) main data to plot/inspect. If numeric 'dat' will be used as dependent variable (y-data) together with numeric 'indepVarLst' (independent variable); if list, then list-elments indepVarLst and dependVar will be used; if matrix, the the 1st and 2nd colum will be used

indepVarLst

(character) if 'dat' is list, this designes the list element with the explanatory or independent variable (ie the variable used for explaining, typically x-data)

dependVar

(character) if 'dat' is list, this designes the list element with dependent variable (ie the variable to be explained, typically y-data) to test

cusTxt

(character) optional custom text to display in subtitle (instead of p-value to H0: slope.regression=0)

regrLty

(integer) line type for regression

regrLwd

(integer) line width for regression

regrCol

(integer) color of regression-line

confInt

(numeric, between 0 and 1) the probabiity alpha for the regression interval, if NULL no confidence intervall will be plotted/calculated

confCol

(character) (background) color for confidence-interval

xLab

(character) optional custom x-label

yLab

(character) optional custom y-label

xLim

(numeric) custom limit for x-axis (see also par)

yLim

(numeric) custom limit for y-axis (see also par)

tit

(character) optional title

nSignif

(integer) number of significant digits for regression parameters in subtitle of plot

col

(integer or character) custom color for points (choose NULL for not plotting the actual data)

pch

(integer or character) type of symbol for points (see also par)

silent

(logical) suppress messages

callFrom

(character) allows easier tracking of message(s) produced

Value

plot and invisible list containing $data, $linRegr, $confInterval (if calculated)

See Also

exclExtrValues for decision of potential outliers; hist, vioplotW

Examples

1
2
3
4
5
set.seed(2020); dat1 <- rep(1:6,each=2) +runif(12,0,1)
plotLinReg(dat1, gl(6,2))
# extract elements out of list :
li2 <- list(aa=gl(5,2), bb=dat1[1:10])
plotLinReg(li2, indepVarLst="aa", dependVar="bb")

wrGraph documentation built on April 12, 2021, 1:07 a.m.