White-tailed deer (Odocoileus virginianus) have been extensively studied in North America, particularly in regions where their populations are managed through hunting, conservation efforts, and habitat management. Below is an example of a simplified dataset representing the population of White-tailed deer in a hypothetical region in North America over several decades.

# Year and Population Data
year <- c(1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020)
deer_population <- c(100, 150, 220, 350, 500, 600, 700, 750)

# Time (in years since 1950)
time <- year - 1950

# Logistic Model Function
logistic_model <- function(t, K, r, P0) {
  K / (1 + ((K - P0) / P0) * exp(-r * t))
}

# Exponential Growth Model Function
exponential_model <- function(t, r, P0) {
  P0 * exp(r * t)
}

# Initial Parameter Guesses
K_start <- 800  # Initial guess for the carrying capacity (in thousands)
r_start <- 0.1
P0_start <- deer_population[1]

# Fitting the Logistic Model
fit <- nls(deer_population ~ logistic_model(time, K, r, P0_start),
           start = list(K = K_start, r = r_start))

# Summary of the Fitted Model
summary(fit)
## 
## Formula: deer_population ~ logistic_model(time, K, r, P0_start)
## 
## Parameters:
##    Estimate Std. Error t value Pr(>|t|)    
## K 8.758e+02  3.202e+01   27.35 1.58e-07 ***
## r 5.624e-02  1.885e-03   29.83 9.42e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 16.21 on 6 degrees of freedom
## 
## Number of iterations to convergence: 5 
## Achieved convergence tolerance: 3.239e-06
# Extracting Parameters
K_est <- coef(fit)["K"]
r_est <- coef(fit)["r"]

K_est
##        K 
## 875.8154
r_est
##          r 
## 0.05623794
# Plotting the Data
plot(time, deer_population, main="Logistic vs Exponential Growth Model for White-tailed Deer", 
     xlab="Time (Years since 1950)", ylab="Deer Population (Thousands)", pch=19)

# Adding Logistic Growth Line
curve(logistic_model(x, K_est, r_est, P0_start), add=TRUE, col="blue", lwd=2)

# Adding Exponential Growth Line (using the same r_est for comparison)
curve(exponential_model(x, r_est, P0_start), add=TRUE, col="red", lwd=2, lty=2)

t_double <- log(2) / r_est

# Adding a legend
legend("bottomright", legend=c("Logistic Growth", "Exponential Growth"),
       col=c("blue", "red"), lwd=2, lty=c(1, 2))