A non-linear least squares fit was used to determine the US population growth constant (k) from 1790 to 1850. First, a plot of years versus population (in millions) was created to visualize the growth trend. For ease of readability and data processing, the years on the x-axis are represented as the number of years since 1790.
#Defining Variables
year <- c(0, 10, 20, 30, 40, 50, 60) #x
pop <- c(3.929, 5.308, 7.240, 9.638, 12.866, 17.069, 23.192) #y
#Plotting x vs. y
plot(year,pop,
xlab='Years (Starting from 1790)',
ylab='Population in Millions',
main='US Population Growth (1790-1850)')
To model this growth trend, an exponential growth model was applied:
\[
\text{Population} = \text{popi} \cdot e^{k \cdot \text{year}}
\] popi is the initial US population at year 0
(1790)
k is the growth rate constant
year is the number of years since 1790
A non-linear least squares fit line was added to the exponential
model to estimate the growth constant k.
#nls2 fitting
plot(year,pop,
xlab='Years (Starting from 1790)',
ylab='Population in Millions',
main='US Population Growth (1790-1850)')
library(nls2)
## Loading required package: proto
populationmodel <- nls(pop ~ popi*exp(k * year),
start = c(popi = 3.929, k = 0.01))
summary(populationmodel)
##
## Formula: pop ~ popi * exp(k * year)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## popi 3.9744064 0.0407277 97.58 2.14e-09 ***
## k 0.0293421 0.0002023 145.02 2.96e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.09817 on 5 degrees of freedom
##
## Number of iterations to convergence: 4
## Achieved convergence tolerance: 4.981e-08
lines(year,predict(populationmodel),col= 'red')
The nls2 model provides a strong fit to the exponential population model, with minimal noise or outlier data points detected. According to the non-linear least squares summary, the growth rate (k constant) of the US population from 1790 to 1850 is estimated to be 0.0293421.