Statalist


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

Re: st: question on xtile using cutpoints


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: question on xtile using cutpoints
Date   Wed, 22 Oct 2008 18:42:01 +0100 (BST)

I understand the confusion though, the syntax of -xtile- does not look 
very Stataish to me (to borrow some Coxish terminology). I would have
expected that the cutpoints should be given to -xtile- as a numlist
instead of storing these as a variable. Maybe the numlist causes
problems if you want to specify a lot of cutpoints, but I don't know.

-- Maarten

--- Maarten buis <[email protected]> wrote:

> --- Sharon Kane <[email protected]> wrote to me privately:
> 
> > Thanks Maarten, that does help some, but here is the rest of the
> > specifics.  I have two choices for my cutpoints - 1. the original
> > variable and 2. the variable containing quintiles 1-5.  When I
> select
> > either of those as my cutpoints for the new variable, the results
> are
> > strange.  Any further suggestions?
> 
> It is usually better to respond to the statalist for reasons
> discussed
> in section 5 of the statalist FAQ.
> 
> A quick and dirty method is shown in the example below:
> 
> *------------- begin example -------------
> // prepare the data
> tempfile benchmark newdata
> 
> sysuse auto, clear
> keep if foreign == 0
> save `benchmark'
> 
> sysuse auto, clear
> keep if foreign == 0
> save `newdata'
> 
> // collect the cutvalues
> use `benchmark', clear
> _pctile mpg , nquantile(5)
> return list
> 
> // apply these cutvalues to new data
> use `newdata', clear
> gen bench = .
> forvalues i = 1/4 {
> 	replace bench = `r(r`i')' in `i'
> }
> list bench in 1/10
> xtile newvar = mpg, cutpoints(bench)
> tab newvar
> tab mpg newvar
> *------------- end example ----------------
> (For more on how to use examples I sent to the Statalist, see
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
> 
> Hope this helps,
> Maarten
> 
> 
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology
> Vrije Universiteit Amsterdam
> Boelelaan 1081
> 1081 HV Amsterdam
> The Netherlands
> 
> visiting address:
> Buitenveldertselaan 3 (Metropolitan), room N515
> 
> +31 20 5986715
> 
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
> 
> 
>       
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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