| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Re: new sampling problem
Thanks for this, and for the setting the seed advice.
I have tried to sort this out with this very crude program but it only seems
to do the sampling for one value of newvar1, can anyone help me with this?
the first part of the do file defines the data. The last part does the
sampling I am interested in. It is very, very crude - and it may seem a
little odd, although I know what I want to do.
clear
range y 1 10 10
sum y
gen income=.
replace income=1 in 1/4
replace income=2 in 5/8
replace income=3 in 9/10
gen sex1=.
replace sex1=2 in 1/5
replace sex1=1 in 6/10
gen sex2=.
replace sex2=1 in 1/3
replace sex2=2 in 4/5
replace sex2=3 in 6/10
tab income
tab sex1
tab sex2
preserve
sort sex2
contract sex2
tempvar newvar
samplepps newvar, size(_freq) withrepl ncases(100)
mkmat newvar
restore
svmat newvar
gen const=1
local news=newvar1
foreach val of local news{
samplepps sample`val', ncases(`val') withrepl size(const)
}
From: "Michael Blasnik" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: Re: st: Re: new sampling problem
Date: Tue, 19 Jun 2007 11:45:48 -0400
..
You can easily automate this by building the local macro from whatever part
of your do or ado file creates the numbers. I just gave the example of
creating it as a list all at once, but obviously you can pass the list into
this however you want. You could even write a wrapper ado around samplepps
that would take a list of numbers and run samplepps with each of them. You
may also be able to move the calls to samplepps into whatever process
creates these numbers. Also, the advice about setting the random number
seed by Steven Samuels elsewhere on this thread should be followed.
Michael Blasnik
----- Original Message ----- From: "John allfish" <[email protected]>
To: <[email protected]>
Sent: Tuesday, June 19, 2007 11:38 AM
Subject: RE: st: Re: new sampling problem
The list of numbers will work, however I want the program to run without
me specifying the numbers. These come from another part of the work I am
doing and I want them to be called into samplepps automatically. I should
have added that I want to use samplepps to draw random samples of larger
than existing N. It was suggested that gsample but I am using version 8.0
and it would not work.
Thanks,
John
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________
The next generation of Hotmail is here! http://www.newhotmail.co.uk/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/