A problem from Stewart Calculus: Concepts and Contexts 2/e p. 38. It appears in Chapter 1.
mosaicrequire(mosaic)
pop = fetchData("PREP-Stewart-World-Population.csv")
## Retrieving data from
## http://www.mosaic-web.org/go/datasets/PREP-Stewart-World-Population.csv
head(pop)
## Year Population
## 1 1900 1650
## 2 1910 1750
## 3 1920 1860
## 4 1930 2070
## 5 1940 2300
## 6 1950 2560
What skills are needed to do this? Careful spelling, attention to punctuation, use of quotes, understanding the structure of a file name, understanding the syntax for use of R functions, understanding assignment.
plotPoints(Population ~ Year, data = pop)
What do you need to know to answer the questions posed earlier?
Some techniques:
quadf = fitModel(Population ~ a * Year^2 + b * Year + c, data = pop)
quadf(1925)
## [1] 1878
quadfResids = with(pop, Population - quadf(Year))
You figure it out!
splinef = spliner(Population ~ Year, data = pop)
splinef(1925)
## [1] 1956
splinefResids = with(pop, Population - splinef(Year))
You can also try a monotonic spline. Use help(spliner) to find out how.
This is hard, for reasons that relate to the data and numerics. Here, a guess is being made for a doubling time of 30 years.
expf = fitModel(Population ~ A + B * 2^((Year - 1900)/30), data = pop)
According to this model, what's the population in 1925?
a*Year^3 for the cubic?