How to perform nonlinear regression accross multiple datasets

15 ビュー (過去 30 日間)
Jack Nolan
Jack Nolan 2021 年 2 月 19 日
回答済み: Eleida 2025 年 7 月 1 日
Appolgies in advance as I am new to MATLAB.
I am trying to fit a model to mutiple data sets at once using non linear regression. I have found similiar examples but I am unable to modify them to suit my needs.
The model contains 3 unkown paramaters that must be tuned to satsifty (or give best model fit) accross 4 data sets at once.However, the model also contains 1 known paramater which is different for each of the 4 datasets.
Model to fit:
  • ΔRon/Ron are the data set y values
  • t is the data set x values
  • A1, A2, γ are unkown paramaters (common to all data sets) which must be found
  • tau is a kown paramaer whcih differs accross all data sets
I have attached an m-file with relevant data and information. If sombody could provide guidance or a commented solution I would be very grateful. Thanks.
  8 件のコメント
Jack Nolan
Jack Nolan 2021 年 2 月 20 日
@Alex Sha, can you recommend a free/more afordable software package please.
Alex Sha
Alex Sha 2021 年 2 月 21 日
Matlab should be OK, but need you to do more work.

サインインしてコメントする。

採用された回答

Deepak Meena
Deepak Meena 2021 年 2 月 24 日
Hi Jack,
The following post on MATLAB Answers discusses a similar case:
In that question , there were 2 unknown shared parameters and 1 parameter was different for all the dataset but was also unknown. In this question we have 3 unknown shared parameters and 1 known parameters whose value will be different for each dataset.So I modified that to illustrate that :
function sharedparams
t = (0:10)';
T = [t; t; t;t];
Y = 3 + [exp(-t/2); 2*exp(-t/2); 3*exp(-t/2);4*exp(-t/2)] + randn(44,1)/10;
dsid = [ones(11,1); 2*ones(11,1); 3*ones(11,1);4*ones(11,1)];
gscatter(T,Y,dsid)
X = [T dsid];
A3 = [-5;1;3;4];
b = nlinfit(X,Y,@subfun,ones(1,3))
line(t,b(1)+b(2)+b(3)*t+A3(1),'color','r');
line(t,b(1)+b(2)+b(3)*t+A3(2),'color','g');
line(t,b(1)+b(2)+b(3)*t+A3(3),'color','b');
line(t,b(1)+b(2)+b(3)*t+A3(4),'color','c');
function yfit = subfun(param,X)
T = X(:,1); % time
dsid = X(:,2); % dataset id
A0 = param(1);
A1 = param(2);
A2 = param(3);
A3 = [-5;1;3;4]; %known paramter
yfit = A0 + A1+ A2*T + A3(dsid);
  7 件のコメント
Tom Lane
Tom Lane 2021 年 2 月 25 日
You have:
yfit = A1 * log(1 + T/tau(dsid)) + A2 * log(1 + (T/tau(dsid))*(1/gamma));
You should have:
yfit = A1 * log(1 + T./tau(dsid)) + A2 * log(1 + (T./tau(dsid))*(1/gamma));
You want element-by-element division, not vector division in the sense of a matrix operation.
Jack Nolan
Jack Nolan 2021 年 2 月 25 日
Thanks alot @Tom Lane, it's working now

サインインしてコメントする。

その他の回答 (1 件)

Eleida
Eleida 2025 年 7 月 1 日
  1. (20%) Nonlinear Regression.
The data presented below follows the nonlinear functional relationship 𝑦 = 𝑥/(𝑎 + 𝑏𝑥), where 𝑎 and 𝑏 are the nonlinear model parameters.
Use MATLAB to complete the following:
Problem2.1. (5%) Linearize the dataset and perform linearregression on the linearized dataset.Display the slope and intercept/offset of the linear regression model, as well as its coefficient of determination.
Problem 2.2. (5%) Provide a plot that overlays the linearized dataset (i.e., linearized 𝑦 data vs linearized 𝑥 data) and the linear regression model obtained in problem 2.1. Display the linear regression model and its coefficient of determination in a legend. Include appropriate axes labels and axes grid lines.
Problem 2.3. (5%) Determine the values of the nonlinear model parameters 𝑎 and 𝑏 using the slope and intercept/offset of the linear regression model obtained in problem 2.1. Display the values of 𝑎 and 𝑏.
Problem 2.4. (5%) Provide a plot that overlays the original dataset and the nonlinear regression model obtained in problem 2.3. Display the nonlinear regression model and its coefficient of determination in a legend. Include appropriate axes labels and axes grid lines.

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by