multireg: Draws and estimates multiple regression model with two...

View source: R/multireg.R

multiregR Documentation

Draws and estimates multiple regression model with two independent variables

Description

Draws and estimates multiple regression model with two independent variables

Usage

multireg(
  y,
  x,
  z,
  interaction = TRUE,
  ylab = NULL,
  xlab = NULL,
  main = NULL,
  col = NULL,
  xlim = NULL,
  ylim = NULL,
  lwd = 2,
  pch = 16,
  legend = TRUE,
  locator = "top",
  lty = NULL,
  bty = "n",
  horiz = TRUE,
  title = NULL,
  shift = 0.15,
  quantiles_z = c(0.25, 0.5, 0.75),
  colquant = 2:(length(quantiles_z) + 1)
)

Arguments

x

# a numeric or factor variable

z

# a numeric or factor variable

interaction=TRUE

Logical. if TRUE calculates and draws model with interaction

ylab=NULL

y axis label

xlab=NULL

x axis label

main=NULL

main title

col=NULL

color

xlim=NULL

limits of x axis

ylim=NULL

limits of x axis

lwd=2

regression line width

pch=16

point character

legend=TRUE

Logical, if TRUE draws legend

locator="top"

locatin of legend

lty=NULL

line type of legend elements

bty="n"

box type of legend

horiz=TRUE

adjust legend text horizontally

title=NULL

legend title

shift=.15

distance of groups in interactionplot

quantiles_z=c(.25, .5, .75)

vector of quantiles to split z

colquant=2:(length(quantiles_z)+1)

vector of colors for groups

Examples

# create variables
metricY<-rnorm(100)
metricX1<-rnorm(100)
metricX2<-rnorm(100)
binaryY<-rbinom(100,1,.5)
factorY<-factor(sample(paste("Category",1:3),100,T))
factorX1<-factor(sample(paste("Level X1",1:3),100,T))
factorX2<-factor(sample(paste("Level X2",1:3),100,T))
metricY<metricX1*metricX2+rnorm(100)
multireg(metricY,metricX1,metricX2)
binaryY<-ifelse(((metricX1*metricX2)+rnorm(100))>0,1,0)
# use multireg
multireg(metricY,metricX1,metricX2,legend=T,main="metric Y ~ metric X1 * metric X2")#
multireg(metricY,metricX1,factorX2,legend=T,title=NULL,main="metric Y ~ metric X1 * factor X2")#
multireg(metricY,factorX1,factorX2,legend=T,main="metric Y ~ factor X1 * factor X2")#
multireg(binaryY,metricX1,metricX2,legend=,main="binary Y ~ metric X1 * metric X2")#
multireg(binaryY,metricX1,factorX2,legend=F,title=NULL,main="binary Y ~ metric X1 * factor X2")#
multireg(binaryY,factorX1,factorX2,legend=T,main="binary Y ~ factor X1 * factor X2")#
multireg(factorY,metricX1,metricX2,legend=T,main="factor Y ~ metric X1 * metric X2")#
multireg(factorY,metricX1,factorX2,legend=T,main="factor Y ~ metric X1 * factor X2")#
multireg(factorY,factorX1,factorX2,legend=T,main="factor Y ~ factor X1 * factor X2")#

ingmarboeschen/graphing documentation built on Jan. 14, 2025, 7:32 a.m.