mkjep asked . 2022-07-16

"Input to EIG must not contain NaN or Inf" error in fitrm for 18 subjects and 6 levels

Hi,
 
I am getting the following Matlab error: "Input to EIG must not contain NaN or Inf." when I run the fitrm function.
 
I am trying to test the differences between the 6 levels.
 
I have 18 subjects and 6 levels.
 
My table with the formatted data looks like this:
 

EIG

The code:

subj = {'Subj1','Subj2','Subj3','Subj4','Subj5','Subj6','Subj7','Subj8','Subj9','Subj10','Subj11','Subj12','Subj13','Subj14','Subj15','Subj16','Subj17','Subj18'}';

t_loud_fc = table(subj,fc_y_250_mean,fc_y_500_mean,fc_y_1000_mean,fc_y_2000_mean,fc_y_3000_mean,fc_y_4000_mean,...
  'VariableNames',{'subj','Cond1','Cond2','Cond3','Cond4','Cond5','Cond6'});

cond_loud_fc = dataset([1 2 3 4 5 6]','VarNames',{'Conditions'});

rm_loud_fc = fitrm(t_loud_fc,'Cond1-Cond6~subj','WithinDesign',cond_loud_fc);

ranovatbl_loud_fc = ranova(rm_loud_fc);

The output from the console window is:

 

Error using eig
Input to EIG must not contain NaN or Inf.

Error in RepeatedMeasuresModel>mauchlyTest (line 1921)
lam = eig(C'*S*C);

Error in RepeatedMeasuresModel.fit (line 1369)
          [this.Mauchly,this.Epsilon] = mauchlyTest(this.Cov,size(Xmat,1),rank(Xmat));

Error in fitrm (line 67)
s = RepeatedMeasuresModel.fit(ds,model,varargin{:});

Error in RunStatAnalysis (line 51)
rm_loud_fc = fitrm(t_loud_fc,'Cond1-Cond6~subj','WithinDesign',cond_loud_fc);
I have traced the problem to line 1347 in RepeatedMeasuresModel.m. Here, the variable dfe is equal to zero and thus the covariance becomes 0 as well.. How do I avoid this?
 
The variable dfe is given by dfe = size(Xmat,1)-size(Xmat,2); , where Xmat is a 18x18 matrix and thus dfe becomes zero....

anova , within-subject , AI, Data Science, and Statistics , Statistics and Machine Learning Toolbox

Expert Answer

John Williams answered . 2024-12-21 01:40:09

Hello, I have a similar problem and don't understand how to solve it. I tried looking for missing values but don't seem to find them. This is my code:
 
V1 = (41 + 47 + 42)/x;
V2 = (54 + 97 + 58)/x;
V3 = (46 + 49 + 26)/x;
V4 = (28 + 40 + 45)/x;
V5 = (104 + 126 + 70)/x;
S1 = [V1 31 51 35 34];
S2 = [V2 22 75 42 55];
S3 = [V3 45 83 31 24];
S4 = [V4 54 67 10 55];
S5 = [V5 71 156 61 91];
vehicle = [S1(1) S2(1) S3(1) S4(1) S5(1)];
cloz_0_08 = [S1(2) S2(2) S3(2) S4(2) S5(2)];
cloz_0_1 = [S1(3) S2(3) S3(3) S4(3) S5(3)];
cloz_0_3 = [S1(4) S2(4) S3(4) S4(4) S5(4)];
cloz_1 = [S1(5) S2(5) S3(5) S4(5) S5(5)];
animals{1} = 'rat4';
animals{2} = 'rat15';
animals{3} = 'rat20';
animals{4} = 'rat21';
animals{5} = 'rat29';
animals = animals'
all = [vehicle' cloz_0_08' cloz_0_1' cloz_0_3' cloz_1'];
t = table(animals,all(:,1),all(:,2), all(:,3), all(:,4), all(:,5),... 'VariableNames',{'animals','veh','cloz_0_08', 'cloz_0_1', 'cloz_0_3', 'cloz_1'});
All = dataset([1 2 3 4 5]','VarNames',{'Treatments'});
rm = fitrm(t,'veh-cloz_1~animals','WithinDesign',All)
and when I run the last bit I get
>> rm = fitrm(t,'veh-cloz_1~animals','WithinDesign',All) Error using eig Input to EIG must not contain NaN or Inf.
Error in RepeatedMeasuresModel>mauchlyTest (line 1921) lam = eig(C'*S*C);
Error in RepeatedMeasuresModel.fit (line 1369) [this.Mauchly,this.Epsilon] = mauchlyTest(this.Cov,size(Xmat,1),rank(Xmat));
Error in fitrm (line 67) s = RepeatedMeasuresModel.fit(ds,model,varargin{:});


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.