Converting data in csv form into vector

mydata <- read.csv ("Finals.csv")

Year from 1790 to 1850 with year 1790 = 0

YearVect <- mydata$Years

YearVect
## [1]  0 10 20 30 40 50 60

Population in millions

PopVect <- mydata$Pop

PopVect
## [1]  3.929  5.308  7.240  9.638 12.866 17.069 23.192

Ploting US population growth from 1790 to 1850 graph, Nls equation, tryfit line, and intercept

\(Population= P_{0} \cdot e^{(k*t)}\)

Where:

Population is the population after time t

\(P_{0}\) is the inital population

e is Euler’s number

k is the rate of growth

t is the time in years

plot(YearVect, PopVect, xlab = 'Year from 1790 to 1850', ylab= 'US popluation growth in millions',
     main = "US population growth from 1790 to 1850")

tryfit <- nls(PopVect ~ 3.929 * exp (k*YearVect), start= c(k = 0.1))

summary(tryfit)
## 
## Formula: PopVect ~ 3.929 * exp(k * YearVect)
## 
## Parameters:
##    Estimate Std. Error t value Pr(>|t|)    
## k 2.956e-02  5.747e-05   514.4 3.64e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1002 on 6 degrees of freedom
## 
## Number of iterations to convergence: 8 
## Achieved convergence tolerance: 6.62e-07
lines(PopVect,predict (tryfit))

cf <- coef(tryfit)

Intercept <- cf[1]

Intercept
##          k 
## 0.02955991