8.2. The Method of Least Squares 333
Table 8.3. Population Size in Year t
t 0123 4 5
P 173 278 534 895 1553 2713
8.2.2. Find the least-squares, best-fit line to the data points (3, 120), (4, 116),
(5, 114), (6, 109), and (7, 106) by:
a. following the four steps given in the text, using a computer. The
MATLAB command A' gives the transpose of a matrix A.
b. following the first two steps and then using the MATLAB com-
mand A\b to find the least-squares solution
ˆ
x to Ax = b.
c. Using the MATLAB command polyfit. For instructions, type
help polyfit.
8.2.3. Recall from the last section that the data of Table 8.1 showed an
exponential decay that we hoped to model by an exponential formula.
Table 8.2 contains transformed data that is roughly linear.
a. Find the least-squares, best-fit line ln y =
ˆ
mt +
ˆ
b to the data in
Table 8.2.
b. Use your answer to part (a) to give an exponential curve y = ae
kt
fitting the data in Table 8.1.
Note: This approach to fitting an exponential curve, using a least-
squares, best-fit line to the transformed data, does not necessarily
give the exponential that minimizes SSE for the untransformed data.
It is, however, a standard approach to exponential curve fitting.
8.2.4. Suppose the population data in Table 8.3 is believed to be described
by the model P
t+1
= λP
t
.
a. Produce a semilog plot and explain why it justifies the choice of
the model.
b. Find the least-squares, best-fit line to the transformed data.
c. Use part (b) to find an exponential curve fitting the data.
d. Use part (c) to give a good estimate of λ for this data.
8.2.5. To produce and plot simulated data points that will be nearly on the
line y = .7x + 2.1, use the MATLAB commands
x=[1:10]', y=.7*x+2.1+.3*randn(10,1),
plot(x,y,'o').
Then A=[x,x.∧0], b=y will prepare you to perform the least-
squares, line-fitting calculation.