Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: How to graph
From
Roberto Ferrer <[email protected]>
To
Stata Help <[email protected]>
Subject
Re: st: How to graph
Date
Thu, 20 Mar 2014 23:37:32 -0430
Another way:
*------------------------ begin code ---------------------
*clear all
set more off
webuse nlswork
keep idcode year ln_wage
keep if inlist(year, 68, 88)
local q = 10 // number of quantiles
pctile pct68 = ln_wage if year == 68, nq(`q')
pctile pct88 = ln_wage if year == 88, nq(`q')
gen diff = pct88 - pct68
gen xvar = _n*`=100/`q'' in 1/`=`q'-1'
label variable pct68 "1968"
label variable pct88 "1988"
label variable xvar "percentile"
twoway connected pct68 pct88 xvar, ytitle(Ln(wage)) msize(small small)
//additional graph
twoway connected diff xvar, ytitle(wage growth) msize(small)
*------------------------ end code -------------------------
On Thu, Mar 20, 2014 at 5:11 PM, Carlos Avellaneda Suárez
<[email protected]> wrote:
> I am sure that more advanced users may have better solutions, but this
> can work for your purposes. Suppose year 68 = 2000 and year 88 = 2005:
> *Begin*
> webuse nlswork
> preserve
> collapse (p10) p10=ln_wage (p20) p20=ln_wage ///
> (p30) p30=ln_wage (p40) p40=ln_wage (p50) p50=ln_wage ///
> (p60) p60=ln_wage (p70) p70=ln_wage (p80) p80=ln_wage ///
> (p90) p90=ln_wage , by(year)
> keep if year==68 | year==88 // You'll have to replace this line with
> the years you are interested in
> foreach v of varlist p10-p90 {
> gen growth_`v'=`v'-`v'[_n-1] if _n>1
> drop `v'
> }
> reshape long growth_p, i(year) j(percentile)
> graph bar (mean) growth_p, over(perc)
> restore
> *End*
> Hope this helps!
> Carlos
>
> 2014-03-20 16:02 GMT-05:00 Kisil ktl <[email protected]>:
>> Thank you for your reply Carlos. Sorry for being late to respond,
>> since I don't have stata on my own computer.
>> I applied what you suggested, however this is not the case I actually
>> want to graph .
>> I want to have percentiles (10th, 20th,..,90th) ordered on the x-axis
>> and difference of the log wage in 2000 from the log wage in 2005 for
>> the respective percentile on the y-axis, I'm not interested in the
>> years between 2000 and 2005.
>>
>> Greetings
>> Kisil
>>
>>
>> On Tue, Mar 18, 2014 at 9:44 PM, Carlos Avellaneda Suárez
>> <[email protected]> wrote:
>>> Hi Kisil,
>>> One solution is to collapse your dataset. Here is an example you can
>>> reproduce in a do-file:
>>> *****Begin Example*****
>>> webuse nlswork
>>> preserve
>>> collapse (p10) p10=ln_wage (p20) p20=ln_wage ///
>>> (p30) p30=ln_wage (p40) p40=ln_wage (p50) p50=ln_wage ///
>>> (p60) p60=ln_wage (p70) p70=ln_wage (p80) p80=ln_wage ///
>>> (p90) p90=ln_wage , by(year)
>>> tsset year
>>> tsline p*
>>> restore
>>> *****End*****
>>> By the way, why would you estimate a percent change in a log variable?
>>> Remember that the first difference of the logarithm of a variable
>>> approximates to the percentage change of the unaltered variable. With
>>> the previous example, you just have to generate new variables of the
>>> first difference of each percentile.
>>> Hope this helps.
>>> Carlos
>>>
>>> 2014-03-18 13:41 GMT-05:00 Kisil ktl <[email protected]>:
>>>> Dear statalist,
>>>>
>>>> I work on a data set that has log wage information of workers through six years.
>>>> In order to show how log wage at different percentiles changed between
>>>> the years 2000 and 2005, I want to make a graph that has
>>>> 10th,20th,..,90th percentiles on the x-axis and corresponding
>>>> percentage log wage changes on the y-axis.
>>>> For example, the graph should show how many percent did the log wage
>>>> of a worker at 90th or 10th percentile of the wage distribution change
>>>> between 2000 and 2005.
>>>> egen rank = rank(wage)
>>>> This command computes the percentile ranks of workers with respect to
>>>> their log wages, but I could not do the rest of it. How can I make
>>>> this kind of a graph?
>>>>
>>>> Best regards
>>>> Kisil
>>>> *
>>>> * For searches and help try:
>>>> * http://www.stata.com/help.cgi?search
>>>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>>>> * http://www.ats.ucla.edu/stat/stata/
>>> *
>>> * For searches and help try:
>>> * http://www.stata.com/help.cgi?search
>>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>>> * http://www.ats.ucla.edu/stat/stata/
>>
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>> * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/