Summary Statistics Table by group
24 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm new in Matlab and I'm completely lost. I would like to create a table of summary statistics (mean, median, mode, std, max, min, skewness, kurtosis) of different caracteristics such as Common Equity Tier 1 ratio, Leverage ratio..... I imported my data form my excel folder. I already create and define my variables.
Here is my code : %Create and define my date data.return1018=data.data(:,1); data.return1w=data.data(:,2); data.LVGR0617=data.data(:,3); data.CET1R0617=data.data(:,7); data.TLRE0617=data.data(:,11); data.NPA0617=data.data(:,25); data.OBS0617=data.data(:,27);
dsa=({'data.CET1R0617', 'data.LVGR0617', 'data.NPA0617', 'data.OBS0617', 'data.return1w', 'data.return1018'})
statarray = grpstats(dsa,{'mean','median','mode','std','min','max','skewness','kurtosis'})
The problem is that my group stats doesn't work... and I really don't know why.
Thank you in advance for your help,
1 个评论
jonas
2018-10-25
Well, your syntax is wrong and it's not possible to help you with the limited information you have provided. What is dsa? Why is the table not passed to the function? Are all your variables numeric?
Would be easier if you just uploaded your table.
回答(2 个)
jonas
2018-10-25
You need to pass the table as input to grpstats. Assuming that dsa is a cell array with grouping variables, then change your code as follows:
dsa = {'CET1R0617', 'LVGR0617', 'NPA0617', 'OBS0617', 'return1w', 'return1018'}
statarray = grpstats(data,dsa,{'mean','median','mode','std','min','max','skewness','kurtosis'})
0 个评论
Steven Lord
2018-10-25
Instead of reading your data into a matrix and post-processing to create a struct from that matrix, consider using readtable to read the data directly into a table array.
Once you have your data in a table use groupsummary with one or more of your table variables as a grouping variable, or use findgroups and splitapply, or depending on the specific summary statistics you want to generate call summary on the table.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!