Im using nlinfit function and I need to know the R square for the fitted solution
13 views (last 30 days)
Show older comments
Im using nlinfit function and I need to know the R square for the fitted solution
0 Comments
Answers (1)
the cyclist
on 15 Dec 2022
rng default
N = 100;
x = randn(N,1);
y = 2 + 3*x + 5*randn(N,1);
modelfun = @(F,x) F(1) + F(2)*x;
beta0 = [0 0];
[beta,R] = nlinfit(x,y,modelfun,beta0);
Rsquared = 1 - sum(R.^2)/sum(((y-mean(y)).^2))
mdl = fitnlm(x,y,modelfun,beta0)
mdl.Rsquared
0 Comments
See Also
Categories
Find more on Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!