biVarPlot: A bivariate regression function

Description Usage Arguments Examples

View source: R/biVarPlot.R

Description

This function will fit a linear model to two variables. The criterion can be continuous or binary. For logistic regression, set family = 'binomial'. For poisson regression, set family = 'poisson'. If omitted, family will default to 'gaussian' for standard linear regression.

Usage

1
biVarPlot(data, x, y, family = "Gaussian")

Arguments

data

A data frame.

x

An independent variable

y

A dependent variable

family

A distribution ('gaussian', 'binomial', or 'poisson')

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Linear regression
biVarPlot(data = cars, x = dist, y = speed)
biVarPlot(data = mtcars, x = cyl, y = mpg)
biVarPlot(data = Orange, x = age, y = circumference)
biVarPlot(data = ChickWeight, x = Time, y = weight)
biVarPlot(data = USArrests, x = UrbanPop, y = Rape)

# Logistic regression
vot  <- rnorm(20, 15, 5)
vot  <- sort(vot)
phon <- c(0,1,0,0,0,0,0,1,0,1,0,1,0,1,1,1,1,1,1,1)
df1  <- data.frame(vot, phon)
biVarPlot(data = df1, x = vot, y = phon, family = 'binomial')

# Poisson regression
time   <- 1:10
counts <- c(18, 17, 21, 20, 25, 27, 30, 43, 52, 50)
df2    <- data.frame(time, counts)
biVarPlot(data = df2, x = time, y = counts, family = 'poisson')

jvcasillas/lingStuff documentation built on April 12, 2021, 6:59 p.m.