Subscript indices error on fitrm with NaN values

Hello everyone,
I am having issues with creating a repeated measures model with fitrm. The issue occurs when I choose to omit a certain amount of data points within the table and replace with NaN values. What confuses me is that the dataset works with some values replaced with NaN, however,with a certain combination of omitted data points I receive a 'Subscript indices must either be real positive integers or logicals' error.
Here is my code:
load('Bad_ranova.mat');
%Fit Repeated Measures Model
MOS_fitrm = fitrm(t,'neg2del_os-pos2del_fix~Gender*Gait_Parameter','WithinDesign',within);
%Repeated measures ANOVA
MOS_rm = ranova(MOS_fitrm,'WithinModel','BP_Condition*Step_Width');
The tables 't' and 'within' are included as attached matlab structures. Good_ranova.mat runs with no issues, Bad_ranova.mat is the same dataset but with additional data values replaced with NaN (and does not run properly).
Thanks, - JP

댓글 수: 2

Leila
Leila 2018년 4월 19일
I am having exactly the same problem, any solution or advise?
Me as well..any solution yet?

댓글을 달려면 로그인하십시오.

답변 (1개)

Abhaya
Abhaya 2024년 12월 9일

0 개 추천

Hi JP,
The issue you're encountering is related to how MATLAB fitrm function handles missing data. Specifically, fitrm’ function removes any rows that contain missing values (NaN) before fitting the repeated measures model.
In the Bad_ranova.mat file, the table t contains at least one NaN value in each row. When fitrm’ function is executed, it removes all rows from the t table, resulting in an empty table, which triggers the error.
To resolve this issue, you can use any workaround to handle or replace NaN values. For guidance on handling missing data in MATLAB, refer to this resource.

카테고리

도움말 센터File Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기

질문:

JP
2017년 9월 7일

답변:

2024년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by