INSTRUCTOR: Here, I'm gonna provide a
brief introduction to nonlinear regression and
I'll talk about some of the assumptions,
and I'll talk about how we evaluate the results.
I'm using data from the Problem Solving
in Chemical Engineering with Numerical Methods book,
also using information from this reference.
So the data that's being used, vapor pressure data,
so temperature and then the vapor pressure
at that temperature.
And the ideas we wanna fit this to the Antoine's equation.
Two approaches, we could use linear regression
or we could use nonlinear regression.
The nonlinear linear regression assumes that the
scatter of the data follows a Gaussian distribution.
This turns out to be a reasonable assumption
in lots of cases.
And also assumes the standard deviation
is the same for all, we'll call this Y and X,
all Y values is the dependent variable.
So basically nonlinear regression,
soon as we know the X values accurately, then we set
that value and that we're measuring the Y value
so that's where the error is.
And so if we were to look at a plot of Y versus X,
let me pause, what we're trying to do is find an equation,
that's the curve I've drawn that fits these data points
which clearly have scatter.
This distance between the data point and the line,
all these distances, we're going to
add up the square of those distances
and so the Y experimental minus Y calculated,
that's what is referred to as a residual.
And then we're gonna sum the square of these residuals
and that's what we're trying to minimize.
Now, it's possible that as X gets bigger,
the error in Y, the scatter gets larger and so sometimes
instead of sum of the squares the residuals,
we're going to take the experimental value
minus the calculated value,
divided by the experimental value
and then sum that, and try and minimize that
and this accounts for the idea that the error gets bigger,
for example in this case, as the pressure gets bigger.
Now we should keep in mind, if we have
several measurements at the same value of X
for example, we have one here and we have one here.
General, we're not gonna take the average of those three
and then count that as one point,
unless they were measurements made on the same,
for example, samples so they were not
really independent measurements.
For example, if I ran an experiment, took a sample,
say with a gas chromatograph and got a number
and then I ran it again,
took another sample gas chromatograph, they're independent.
If I had a measurement and just measured
say the area under a curve
for gas chromatograph three times,
those are not independent experiments.
So what I've done is used software in this case POLYMATH,
to generate the parameters
and I'll just show you the results so,
first let me point out that we're fitting the data,
log pressure, A plus B, T plus C.
A, B and C are constants.
These are parameters we're trying to determine
using the nonlinear regression.
Well here's the result,
the fit of pressure versus temperature.
The data points are the circles and the line is the curve
and of course, we're not plotting logs so,
so we're plotting, in this case,
pressure is equal 10 raised to the power A plus B, T plus C.
What we did in the program was to guess the initial values
and this is important, we have to
have guesses that are reasonable
or we're not gonna converge.
And then these are the values
where A, B and C we converged on.
These are the 95% confidence limits
and that means there's a 95% chance that the
true value is in this range.
So now the question is, how we evaluate this fit?
Well, first, is it physically meaningful?
Well, in some case, that's easy to say for example,
if you get a rate constant that's negative,
we'd say it's not physically meaningful for A, B and C,
we probably can't say anymore.
Second is the fit so, does the curve fit the data?
If we look at it, would we say, yeah,
it's a pretty good fit.
Third is to look at these confidence intervals
and see if they're small,
relative to the value of the parameter, right?
I mean if the fit was bad,
they could be a significant fraction,
it could even be larger than parameter,
that would not be a good fit.
Well fourth is, is there a better model?
In other words, is this the right model
or completely different from of the equation?
The way to find out of course, is to try the other model
and look at confidence limits.
And then fifth and important one is,
if we look at a plot of the residuals
are they randomly distributed around the curve?
And I'll show you a little more about way we judge that.
So here are the residuals for this plot,
residual in this case, the experimental pressure
minus the calculate pressure
as a function of the pressure. Scatter looks random.
It looks like there's probably a bigger error
at the higher pressures and then
something that would not be random
might have the residuals that looks something like this,
where more of a pattern occurs and in a test that
is possible to get a better estimate is the runs test
and what that means is a run is how many points
in the series, consecutive points that are
above the line or below the line so,
for example, here's three points that below the line
so that would be one run out. Now,
here's one point above and then one below
now, three above, one below, two above, one below, so forth.
We can count those up and what we expect is the number
through approximation the number, in this case
number of data points, over two plus one.
That's how many runs approximately,
if the number runs is significantly smaller
we'd be worried in this case, 20 data points over two
plus one, we expect 11. Here we have 13.
That's a good indication that the distribution is random.
One final thing, we should look at the R squared value
or it's squared value. In this case is essentially one,
but the R squared value is probably not
a great way to compare, the confidence limits
are much better indication of the data fit.
And so what I do, I'll give you an example
to show what I mean. So here I've repeated the results
that I've been showing you for the nonlinear regression.
Here's a run where we use different values
as our starting guesses, initial estimates.
Well, we didn't converge very well
after 64 iterations, the simulation stopped
to run numbers only three saying
it's not really random.
And then noticed how large the confidence limits are
and how different the values are from the best fit.
Well here, we have a very large R squared, very close to one
but it doesn't look very random, run number only four.
And this is where again, we pick different estimates
and we to program, quit after 64 iterations
and this is not a good fit,
the 95% confidence interval is larger.
If we kept progressing we would expect we would,
we would get to these values.
So the program that we use POLYMATH to file
is on the LearnChemE site so you can
look at it and we'll explain in another
screen cast how to use that program.