Chem 243

Programming Project


XY Data Set

The data set below represent the US population growth from 1790 to 1850.
* The year begins on 1790 so 1790 = 0.
* The population is given in millions

# YEAR 

year <- c(0,10,20,30,40,50,60)


# POPULATION

pop <- c(3.929, 5.308, 7.240, 9.638, 12.866, 17.069, 23.192)

Data Plot

plot(year,pop,
     xlab = "Year since 1790", ylab = "Population (millions)", main = "US Population Growth")


NLS2 Analysis

Since this data is based on population growth, we use the exponential function for the nls2 analysis.

\[ pop = popi * exp (k*year) \] where:

  • pop = population at (year)

  • popi = initial population (year = 0)

  • k = growth constant

library(nls2)
## Loading required package: proto
tryfit <- nls2(pop ~ popi*exp(k * year), 
                start = list(popi = 3.929, k = 0.05))

summary(tryfit)
## 
## 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: 5 
## Achieved convergence tolerance: 7.969e-08

From the nls2 analysis we can determine that k = 0.0293421


Fit Curve

The tryfit line based on the exponential function is plotted on the graph below.

plot(year, pop,
     xlab= "Year since 1790", ylab= "Population (millions)", main= "US Population Growth")
lines(year,predict(tryfit), col="pink")


Conclusion

The exponential tryfit line matches up very closely with the data set. Based on this, we can determine that our k value from the nls2 analysis is accurate. The estimated value for the initial poplation was 3.97, compared to our actual initial value, 3.93.

The growth constant (k) is 0.0293421 from the years 1790 to 1850 in the US.