I'm trying calculate the ROC curve of a cross-validation. In particular, the parameter AUC (Area under the curve) and OPTROCPT (Optimal ROC Point). I thing I can calculate them by averaging the AUC and th OptROCPt of each iteration, but I didn't get correct results. What am I doing wrong?
My code is:
cv = cvpartition(size(Y,1),'kfold',10);
AUCvector=zeros(10,1);
OptPtovector=zeros(10,2);
for k=1:10
istrain = training(cv,k);
istest = test(cv,k);
[b,dev,stats] = glmfit(X(istrain),y(istrain),'binomial','logit');
p=glmval(b,X(istest),'logit'); $ Are p the scores for perfcurve?
clear AUC OptPto
[Temp1,Temp2,Temp3,AUC,OptPto]=perfcurve(y(istest),p,1);
AUCvector(k,1)=AUC;
OptPtovector(k,:)=OptPto;
end
mAUC=mean(AUCvector)
mOptPto=mean(OptPtovector,2)
Best regards, Frank