scatter.plot: A regression function for simple regression and break point...

Description Usage Arguments Value Examples

Description

This function performed basic regression analysis with the option to add confidence intervals and prediction intervals; alternative regression approaches, e.g., segmented regression, change point analysis (through rpart) and confidence bounds, quantile regression, and lowess regression splines. This version also added a capacity for transforming percent values (where 0 is probably the minimum) by adding 1 or 100 before log transformation if users choose so. Any x variable with 0s and log is true, the add 1 to the original or 100 times of the original.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
scatter.plot(data = NULL, xvar, yvar, xName = "x", yName = "y",
  xlim = NULL, ylim = NULL, sign = FALSE, xlab = names(data[xvar]),
  ylab = names(data[yvar]), addaxes = TRUE, cex.eq = 1.5, bty = "o",
  type = "p", pch = 1, col = 1, main = "", cex.main = 1,
  cex.lab = 1, cex = 1, cex.axis = 1, lty = 1, las = 1, bg = "gray",
  side = 4, tx.col = 2, xlog.scale = 10, ylog.scale = 10,
  lab.pos = "topleft", labs = "", x.add = 0, add.fit = "none",
  interval = "none", ln.col = "red", level = 0.95, add.cor = FALSE,
  add.reg = FALSE, add.rq = FALSE, nl.rq = FALSE, rq.tau = 0.5,
  log = "", add = FALSE, add.r2 = FALSE, add.interp = FALSE,
  pred.x = NA, pred.y = NA, rounder1 = 2, rounder2 = 0, ...)

Arguments

data

A input data frame, default to be NULL,

xvar

x variable, either column name or index value

yvar

y variable, either column name or index value

xName

xName for making equation labels

yName

yName for making equation labels

xlim

xlim

ylim

ylim

sign

if TRUE then use signif for equation otherwise, use round

xlab

xlabel

ylab

ylabel

addaxes

to plot axes

bty

add a box frame

pch

point type

cex

magnifier

cex.axis

# magnifier

lty

line type

las

direct

bg

background col

side

which side to add

tx.col

is for col of labs ln.col for fitted line color

xlog.scale

either 10 or exp

ylog.scale

either 10 or exp

lab.pos

control position of labels "bottomright" "bottomleft", "topright", "topleft"

labs

add labels

x.add

1 to convert percent x value = 0 to 1+ x value , or 100, then *100+1,

add.fit

either "linear", "lowess", "loess", "segment" (segmented regression), "change" (regression tree)

level

CI level

add.cor

add spearman correlation,

add.reg

will add regression model

add.rq

# add regression quantile

rq.tau

a vector to indicate which quantiles we want to use

log

will control x,y axis if log,

add

if TRUE, then add to existing graph

add.r2

a boolean to indicate if r2

add.interp

will add a interpolation for inverse prediction of x based on pred.y

pred.x

used to predict x value

pred.y

used to predict y

rounder1

round number of digits for x value

rounder2

round number of digits for y value

yvar

for column index of x, y values in data data frame, or column names

inteval

"confidence", "prediction", "none"

rq

choose if we want to do quantile regression

nlrq

only works for logistic fit

addaxes

if true, add axes

ex.eq

equation

x.add

add x

Value

Returns . sum((x-xmean)^2)) = sum(x^2)- (sum(x))^2/length(x)

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
n = 50
x <- rlnorm(n) + 1:n
x <- (x - min(x))/max(x)
y <- n + 1:n + (rnorm(n))*0.2*n
par(mfrow=c(1,2))
plot(y~x)
scatter.plot(data = data.frame(x,y), xvar= "x", yvar = "y", add.fit = "linear", xlim = c(0,n), 
    ylim = range(y), log = "x", x.add =100)

kevinlzheng/RegR documentation built on May 20, 2019, 9:07 a.m.