How to add boundary conditions using fitnlm function?

조회 수: 11 (최근 30일)
Camila Garcia Jange
Camila Garcia Jange 2020년 12월 8일
댓글: laurent jalabert 2022년 1월 24일
Hello,
I would like to run a nonlinear regression model for the function detailed below (in the code). However, I want to add boundary conditions for my parameters, which include:
b(1) > 0, b(2) > 0, and 0.45 < b(3) < 0.89
I would like to know how I can obtain the full statistical analysis (i.e. SSE, coefficients, t test, confidence intervals) while being able to add the boundary conditions to the model. Right now, I am able to run the model, but without the specified boundaries.
I am aware that if I use lsqcurvefit function, I will be able to include the boundaries that I want. However, my goal is not only to include the boundaries and minimize SSE. I want to evaluate whether it is important to include the parameter b(2) in the model or not. Thank you in advance for the help.
%% Data and Model for the Fit
% Defining experimental data (x,y)
x = [1 2 4 6 8 10 15 20 30 40 60 90 120 150 180]';
y = [0 0 0 0 0.206398349 0.063037496 0.085397317 0.56381149 0.946508428 1.462332301 1.731854145 1.700722394 1.829205366 2.092363261 2.265393877]';
%% Defining function
fitfcn = @(b,x) b(1).*x.^(b(3)) + b(2).*x.^(2*b(3));
start = [0.1,0.01,0.45];
nlm = fitnlm(x,y,fitfcn,start);
xx = linspace(0,180)';
line(xx,predict(nlm,xx),'linestyle','--','color','k');
hold on;
plot(x,y,'ko');
xlabel('Time (min)'); ylabel('Concentration (mg/mL/g');

답변 (1개)

Aditya Patil
Aditya Patil 2020년 12월 21일
This is an known request, and might be implemented in any future release.
As a workaround, you can use the predicted parameters/weights from lsqcurvefit to evaluate the function, and then use various hypothesis tests to evaluate the fit.

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by