{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ECOR 2606 - Lecture 16

# ECOR 2606 - Lecture 16 - Problem(text1329: Year Population...

This preview shows pages 1–3. Sign up to view the full content.

3/8/2010 1 Problem (text 13 29): The table below gives the population of a small but growing suburb over a twenty year period. Year 0 5 10 15 20 Population 100 200 450 950 2000 The growth is assumed to be exponential: population = α *exp( β t ), where t is a time in years What values of α and β best fit the data? What can the population be expected to be after 25 years? Ideally a nonlinear regression technique would be used to find the α and β that absolutely minimize the sum of the squares of the errors between the data points and the fitted curve. A good (but not perfect) answer can be obtained more simply by transforming the data and using linear regression. The basic procedure: y = α *exp( β x ) ln( y ) = ln( α ) + β x Let y ’ = ln( y ) Then y ’= ax + b , where a = β and b = ln( α ) Use linear regression to find best a and b . Then find α and β by applying α =exp( b ) and β = a Matlab part 1: x = [0 5 10 15 20]; y = [100 200 450 950 2000]; yt = log(y); % transform the y values p = polyfit (x, yt, 1); % fit a straight line to the transformed data fitt = @(x) p(1) * x + p(2); % function for the fitted line

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3/8/2010 2 Matlab part 2: figure (1) plot (x, yt, 'x', x, fitt(x), 'MarkerSize', 10); grid on; xlabel ('Years'); ylabel ('ln(Population)'); fprintf ('For transformed data a = %f, b = %f, r = %f\n', ... p(1) p(2) orrelate ( t fitt)) p(1), p(2), correlate (x, yt, fitt)); The first data point doesn’t appear. This seems to happen a lot (a Matlab bug?). The best fit line is y = 0.1510 * x + 4.5841 The correlation coefficient for this straight line and the transformed data is 0.999789. Matlab part 3: % calculate alpha and beta alpha = exp(p(2)); beta = p(1); fit = @(x) alpha * exp(beta * x); % function for fitted curve % need lots of x values to get a smooth plot of the fitted curve
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern