Getting Started

Software Requirements

This program requires RStudio, which is completely free to download and use:

  1. Download R from: https://cran.r-project.org/
  2. Download RStudio from: https://posit.co/download/rstudio-desktop/
  3. Install both programs on your computer (R first, then RStudio)

Note: You must use RStudio to run this program. Regular R or other environments may not work properly.

What This Program Does

This R program analyzes population data using a two-stage logistic growth model:

  1. Stage 1: Fits growth parameters (r and K) to your observed data
  2. Stage 2: Projects future population with different death rate scenarios

The program automatically generates plots and exports data tables for analysis.


Setting Up Your Data

Data Import Options

The program offers two ways to import your population data. Choose ONE option:

Option B: Place File in Same Folder

  1. Save your CSV file in the same folder as this R script
  2. Find this line:
# data <- read.csv("whooping_crane_population_for_R.csv")
  1. Remove the # and change the filename to match yours:
data <- read.csv("YOUR_FILENAME.csv")

Required Data Format

Your CSV file must have exactly two columns: - Column 1: Year (e.g., 2000, 2001, 2002…) - Column 2: Population (e.g., 100, 120, 145…)

Example CSV file:

Year,Population
2000,100
2001,120
2002,145
2003,160

Changing Model Settings

Key Input Parameters

Find the User Inputs section (around line 15) to modify these values:

inputs <- list(
  P0 = 18,         # Starting population - CHANGE THIS to match your data
  r_guess = 0.5,   # Leave as default
  K_guess = 4000,  # Leave as default  
  r_min = 0,       # Leave as default
  r_max = 1,       # Leave as default
  K_min = 600,     # Adjust if needed - minimum carrying capacity
  K_max = 5000,    # Adjust if needed - maximum carrying capacity
  extend_years = 25,  # CHANGE THIS - how many years to project forward
  death_rate = 0   # CHANGE THIS - experiment with different values
)

What to Change

Required Changes:

  • P0: Set to the first year’s population in your data
  • death_rate: This is your main experimental variable

Optional Changes:

  • extend_years: How many years to project into the future
  • K_min/K_max: Adjust based on your species’ realistic population limits

Leave as Default:

  • r_guess, r_min, r_max (growth rate parameters)

Running the Program

Step-by-Step Process

  1. Download and save the code (see “Getting the Code” section above)
  2. Open the R script file in RStudio
  3. Set up your data using one of the two import options below
  4. Modify the input parameters as needed
  5. Run the entire script in RStudio:
    • Select all code (Ctrl+A or Cmd+A)
    • Run all (Ctrl+Enter, Cmd+Enter, or click “Run All”)
  6. Check the console output for results
  7. View the generated plot in the Plots panel
  8. Find your exported files in the same folder as your R script

Experimenting with Death Rates

To test different scenarios:

  1. Start with death_rate = 0 (baseline scenario)
  2. Change death_rate to 5, 10, 20, etc.
  3. Re-run the script each time
  4. Compare the results

Each run creates a separate output file, so you can compare scenarios.


Understanding Your Results

Console Output

When the program runs, you’ll see:

STAGE 1 - Parameter estimates (fitted to observed data):
r (growth rate) = 0.0850
K (carrying capacity) = 3250.0
These values are FIXED for all death scenarios.

STAGE 2 - Projection with death rate = 10
Model equation for projections: P(n+1) = P(n) + r*P(n)*(1 - P(n)/K) - d

Key Points: - r and K are automatically calculated from your data - These values stay the same for all death rate experiments - Only the death rate changes between scenarios

Plot Interpretation

The generated plot shows: - Blue points/line: Your original data - Red line: Model predictions - Dotted vertical line: Where projections begin - Left side: Historical data (no death applied) - Right side: Future projections (with death applied)


File Outputs

Where Files Are Saved

All output files save to the same folder as your R script.

The console will tell you exactly where:

Results saved as: logistic_model_death_10.csv
File location: /your/folder/path/logistic_model_death_10.csv
Working directory: /your/folder/path/

Generated Files

Each time you run the program, it creates:

CSV Data File

  • Filename: logistic_model_death_X.csv (where X = your death rate)
  • Contains: Year, observed data, model predictions, parameters
  • Purpose: For detailed analysis and comparison

Plot File

The plot appears in RStudio’s Plots panel (bottom-right area of RStudio). To save it:

  1. In the Plots panel, click Export
  2. Choose Save as Image or Save as PDF
  3. Select location and filename
  4. Click Save

Comparing Multiple Scenarios

Run the program multiple times with different death rates: - death_rate = 0 → creates logistic_model_death_0.csv - death_rate = 10 → creates logistic_model_death_10.csv - death_rate = 25 → creates logistic_model_death_25.csv

Each file contains the complete results for that scenario.


Troubleshooting

Common Problems

“File not found” error

Solution: Check that your CSV file is in the correct location and filename matches exactly

“Package not found” error

Solution: In RStudio console, run install.packages("tidyverse") and wait for it to finish, then re-run your script

Strange results

Solution: Check that your CSV has exactly two columns: Year, Population

Program won’t run

Solution: Make sure you’ve uncommented (removed #) from exactly ONE data import option

Getting Help

  1. Check console messages - they often explain the problem
  2. Verify your data format - must be Year, Population columns
  3. Ensure file paths are correct
  4. Ask for help if error messages are unclear

Quick Reference

Essential Steps

  1. Import data: Choose ONE option (A or B) and uncomment it
  2. Set P0: Match your first year’s population
  3. Set death_rate: Start with 0, then experiment
  4. Run script: Select all and execute
  5. Save plot: Use Export button in Plots panel
  6. Find CSV files: Same folder as your R script

Key Lines to Modify

  • Line ~18: Data import (uncomment ONE option)
  • Line ~15: P0 value (match your data)
  • Line ~21: death_rate (your experimental variable)
  • Line ~20: extend_years (projection length)

This guide covers the essential steps to use the population modeling program. Focus on data import, parameter settings, and understanding your outputs.