Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Analysis with STATA

You're reading from   Data Analysis with STATA Explore the big data field and learn how to perform data analytics and predictive modelling in STATA

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781782173175
Length 176 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Introduction to Stata and Data Analytics FREE CHAPTER 2. Stata Programming and Data Management 3. Data Visualization 4. Important Statistical Tests in Stata 5. Linear Regression in Stata 6. Logistic Regression in Stata 7. Survey Analysis in Stata 8. Time Series Analysis in Stata 9. Survival Analysis in Stata Index

Survey analysis in Stata code


Let's understand the Stata code to take a random sample from the survey data. A random sample is also called simple random sample (SRS):

use survey_data, clear
count
1095
set seed 2087620
sample 26
count
286

The following diagram represents the random sample generation mechanism:

Let's understand how to create pweights that are probability weights for the given sample.

Now, the sampling fraction in our case is given by the following:

So, the Stata code for pweight is as follows:

gen pweight = 1095/286

Similarly, FPC will be generated as follows:

gen fpc = 1095

This command generates the following output:

Now, we can leverage svyset, which is a command to give out the information stored in Stata with respect to the sampling design and plan. In this case, the PSU numbers remain the same, which means that Stata has a thorough understanding, which is similar to the understanding we have. As there is only one Stata, the sampling design is similar—in fact, it's the same as...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime