Since I could not find a build-in function for my purpose I ended up writing this little function: http://www.mathworks.com/matlabcentral/fileexchange/45966-compare-two-proportions-chi-square
How to compare two proportions ?
조회 수: 13 (최근 30일)
이전 댓글 표시
I have a vector of x1=[0 1 1 0 1 0 ... 1 0 1] and a cell array of string x2={'Condition A' 'Condition A' 'Condition B'..... 'Condition A' 'Condition B' 'Condition B' 'Condition A}.
How can I test if the proportion of "1" is different in Condition A versus Condition B ?
I tried using crosstab() but I am unsure how to set up the data. It looks like crosstab(x1,x2) expects x1 and x2 to be grouping variables. The x1 I have is a response variable.
How should i set up my data for crosstab? Is there another function which would take counts or a binary response variable? Maybe an equivalent of the R function prop.test() ?
댓글 수: 0
채택된 답변
추가 답변 (1개)
dpb
2014년 3월 19일
Start by simply converting the ASCII to another logical array of 0/1...
xA=ismember(x2,'Condition A'); % swap 'B' for 'A' if sense is other way in x1; you don't say
then compute the estimated p for the two populations as
p=[sum(x1) sum(xA)]/length(x1); % assuming same length; if not use each length of course
To test the null hypothesis the two are the same, see--
for method. Not positive if Matlab has a builtin test or not but it's surely not complicated.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Hypothesis Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!