We are given a data set that has the population data of the United States from 1790 to 1850 and is given in intervals of 10 years. So their are 6 data points in total.
The first thing that I did was plot out the data using the plot function.
After plotting out the data using the plot function, I used the exponential function of \(pop(T) = pop(init) \cdot e^{kT}\) ,where pop(init) is the inital population and the y intercept, k is the growth factor. The nonlinear fitting function uses the assigned function and an algorthim to properly find values for k, and pop(init).
## Loading required package: proto
##
## Formula: pop ~ pop_ini * exp(k * year)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## pop_ini 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: 9
## Achieved convergence tolerance: 5.027e-08
As you can see the function given, fits the data, extremely well. The two free variables pop_init and k where solved by the algorthim. We end up with a population function of \[pop = 3.9744064 \cdot e^{0.0293421T}\]
This fits our data and gives us a very low error overall. This could be used to potentially estimate the population of the US in 1824 or 1804. Therefore it was a good idea to use the nls2 function to accurately model the data.
Futhermore, this project shows how simple modeling techniques can be very powerful in exteremly diverse applications.