Concordance index loop optimization

1 回表示 (過去 30 日間)
Andre
Andre 2014 年 6 月 6 日
回答済み: Julio Chirinos 2018 年 8 月 14 日
Hello, I'm implementing de concordance index measure (<http://biomet.oxfordjournals.org/content/92/4/965.abstract>) to compare a regression model with tru labels, and I attempted to do a loop based implementation that is currently very slow (see below). Does anybody know a good implementation of this measure, or how to optimize this code?
Thanks in advance
CODE:
function [ci] = acan_concordance_index(targets, predicts)
[~,i] = sort(targets,'descend');
predicts = predicts(i);
n = length(targets);
total = 0;
norm_z = 0;
for j=1:n
for k=j:n
if j ~= k
h = step_function(predicts(j) - predicts(k));
total = total + h;
norm_z = norm_z + 1;
end
end
end
ci = total / norm_z;
end
function h = step_function(diff)
if diff > 0
h = 1;
elseif diff == 0
h = 0.5;
else
h = 0;
end
end
  2 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 6 月 6 日
In the above code, the outer for loop is iterating over j and the inner for loop is iterating over k. Yet h is being calculated as
h = step_function(predicts(i) - predicts(j));
Do you mean to be using i which is a vector returned from the sort function?
Andre
Andre 2014 年 6 月 7 日
Yes Geoff, I misstyped it, and already edited. I also changed the inner loop to begin with j, as the list is already ordered. I found a nice definition of the c-index here: https://stat.ethz.ch/pipermail/r-help/2008-December/182565.html The code seems to match mine, but it is also non optimized.
Thanks for the reply.

サインインしてコメントする。

回答 (1 件)

Julio Chirinos
Julio Chirinos 2018 年 8 月 14 日
does anybody have a function to compute the Harrel c index in Matlab? I have reached out to the Mathworks to no avail. Any help would be greatly appreciated. Alternatively, in the function above, what is targets and predicts? how do I go from the output of coxphfit to these 2 arguments in order to use the function? Thank you!

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by