Skip to main content
U.S. flag

An official website of the United States government

Here’s how you know

Dot gov

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

HTTPS

Secure .gov websites use HTTPS
A lock (LockA locked padlock) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

    • Environmental Topics
    • Air
    • Bed Bugs
    • Cancer
    • Chemicals, Toxics, and Pesticide
    • Emergency Response
    • Environmental Information by Location
    • Health
    • Land, Waste, and Cleanup
    • Lead
    • Mold
    • Radon
    • Research
    • Science Topics
    • Water Topics
    • A-Z Topic Index
    • Laws & Regulations
    • By Business Sector
    • By Topic
    • Compliance
    • Enforcement
    • Laws and Executive Orders
    • Regulations
    • Report a Violation
    • Environmental Violations
    • Fraud, Waste or Abuse
    • About EPA
    • Our Mission and What We Do
    • Headquarters Offices
    • Regional Offices
    • Labs and Research Centers
    • Planning, Budget, and Results
    • Organization Chart
    • EPA History

Breadcrumb

  1. Home
  2. Causal Analysis/Diagnosis Decision Information System (CADDIS)

Using R for Significance Tests

  • Introduction
  • Using Taxon-Environment Relationships
  • Estimating Taxon-Environment Relationships
  • Computing Inferences
  • R Scripts

How to Test the Statistical Significance of Regression Models

Helpful Links
Topics In R Scripts
  • R Scripts
  • Download Scripts and Sample Data
  • Loading Data
  • Central Tendencies
  • Environmental Limits
  • Parametric Regressions
  • Non-Parametric Regressions
  • Significance Tests
  • Area Under the ROC Curve
  • Curve Shape
  • Weighted Average Inference
  • Estimate Taxon-Environment Relationships Using taxon.env()

PECBO Appendix Site Map

A chi-square test of nested models is a robust means of testing the statistical significance of regression models. For a parametric regression model, the taxon-environment relationship is modeled using three degrees of freedom (a constant, a linear term, and a quadratic term). The following script tests the significance of this model against nested models expressed only as a constant and as a constant and a linear term.

# Conduct chi-square tests on nested parametric models
for (i in 1:length(taxa.names)) {

  print(taxa.names[i])
  resp <- dfmerge[,taxa.names[i]] > 0

  # Fit a model that is only a constant
  modcmp <- glm(resp ~ 1, family = binomial, data = dfmerge)

  # Compare original model with constant model using
  # a chi-square statistic
  modout <- anova(modlist.glm, modcmp, test = "Chi")
  print(modout)

  # Select p < 0.05 as statistically significant
  if (modout[2,"P(>|Chi|)"] < 0.05) {
    print("Model significant compared to constant")
  }

  # Fit a model with only a linear explanatory variable
  modcmp <- glm(resp ~ temp, family = binomial, data = dfmerge)

  # Compare original model with constant model using a
  # chi-square statistic
  modout <- anova(modlist.glm, modcmp, test = "Chi")
  print(modout)
  if (modout[2,"P(>|Chi|)"] < 0.05) {
    print("Model with b2 significant (p < 0.05) improvement over linear model")
  }
}


The same approach can be applied to nonparametric models, comparing the nonparametric regression model to models expressed only as a constant and as a constant and a linear term.


# Conduct chi-square tests on nested non-parametric models
library(gam)
for (i in 1:length(taxa.names)) {

  print(taxa.names[i])
  resp <- dfmerge[,taxa.names[i]] > 0
  modcmp <- gam(resp ~ 1, family = binomial, data = dfmerge)
  modout <- anova(modlist.gam, modcmp, test = "Chi")
  print(modout)
  if (modout[2,"P(>|Chi|)"] < 0.05) {
    print("Model significant compared to constant")
  }
  
  # Fit a model with only a linear explanatory variable
  modcmp <- gam(resp ~ temp, family = binomial, data = dfmerge)
  modout <- anova(modlist.glm, modcmp, test = "Chi")
  print(modout)
  if (modout[2,"P(>|Chi|)"] < 0.05) {
    print("Nonparametric model with two degrees of freedom 
           significant over linear model.")
  }
}

Causal Analysis/Diagnosis Decision Information System (CADDIS)

  • CADDIS Home
    • About CADDIS
    • Frequent Questions
    • Publications
    • Recent Additions
    • Related Links
    • CADDIS Glossary
  • Volume 1: Stressor Identification
    • About Causal Assessment
    • Getting Started
    • Step 1. Define the Case
    • Step 2. List Candidate Causes
    • Step 3. Evaluate Data from the Case
    • Step 4. Evaluate Data from Elsewhere
    • Step 5. Identify Probable Causes
  • Volume 2: Sources, Stressors and Responses
    • About Sources
      • Urbanization
    • About Stressors
  • Volume 3: Examples and Applications
    • Analytical Examples
    • Worksheet Examples
    • State Examples
    • Case Studies
    • Galleries
  • Volume 4: Data Analysis
    • Selecting an Analysis Approach
    • Getting Started
    • Basic Principles & Issues
    • Exploratory Data Analysis
    • Basic Analyses
    • Advanced Analyses
    • PECBO Appendix
    • Download Software
    • Data Analysis Topics (A -Z)
  • Volume 5: Causal Databases
    • Learn about CADLink
Contact Us about CADDIS
Contact Us to ask a question, provide feedback, or report a problem.
Last updated on February 7, 2025
  • Assistance
  • Spanish
  • Arabic
  • Chinese (simplified)
  • Chinese (traditional)
  • French
  • Haitian Creole
  • Korean
  • Portuguese
  • Russian
  • Tagalog
  • Vietnamese
United States Environmental Protection Agency

Discover.

  • Accessibility Statement
  • Budget & Performance
  • Contracting
  • EPA www Web Snapshot
  • Grants
  • No FEAR Act Data
  • Plain Writing
  • Privacy
  • Privacy and Security Notice

Connect.

  • Data
  • Inspector General
  • Jobs
  • Newsroom
  • Regulations.gov
  • Subscribe
  • USA.gov
  • White House

Ask.

  • Contact EPA
  • EPA Disclaimers
  • Hotlines
  • FOIA Requests
  • Frequent Questions
  • Site Feedback

Follow.