Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inequality analysis

    Hi,
    I’am new in the forum, I don’t know if I posted in good place for my question, this is my first message. I’am taking class about Inequality analysis, as i’am new in Stata i have problem with some commands used. I didn’t understand the following code:
    gen transfer = 0
    loca total_transfers = 0
    local limit = 0
    while `total_transfers' < 300 {
    qui replace transfer=max(0, `limit'-income)
    qui sum transfer
    local total_transfers=r(sum)
    local limit = `limit'+1
    }
    I understood the first line of the code, but the rest is not clear for me. Could you help me for understanding please? Thanks very much

  • #2
    you are searching for the smallest limit where the total transfer exceeds 300.

    The local macros transfer and total_transfer are used here as places to store numbers. So you start by storing 0 in `total_transfer' and `limit'.

    The while command says to continue executing the block of code between { and }, until the logical statement `total_transfers' < 300 becomes false

    The first line in the while loop replaces the variable transfer with limit - income if that is positive or zero if that difference is negative
    sum, summurizes that variable, which leaves various characteristics of that variable behind in memory. Among those is the sum in r(sum)
    This is what is used in the next line: the local macro `total_transfer' is set to the sum of the variable transfer, which was computed by the sum command
    The final line of the block increases the limit by 1

    A number of the tricks used here are also discussed here: http://www.maartenbuis.nl/workshops/.../stata_l2.html
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X