[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Cumulative Percentiles & Accuracy Profiles

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Cumulative Percentiles & Accuracy Profiles
Date   Thu, 2 Apr 2009 15:44:10 +0200


set obs 10000
g x=runiform()*10
g y=1+2*x+rnormal()
reg y x
predict pred
xtile predxtile = pred, nquantiles(100)
xtile depxtile = y, nquantiles(100)

forv i=1/100{
qui cou if  predxtile<=`i' &  depxtile<=`i'
di in red "Now at top `i' percent with `r(N)' agreements, for a percentage
of " %3.2fc `=`r(N)'*100/`c(N)''

You could of course use a -matrix- or -postfile- to accumulate those


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Ronan Gallagher
Gesendet: Donnerstag, 2. April 2009 15:21
Betreff: st: Cumulative Percentiles & Accuracy Profiles


I am doing some modelling using Stata and wish to draw a cumulative accuracy
profile.  Essentially I have a model from which I want to compare the actual
and predicted values of my dependent variable.

To do this I need to create 100 bins and assign the top 1% of all predicted
values to the first bin, the top 2% to the second bin and so forth until the
100th bin consists of the total number of observations.  I then want to
repeat this exercise for the actual value of the dependent variable.  Once
the bins are populated I need to compare how many predicted values in a
given bin also have their actual values in the same bin.  I then need to
plot this percentage for each bin and the resultant graphic is the
cumulative accuracy profile for my model.

My uncertainty centres on the cumulative nature of the bin assignment i.e.
the first percentile of observations fall into every bin, the second
percentile into 99 bins and the final percentile into only one bin.  The
xtile command therefore is not as useful.

Any help on how to compute the appropriate percentages and display the
cumulative accuracy profile would be greatly appreciated.

Thank-you in advance,

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index