Book Image

Data Analysis with STATA

Book Image

Data Analysis with STATA

Overview of this book

Table of Contents (16 chapters)
Data Analysis with Stata
About the Author
About the Reviewers


This book covers data management, visualization of graphs, and programming in Stata. Starting with an introduction to Stata and data analytics, you'll move on to Stata programming and data management. The book also takes you through data visualization and all the important statistical tests in Stata. Linear and logistic regression in Stata is covered as well. As you progress, you will explore a few analyses, including survey analysis, time series analysis, and survival analysis in Stata. You'll also discover different types of statistical modeling techniques and learn how to implement these techniques in Stata. This book will be provided with a code bundle, but the readers would have to build their own datasets as they proceed with the chapters.

What this book covers

Chapter 1, An Introduction to Stata and Data Analytics, gives an overview of Stata programming and the various statistical models that can be built in Stata.

Chapter 2, Stata Programming and Data Management, teaches you how to manage data by changing labels, how to create new variables, and how to replace existing variables and make them better from the modeling perspective. It also discusses how to drop and keep important variables for the analysis, how to summarize the data tables into report formats, and how to append or merge different data files. Finally, it teaches you how to prepare reports and prepare the data for further graphs and modeling assignments.

Chapter 3, Data Visualization, discusses scatter plots, histograms, and various graphing techniques, and the nitty-gritty involved in the visualization of data in Stata. It showcases how to perform visualization in Stata through code and graphical interfaces. Both are equally effective ways to create graphs and visualizations.

Chapter 4, Important Statistical Tests in Stata, discusses how statistical tests, such as t-tests, chi square tests, ANOVA, MANOVA, and Fisher's test, are significant in terms of the model-building exercise. The more tests you conduct on the given data, the better an understanding you will have of the data, and you can check how different variables interact with each other in the data.

Chapter 5, Linear Regression in Stata, teaches you linear regression methods and their assumptions. You also get a review of all the nitty-gritty, such as multicollinearity, homoscedasticity, and so on.

Chapter 6, Logistic Regression in Stata, covers how to build a logistic regression model and what the best business situations in which such a model can be applied are. It also teaches you the theory and application aspects of logistic regression.

Chapter 7, Survey Analysis in Stata, teaches you different sampling concepts and methods. You also learn how to implement these methods in Stata and how to apply statistical modeling concepts, such as regression to the survey data.

Chapter 8, Time Series Analysis in Stata, covers time series concepts, such as seasonality, cyclic behavior of the data, and autoregression and moving averages methods. You also learn how to apply these concepts in Stata and how to conduct various statistical tests to make sure that the time series analysis that you performed is correct.

Chapter 9, Survival Analysis in Stata, teaches survival analysis and different statistical concepts associated with it in detail.

What you need for this book

For this book, you need any version of the Stata software.

Who this book is for

This book is for all professionals and students who want to learn Stata programming and apply predictive modeling concepts. It is also very helpful for experienced Stata programmers, as it provides information about advanced statistical modeling concepts and their application.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

infix dictionary using Survey2010.dat
  rowtype  1-2
  yr  3-4 quart5 […]

Any command-line input or output is written as follows:

assert popscon>0,
assert popscon<0

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: " You can also select the Reporting tab and select the Report estimated coefficients option."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.