I tried to run this code taken from this expectacular blog of programmers (supuse used to make roc curve) but i can´t, seems to be is belongs to oldes eviews version. So it's possible to run in to the newest eviews version 12.0. What step do i have to do? Thanks
Juan Carlos Grass Galvis
Code: Select all
%dep = "grade"
%eq = "eq_probit"
' find valid observations
{%eq}.makeresid _xxe
' get number of 0 and 1
smpl if _xxe<>na and {%dep} = 0
!n0 = @obs({%dep})
smpl if _xxe<>na and {%dep} = 1
!n1 = @obs({%dep})
' get fittted values
smpl if _xxe<>na
{%eq}.forecast _xxyf
group a {%dep} _xxyf
stom(a, b)
stom(_xxyf, _xxprob)
' sort in descending order so we have threshold of infinity which is "off"
vector _xxpranks = @ranks(_xxprob, "d", "i")
matrix _xxsdata = @capplyranks(b, _xxpranks)
' get unique fitted values
vector _xxuniq = @uniquevals(pranks)
!nunique = @rows(_xxuniq)
delete _xxuniq
' create output ROC matrix
matrix(!nunique+2, 4) _xxroc
' we start at threshold of infinity which is "off"
!ntype1 = 0 ' number of correct 1 predictions
!ntype0 = !n0 ' number of correct 0 predictions
!j = 1
!i = 1
!n = @rows(_xxsdata)
roc(1, 1) = 1 - (!ntype0 / !n0) ' 1 - specificity
roc(1, 2) = !ntype1 / !n1 ' sensitivity
roc(1, 3) = 0
roc(1, 4) = 0
while !j <= !nunique
!target = _xxsdata(!i, 2)
!val = !target
while !val = !target
!response = sdata(!i, 1)
if (!response = 0) then
!ntype0 = !ntype0 - 1
endif
if (!response = 1) then
!ntype1 = !ntype1 + 1
endif
!i = !i+1
if (!i > !n) then
!val = 0
else
!val = sdata(!i, 2)
endif
wend
_xxroc(!j+1, 1) = 1 - (!ntype0 / !n0)
_xxroc(!j+1, 2) = !ntype1 / !n1
_xxroc(!j+1, 3) = !j / !nunique
_xxroc(!j+1, 4) = !j / !nunique
!j = !j + 1
wend
_xxroc(!j+1, 1) = 1 - (!ntype0 / !n0)
_xxroc(!j+1, 2) = !ntype1 / !n1
delete(noerr) roc_graph
freeze(roc_graph) _xxroc.xypair
roc_graph.options linepat -legend size(4,4)
roc_graph.setelem(1) linewidth(1.15)
roc_graph.setelem(2) linepattern(8)
%title = "ROC graph for"
%title = %title + " " + @upper(%eq)
roc_graph.addtext(t, font("Ariel", 12)) %title
roc_graph.addtext(l) "True Positive Rate"
roc_graph.addtext(b) "False Positive Rate"
show roc_graph
delete _xx*