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.
Show older comments
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.
Accepted Answer
More Answers (1)
Wayne King
on 2 Aug 2013
Edited: Wayne King
on 2 Aug 2013
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)});
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!