Hi, I am trying to use grpstats on my program and trying to compute median and percentile and skew but somehow i am not getting the program to run.
이전 댓글 표시
This is what I write
[ Z]= [WeekNum,C,E,G,I];
[stat1,stat2]= grpstats(Z,WeekNum,{'mean',@(Z) prctile(Z,50)})
This is the error I am getting---
Error using grpstats>tryeval (line 429) Error computing statistics for group '10'.
Error in grpstats (line 304) z(gnum,:,:) = tryeval(hfun,x(idx,:),glabel{gnum},tsize)';
Error in portfoliocharacterization (line 24) [stat1,stat2]= grpstats(Z,WeekNum,{'mean',@(Z) prctile(Z,50)}) Caused by: Function '@(Z)prctile(Z,50)' returned a result of size [1 1], expected size [1 5]. ------------------------------------------------------------------------
My data has 5 columns,containing financial statistics and I am grouping them based on what week they were calculated.
I would appreciate any help.
채택된 답변
추가 답변 (1개)
Wayne King
2013년 8월 2일
편집: Wayne King
2013년 8월 2일
Hi Rishav, WeekNum should be your grouping variable for the observations in Z so I'm not sure why you are including WeekNum in the matrix Z. For example, suppose I have the following temperature data with month as the grouping variable
month = [1 1 1 1 6 6 6 6 9 9 9 9]';
% then the temperature data
temp_jan = [20 15 21 17]';
temp_jun = [75 78 80 82]';
temp_sept = [65 60 70 75]';
temp_data = [temp_jan temp_jun temp_sept];
temp_data = reshape(temp_data,12,1);
[stat1,stat2]= grpstats(temp_data,month,{'mean',@(temp_data) prctile(temp_data,50)});
카테고리
도움말 센터 및 File Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!