regC: Linear regression analysis (OLS regression), with options for...

View source: R/regC.r

regCR Documentation

Linear regression analysis (OLS regression), with options for weighted observations, diagnostic tests, and plots of residuals

Description

Linear regression analysis function with many useful features. Standard output of results includes table of coefficients, table of residuals, and additional model information. Options for weighting observations, analysis of variance (ANOVA), performing post-estimation diagnostic tests, including testing normality of residuals and constant variance, and generating diagnostic plots of residuals.

Usage

regC(formula, w, data, digits = 3, anova = FALSE, norm.test = FALSE,
  ncv.test = FALSE, linear.test = FALSE, reset.test = FALSE,
  outlier.test = FALSE, vif = FALSE, printC = FALSE, res.plots = FALSE,
  ...)

Arguments

formula

should be in dataset$dv ~ datatset$iv1 + dataset$iv2 unless dataset specified in optional data argument. If weights are specified using w argument, the formula cannot contain functions or logical statements (all variables in the function must be named in the dataset).

w

(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument.

data

(Optional) Name of dataset that contains dv, iv (and w) variables.

digits

(Optional) Number of decimal places reported in result (defaults to 2).

anova

(Optional) Do you want ANOVA table reporting F-test for all predictors? (default: FALSE)

norm.test

(Optional) Test assumption that regression residuals follow normal distribution (default: FALSE)

ncv.test

(Optional) Test assumption that regression residuals have constant variance (default: FALSE)

linear.test

(Optional) Report results of linearity test? (default: FALSE)

reset.test

(Optional) Report results of model specification test? (default: FALSE)

outlier.test

(Optional) Test whether outlier observations have outsized leverage on results (default: FALSE)

vif

(Optional) Report variance inflation factors to assess multicollinearity? (default: FALSE)

printC

(Optional) Do you want to print tables of results (and residuals plots if res.plots=TRUE) to .html file in working directory? (default: FALSE)

res.plots

(Optional)

...

(Optional) Additional arguments passed to lm function (unweighted models) or svyglm function (weighted models).

Value

Returns a lm or svyglm object.

RCPA3 Package Tutorial Videos

Textbook References

  • Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapters 11, 12, 13.

  • Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 244-271. ISBN-13: 978-1506379616; ISBN-10: 150637961.

Online Resources

Examples

  library(RCPA3)
  
   
  # basic usage
  regC(states$vep20.turnout ~ states$hs.or.more)
   
  # with w and data arguments
  regC(nes$ft.unions ~ nes$ft.dem, w=nes$wt)
  
  # multiple IV with some post-estimation tests
  regC(peace.index ~ vdem.edi.score + hdi, data=world, norm.test=TRUE, ncv.test=TRUE)
  

RCPA3 documentation built on May 29, 2024, 12:19 p.m.

Related to regC in RCPA3...