Documents

Nonlinear Regression EBS127

Description
sadf
Categories
Published
of 11
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
    MATLAB Nonlinear regression A36 Introduction to Nonlinear regression using MATLAB By Professor Tom Rumsey Linear regression models are linear in their parameter values while not necessarily in their independent variables. Nonlinear regression models are nonlinear in their parameters (Himmelblau, 1970). A typical linear model is  p p3322110  x...xxx  ! + ! + ! + ! + ! =  where !  is the dependent variable xi = independent variable i = model parameter Other examples of linear and nonlinear models are given below (Himmelblau, 1970): a.) Linear in , nonlinear in x: 1421322110  xlnxxxx  ! + ! + ! + ! + ! =  b.) Linear in x, nonlinear in : 32211210  xxx  ! + ! + !! + ! =  c.) Nonlinear in  and x: 2211  xexpxexp    ! + ! =   22110  xx  ! + ! + ! =      MATLAB Nonlinear regression A37 The following notes contain examples of using the Matlab function nlinfit  to determine parameters to nonlinear regression models. Matlab can also handle linear regression problems easily; they are covered in the built in help for Release 12. 1. Example one: using Matlab function nlinfit Consider the equation x baxy +=  We assume we have experimental data for y versus x and want to determine the parameters a,b that fit the curve to the data. To gain confidence in the program, the first example will consider data generated with a=2, b=5. x 1 2 3 4 5 6 7 8 9 10 y 0.333 0.571 0.750 0.888 1.000 1.090 1.166 1.230 1.285 1.333 Data were generated in the Matlab script nlinfit_example_one.m. The command window input and output are shown followed by the plot of the data and the curve fit. Command window output: >> nlinfit_example_one a_mod = 2.0000 b_mod = 5.0000 betaci = 2.0000 2.0000 5.0000 5.0000 >>    MATLAB Nonlinear regression A38 Matlab script: nlinfit_example_one.m % Example problem using Matlab function nlinfit % Generate a synthetic data using the equation y=ax/(b+x) % The parameters a and b are to be determined using nlinfit % from the data of y versus x. % x values to be used in equation x=[1:1:10]; % Set values for a, b to be used in the equation a=2; b=5; % Generate the array of experimental data y=a*x./(b+x); % set initial guesses for a, b beta=[1 1]; % Use matlab function nlinfit to estimate the parameters [betahat,f,J]=nlinfit(x,y,'nlin_exam_one_eqn',beta); % Print out the results found by nlinfit a_mod=betahat(1) b_mod=betahat(2) % Use Matlab function called nlparci to get confidence intervals % on parameter estimates betaci=nlparci(betahat,f,J) % Plot predicted and experimental results x_mod=linspace(1,10); y_mod=a_mod*x_mod./(b_mod+x_mod);    MATLAB Nonlinear regression A39 plot(x,y,'ko',x_mod,y_mod,'k-') xlabel('x') ylabel('y') grid legend('expt','model') title('Curve Fit for Nlinfit Example 1') param=['a mod = ',num2str(a_mod),', b mod= ',num2str(b_mod)]; text(2,1.4,param) Matlab function: nlin_exam_one_eqn.m function yhat=nlin_exam_one_eqn(beta,z) % Example for this function follows page 1-81 in % Matlab Statistics Toolbox Manual a=beta(1); b=beta(2); x=z(:,1); yhat=a*x./(b+x);
Search
Tags
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks