I continue putting the notes for routine statistical analysis in R. The comparison of means calculated for categorical data is of great importance for a numerous animal scientists. I solved to share how to organize that.
The Student's method is used to get that point. If frequencies for groups compared are like 0.25 and lower or 0.75 and higher then the Fischer's Phi criterion is highly recommended to apply.
Perhaps, there is another way to get means compared...
#Population mean value computing for a couple of means for descrete data.
#Standard error for the zero frequency is calculated by the van der Waerden method
x1<-0.007*100 #first mean to compare (%)
x2<-0.0006*100 #second mean to compare (%)
n1<-1600
n2<-1600
N<-n1+n2
P1<-(x1*n1)/100
P2<-(x2*n2)/100
P<-P1+P2
#If x1 and x2 are equal to 0 then Van-der-Varden error is calculated. If not then the comparison between n1 and n2 is appear to solve how many variables are in a common sample.
if (x1==0 & x2==0) {p<-((P+1)*100)/(N+2);sp<-sqrt((p*(100-p))/(N+3));p=0} else{
if(n1==n2) {p<-(P/n1)*100;q<-100-p; sp<-sqrt(p*q)/sqrt(n1-1)} else {p<-(P/N)*100;q<-100-p;sp<-sqrt(p*q)/sqrt(N-1)}
}
paste ("p±sp: ",round(p,2),"±",round(sp,3), sep="")
#Phi comparison methodology (p<0.25, q>0.75)
p1<-x1/100
p2<-x2/100
phi1<-2*asin(sqrt(p1))
phi2<-2*asin(sqrt(p2))
F<-((phi1-phi2)^2)*((n1*n2)/(n1+n2))
paste ("method phi, F: ",round(F,2)," -- df=",n1+n2-2, sep="").
No comments:
Post a Comment