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 to Estimate Environmental Limits

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

How to Estimate Environmental Limits

Helpful Links
Topics In R Scripts
  • Overview
  • Download R 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()
Other Pages And Websites
  • Environmental Limits, Equation 2

PECBO Appendix Site Map

We can use a for loop similar to that used for weighted averages to compute environmental limits (see Environmental Limits page, Equation 2) for different taxa.

In this method, you must select a value of the cumulative percentile that you wish to use for computing the environmental limit. In the script below, the cutoff value is selected to be 0.75.

First make sure that you have loaded the sample biological and environmental data and merged them into a single data frame called dfmerge (see Download Scripts and Sample Data in the Helpful Links box).

Also make sure that you have selected the taxa for which you wish to calculate environmental limits and saved them in the vector taxa.names (as described in the R Script for Central Tendencies  in the Helpful Links box).

# Define a storage vector for the cumulative percentile

CP <- rep(NA, times = length(taxa.names))

# Sort sites by the value of the environmental variable
dftemp <- dfmerge[order(dfmerge$temp), ]

# Select a cutoff percentile
cutoff <- 0.75

# Specify three plots per page
par(mfrow = c(1,3), pty = "s")
for (i in 1:length(taxa.names)) {
  # Compute cumulative sum of abundances
  csum <- cumsum(dftemp[, taxa.names[i]])/
          sum(dftemp[,taxa.names[i]])

  # Make plots like Figure 4
  plot(dftemp$temp, csum, type = "l", xlab = "Temperature",
       ylab = "Proportion of total", main = taxa.names[i])

  # Search for point at which cumulative sum is 0.75
  ic <- 1
  while (csum[ic] < 0.75) ic <- ic + 1

  # Save the temperature that corresponds to this percentile.
  CP[i] <- dftemp$temp[ic]

}
names(CP) <- taxa.names
print(CP)

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 13, 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.

Environmental Protection Agency logo
www.epa.gov Feedback Survey

Welcome! Please share your feedback on how we can make www.epa.gov work better for you.

A red asterisk (*) indicates a required field.

Success

Thank you. Your feedback has been received.

Error

alert message

Required Questions - page 1 of 2
question_55203_answer_01
*

400 characters allowed
Would you like to take two more minutes to answer more questions to help us improve our services?
Yes, keep going →
← Back
Optional questions - page 2 of 2
How would you describe yourself?
400 characters allowed
400 characters allowed
400 characters allowed
U.S. flag

An official form of the United States government. Provided by Touchpoints
OMB Approval #1090-0008 · Expiration Date 11/30/2027