plotLinReg {wrGraph} | R Documentation |
Plot linear regression and confidence interval of regression
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
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,
debug = 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 |
(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 |
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 |
yLim |
(numeric) custom limit for y-axis (see also |
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 |
pch |
(integer or character) type of symbol for points (see also |
silent |
(logical) suppress messages |
debug |
(logical) additional messages for debugging |
callFrom |
(character) allow easier tracking of messages produced |
Value
This functions simply plots (to the current graphical devce); an invisible list containing $data, $linRegr, $confInterval (if calculated) may be returned, too
See Also
exclExtrValues
for decision of potential outliers; hist
, vioplotW
Examples
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")