MATLAB Answers

Error using betainc Z must be real and non-negative/polyfitn

19 views (last 30 days)
stamos dontas
stamos dontas on 7 Jan 2021
Edited: John D'Errico on 7 Jan 2021
Hello, i need to calculate the polynomial through regression that fits better to my output with 3 inputs. I downloaded polyfitn and i am just trying to understand how it works however i get this error. suppose i have:
aaa=[1; 2; 3; 4];
bbb=[5; 6; 7; 8];
ccc=[4; 5; 6; 7];
ddd=[ 15; 25; 67; 89];
ss=polyfitn([aaa,bbb,ccc],ddd,3)
Error using betainc
Z must be real and non-negative.
Error in polyfitn (line 266)
polymodel.p = betainc(polymodel.DoF./(t.^2 + polymodel.DoF),polymodel.DoF/2,1/2);
Error in Untitled2 (line 6)
ss=polyfitn([aaa,bbb],ddd,3)
Any help?
Thank in advance

  0 Comments

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 7 Jan 2021
Edited: John D'Errico on 7 Jan 2021
You have 4 data points.
You are trying to estimate a model with how many unknown coefficients? (20. Yes. 20.)
I won't even get into the question of whether your data justifies the model you are trying to fit.
You need more data points than you have terms in the model, to have even a remote chance of solving for coefficients. That does not mean you will be able to do so, for a compliated model.
But let me check...
>> 20 > 4
ans =
logical
1
The call to betainc is probably used to determine if the parameters estimated are significantly different from zero. (Hey, it has been a zillion years since I wrote the code, and I don't have any reason to read it right now.)

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by