MATLAB: Proportion of gender having health issue

proportion;

I have a table that has Gender vector (1=Boy, 2=Girl) and Healtissue (based on score). I would like to know the proportion of girls only have a health issue if their score more than 17?

Best Answer

Assume t is your table and you have a column for gender, a column with HealthScore (true or false), and a column for their score (continously-valued number). Then try
% Find rows with girls who have a score more than 17.
rows1 = (t.Gender == 2) & (t.Score > 17)
% Now find girls with a score more than 17 who ALSO have a health issue (may not be 100% - may only be part of them).
rows2 = (t.Gender == 2) & (t.Score > 17) & t.HealthIssue % Assuming this is a logical column.
proportion = rows2 / rows1
Related Question