how can i calculate R-squared for lsqnonlin function ?

4 次查看(过去 30 天)
i want to calculate R-squared of non linear regression of exponential function. but i don;t know what is its code??
the code that i have written:
clear;
clc;
close all;
%mix code: S100+NaOH 11.25 molar _conc_T8
%tdata = [0.5694 1.0000 2.0000 3.7326 8.0000 16.0000 32.0000 64.0000 ];
%sdata = [1.4367 1.1567 1.3750 2.9900 3.2000 33.0050 0.0000 46.3050 ];
tdata = ...
[0.5694 1.0000 2.0000 3.7326 16.0000 64.0000 ];
sdata = ...
[1.4367 1.1567 1.3750 2.9900 33.0050 46.3050 ];
beta= [1.003908069]
fun = @(x)x(1)*exp(-(x(2)./tdata).^beta)-sdata;
x0=[40,0.9];
options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective');
[x,resnorm, residual] = lsqnonlin(fun,x0)
plot(tdata,sdata,'ko')
hold on
syms tlist
y = x(1)*exp(-(x(2)./tlist).^beta);
tlist = linspace(tdata(1),tdata(end));
y = subs(y);
plot(tlist,y,'b-')
xlabel time(day)
ylabel strength(MPa)
title('exponential Fit to Data')
legend('Data','exponential Fit S100 11.25 M conc T8')
hold off
  1 个评论
Abdolkarim Mohammadi
https://blog.minitab.com/blog/adventures-in-statistics-2/why-is-there-no-r-squared-for-nonlinear-regression

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by