Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Mike Lacy <Michael.Lacy@colostate.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: -svy- commands with a pps sample vs. a simple random sample |

Date |
Fri, 13 May 2011 15:58:58 -0600 |

Greetings,

// Create the simulated data clear set obs 25000 local sampleN = 500 set seed 83573 gen kwh = exp(rnormal(6.4, 0.65)) // kwh usage gen savepct = -0.61 - 0.00014*kwh + 0.14 * sqrt(kwh) // looks realistic to me replace savepct = savepct + rnormal(0,0.5) // gives r = 0.9 with kwh // Population regression relationship gen sqrtk = sqrt(kwh) regress savepct kwh sqrtk // The true populatioh relationship // // Sample the data, pps, and run a regression model quiet summ kwh, detail gen pps = `sampleN' * kwh/r(sum) // sampling prob to get pps and n = 500 // User written -gsample- , see -findit gsample- gsample `sampleN' [aw = pps], gen(picked_pps) wor gen pwt = 1/pps svyset _n [pweight = pwt] svy: mean savepct if picked_pps svy: regress savepct kwh sqrtk if picked_pps // // Repeat analysis with simple random sampling svyset, clear gsample `sampleN', gen(picked_psrs) wor gen psrs = `sampleN'/`=_N' // sampling prob replace pwt = 1/psrs svyset _n [pweight = pwt] svy: mean savepct if picked_psrs svy: regress savepct kwh sqrtk if picked_psrs Thanks, =-=-=-=-=-=-=-=-=-=-=-=-= Mike Lacy, Assoc. Prof. Soc. Dept., Colo. State. Univ. Fort Collins CO 80523 USA

* * 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/

**Follow-Ups**:**Re: st: -svy- commands with a pps sample vs. a simple random sample***From:*Stas Kolenikov <skolenik@gmail.com>

- Prev by Date:
**Re: st: intraclass correlation for Categorical data** - Next by Date:
**re: st: Wishlist - Intellisense-like real time context for Stata programming** - Previous by thread:
**st: Price relative (y/y-1)** - Next by thread:
**Re: st: -svy- commands with a pps sample vs. a simple random sample** - Index(es):