Page 411 - Numerical Methods for Chemical Engineering
P. 411

400     8 Bayesian statistics and parameter estimation



                   Linear least-squares calculations in MATLAB

                   For linear models, we use the function regress,
                   [theta, theta CI, residuals, res CI, Stats] = regress(y, X, alpha);
                                    N
                   y is the vector y ∈  of measured responses. X is the N × P design matrix of predictor
                   variables. alpha sets the width of the confidence intervals (α = 0.05 for 95% CIs). theta
                                    P
                   is the vector θ M ∈  of fitted parameters. theta CI contains lower and upper bounds on
                   each parameter. residuals contains the values in each experiment of the residual errors
                              [k]
                   e [k]  = y [k]  − ˆ y (θ M ) and res CI contains lower and upper bounds on these errors. Stats
                   contains various goodness-of-fit measures.
                     We demonstrate the use of regress for the data set comparing the protein expression levels
                   of wild-type and mutant bacterial strains, (8.35). The following MATLAB code performs the
                   least-squares calculation:

                   y = [121.9; 113.4; 112.2; 106.1; 120.7; 119.5; 116.5; 124.0];
                   X=[10;10;10;10;11;11;11;11];
                   alpha = 0.05;
                   [theta, theta CI, residuals, res CI, Stats] = regress(y, X, alpha);
                   The results of these calculations are

                   theta =
                     113.4000
                     6.7750
                   theta CI =
                     107.1646 119.6354
                     −2.0432 15.5932
                   Thus, we have the 95% confidence intervals,

                                       θ 1 = 113.40 ± 6.33  θ 2 = 6.78 ± 8.82        (8.145)


                   As the confidence interval for θ 2 includes θ 2 = 0, the difference in protein expression levels
                   between the two strains is not statistically significant.


                   Nonlinear least-squares calculations in MATLAB
                   For nonlinear models, the MATLAB statistics toolkit contains functions to compute the
                   least-squares estimates and generate confidence intervals using the approximate posterior
                   density. First, the least-squares estimate is found using the function nlinfit,
                   [theta, residuals, Jac] = nlinfit(X pred, y, fun, theta 0);
                   X pred is a matrix that contains in each row the set of predictors for the correspond-
                   ing experiment. y is the vector of measured response values. fun name is the name of a
                   function,
   406   407   408   409   410   411   412   413   414   415   416