Hi everyone,
I have a question.
Turns out that when a create a linear model (using fitlm) and than I want to run an anova to that model I get this error:
Error using gather
Too many input arguments.
Error in classreg.regr.CompactLinearModel/componentanova (line 824)
[ss,df,ms,f,pval] = gather(ss,df,ms,f,pval);
Error in classreg.regr.CompactLinearModel/anova (line 319)
tbl = componentanova(model,sstype);
I had checked with colleagues and they don't have a "gather" function in line 824
Line 824: [ss,df,ms,f,pval] = gather(ss,df,ms,f,pval)
Does anyone knows what it could be?

4 comentarios

Adam Danz
Adam Danz el 8 de Dic. de 2021
Editada: Adam Danz el 8 de Dic. de 2021
These types of questions are easier to address if you provide a minimal working example that produces the error on your end. My shot-in-the-dark is that your shadowing a matlab function with a 3rd party function that contains the same name as the matlab function.
Note that Matlab does have a gather function (since R2016b) but it only contains 1 input. However, gather could be a shadowed method which is why it would be nice to quickly run a minimal working example.
Thank you so much for your answer!
Here is my code:
y = [10.3 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 24.2 21 21.4 21.3 19.1 22.2 33.8 27.4 25.7 24.9 34.5 31.7 36.3 38.3 42.6 55.4 55.7 58.3 51.5 51 77]
y = 1×31
10.3000 10.3000 10.2000 16.4000 18.8000 19.7000 15.6000 18.2000 22.6000 19.9000 24.2000 21.0000 21.4000 21.3000 19.1000 22.2000 33.8000 27.4000 25.7000 24.9000 34.5000 31.7000 36.3000 38.3000 42.6000 55.4000 55.7000 58.3000 51.5000 51.0000
x = [70 65 63 72 81 83 66 75 80 75 79 76 76 69 75 74 85 86 71 64 78 80 74 72 77 81 82 80 80 80 87]
x = 1×31
70 65 63 72 81 83 66 75 80 75 79 76 76 69 75 74 85 86 71 64 78 80 74 72 77 81 82 80 80 80
mdl = fitlm(x,y) % this runs without problem
mdl =
Linear regression model: y ~ 1 + x1 Estimated Coefficients: Estimate SE tStat pValue ________ _______ _______ __________ (Intercept) -87.124 29.273 -2.9762 0.0058347 x1 1.5433 0.38387 4.0205 0.00037838 Number of observations: 31, Error degrees of freedom: 29 Root Mean Squared Error: 13.4 R-squared: 0.358, Adjusted R-Squared: 0.336 F-statistic vs. constant model: 16.2, p-value = 0.000378
p = anova(mdl) % here is the error. (I have try with all posible anova functions -anova1, anova2, anovan-).
p = 2×5 table
SumSq DF MeanSq F pValue ______ __ ______ ______ __________ x1 2901.2 1 2901.2 16.164 0.00037838 Error 5204.9 29 179.48
When I run the last line I got the error showed before.
I'm using R2021a
Adam Danz
Adam Danz el 15 de Dic. de 2021
I applied the run feature to your code so we can see the results.
Aitana Grasso
Aitana Grasso el 15 de Dic. de 2021
Hello Adam,
Thank you so much for your help.
Apparently de problem was in my MATLAB, so I had to uninstall and install again.
Now everything is running perfectly!

Iniciar sesión para comentar.

 Respuesta aceptada

Adam Danz
Adam Danz el 8 de Dic. de 2021
It looks like you've shadowed matlab's gather function with a function or script of the same name.
To see a list of functions named gather,
which gather -all
/MATLAB/toolbox/matlab/bigdata/gather.m /MATLAB/toolbox/matlab/bigdata/@tall/gather.m % Shadowed tall method /MATLAB/toolbox/nnet/deep/@dlarray/gather.m % Shadowed dlarray method /MATLAB/toolbox/parallel/gpu/@gpuArray/gather.m % Shadowed gpuArray method /MATLAB/toolbox/parallel/parallel/@distributed/gather.m % Shadowed distributed method /MATLAB/toolbox/parallel/parallel/@codistributed/gather.m % Shadowed codistributed method
Then remove your shadowed file from the Matlab path or rename the file.

Más respuestas (0)

Categorías

Preguntada:

el 8 de Dic. de 2021

Comentada:

el 15 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by