This Exponential Regression Calculator helps you analyze data that follows exponential growth or decay patterns. It fits data to the model, providing comprehensive analysis including model coefficients, goodness-of-fit statistics, and diagnostic plots. This is particularly useful for modeling population growth, compound interest, radioactive decay, and other phenomena showing exponential behavior. To learn about the data format required and test this calculator, .
Exponential Regression models the relationship between a predictor variable (X) and a response variable (Y) where the dependent variable changes at a rate proportional to its current value. The model has the form , where and are constants determined by the regression.
Exponential Model:
Log-Transformation:
Coefficient a (initial value):
Coefficient b (growth/decay rate):
Doubling/Half-life Time:
| Year (X) | Population (Y) | ln(Y) |
|---|---|---|
| 1 | 125 | 4.83 |
| 2 | 150 | 5.01 |
| 3 | 179 | 5.19 |
| ⋮ | ⋮ | ⋮ |
| 10 | 580 | 6.36 |
Transform the dependent variable by taking the natural logarithm of each Y value. Then fit a linear regression to X vs. ln(Y).
After linear regression on the transformed data, we get:
Calculate a = e^(intercept) = e^4.78 ≈ 119.18
The growth rate b = 0.17
This population grows by approximately 17% per year (b = 0.17).
The doubling time is ln(2)/0.17 ≈ 4.08 years.
library(tidyverse)
data <- tibble(
Years = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
Population = c(125, 150, 179, 213, 252, 301, 350, 418, 489, 580)
)
model <- lm(log(Population) ~ Years, data = data)
summary(model)
a <- exp(coef(model)[1]) # Intercept
b <- coef(model)[2] # Growth rate
str_glue("Exponential function: y = {round(a, 2)} * e^({round(b, 2)} * x)")
str_glue("Doubling time = {round(log(2)/b, 2)} years")
fitted_exp <- exp(predict(model))
SSE <- sum((data$Population - fitted_exp)^2)
SST <- sum((data$Population - mean(data$Population))^2)
R_squared_exp <- 1 - SSE/SST
print(str_glue("R-squared (exponential scale): {round(R_squared_exp, 4)}"))
data$Fitted <- exp(predict(model))
ggplot(data, aes(x = Years)) +
geom_point(aes(y = Population), color="blue", size = 3) +
geom_line(aes(y = Fitted), color = "red", linewidth = 1) +
labs(title = "Exponential Growth Model",
subtitle = paste0("y = ", round(a, 2), " * e^(", round(b, 3), "x)"),
x = "Years",
y = "Population") +
theme_minimal()import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import statsmodels.api as sm
# Sample data
years = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
population = np.array([125, 150, 179, 213, 252, 301, 350, 418, 489, 580])
# Method 1: Linear regression on log-transformed data
X = sm.add_constant(years)
model = sm.OLS(np.log(population), X).fit()
print(model.summary())
# Extract coefficients
a = np.exp(model.params[0]) # Intercept
b = model.params[1] # Growth rate
print(f"Exponential function: y = {a:.2f} * e^({b:.2f} * x)")
# Calculate fitted values
fitted_values = np.exp(model.predict())
# Method 2: Direct curve fitting
def exp_func(x, a, b):
return a * np.exp(b * x)
# Fit curve
params, covariance = curve_fit(exp_func, years, population)
a_direct, b_direct = params
print(f"Direct curve fitting: y = {a_direct:.2f} * e^({b_direct:.2f} * x)")
# Plot results
plt.figure(figsize=(10, 6))
plt.scatter(years, population, label='Observed data')
plt.plot(years, fitted_values, 'r-', label=f'Fitted: {a:.2f} * e^({b:.2f} * x)')
plt.plot(years, exp_func(years, a_direct, b_direct), 'g--',
label=f'Direct fit: {a_direct:.2f} * e^({b_direct:.2f} * x)')
plt.xlabel('Years')
plt.ylabel('Population')
plt.title('Exponential Regression')
plt.legend()
plt.grid(True)
plt.show()This Exponential Regression Calculator helps you analyze data that follows exponential growth or decay patterns. It fits data to the model, providing comprehensive analysis including model coefficients, goodness-of-fit statistics, and diagnostic plots. This is particularly useful for modeling population growth, compound interest, radioactive decay, and other phenomena showing exponential behavior. To learn about the data format required and test this calculator, .
Exponential Regression models the relationship between a predictor variable (X) and a response variable (Y) where the dependent variable changes at a rate proportional to its current value. The model has the form , where and are constants determined by the regression.
Exponential Model:
Log-Transformation:
Coefficient a (initial value):
Coefficient b (growth/decay rate):
Doubling/Half-life Time:
| Year (X) | Population (Y) | ln(Y) |
|---|---|---|
| 1 | 125 | 4.83 |
| 2 | 150 | 5.01 |
| 3 | 179 | 5.19 |
| ⋮ | ⋮ | ⋮ |
| 10 | 580 | 6.36 |
Transform the dependent variable by taking the natural logarithm of each Y value. Then fit a linear regression to X vs. ln(Y).
After linear regression on the transformed data, we get:
Calculate a = e^(intercept) = e^4.78 ≈ 119.18
The growth rate b = 0.17
This population grows by approximately 17% per year (b = 0.17).
The doubling time is ln(2)/0.17 ≈ 4.08 years.
library(tidyverse)
data <- tibble(
Years = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
Population = c(125, 150, 179, 213, 252, 301, 350, 418, 489, 580)
)
model <- lm(log(Population) ~ Years, data = data)
summary(model)
a <- exp(coef(model)[1]) # Intercept
b <- coef(model)[2] # Growth rate
str_glue("Exponential function: y = {round(a, 2)} * e^({round(b, 2)} * x)")
str_glue("Doubling time = {round(log(2)/b, 2)} years")
fitted_exp <- exp(predict(model))
SSE <- sum((data$Population - fitted_exp)^2)
SST <- sum((data$Population - mean(data$Population))^2)
R_squared_exp <- 1 - SSE/SST
print(str_glue("R-squared (exponential scale): {round(R_squared_exp, 4)}"))
data$Fitted <- exp(predict(model))
ggplot(data, aes(x = Years)) +
geom_point(aes(y = Population), color="blue", size = 3) +
geom_line(aes(y = Fitted), color = "red", linewidth = 1) +
labs(title = "Exponential Growth Model",
subtitle = paste0("y = ", round(a, 2), " * e^(", round(b, 3), "x)"),
x = "Years",
y = "Population") +
theme_minimal()import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import statsmodels.api as sm
# Sample data
years = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
population = np.array([125, 150, 179, 213, 252, 301, 350, 418, 489, 580])
# Method 1: Linear regression on log-transformed data
X = sm.add_constant(years)
model = sm.OLS(np.log(population), X).fit()
print(model.summary())
# Extract coefficients
a = np.exp(model.params[0]) # Intercept
b = model.params[1] # Growth rate
print(f"Exponential function: y = {a:.2f} * e^({b:.2f} * x)")
# Calculate fitted values
fitted_values = np.exp(model.predict())
# Method 2: Direct curve fitting
def exp_func(x, a, b):
return a * np.exp(b * x)
# Fit curve
params, covariance = curve_fit(exp_func, years, population)
a_direct, b_direct = params
print(f"Direct curve fitting: y = {a_direct:.2f} * e^({b_direct:.2f} * x)")
# Plot results
plt.figure(figsize=(10, 6))
plt.scatter(years, population, label='Observed data')
plt.plot(years, fitted_values, 'r-', label=f'Fitted: {a:.2f} * e^({b:.2f} * x)')
plt.plot(years, exp_func(years, a_direct, b_direct), 'g--',
label=f'Direct fit: {a_direct:.2f} * e^({b_direct:.2f} * x)')
plt.xlabel('Years')
plt.ylabel('Population')
plt.title('Exponential Regression')
plt.legend()
plt.grid(True)
plt.show()