Introduction to Stata - Lab 1 - Fall 2008 | STATS 13, Lab Reports of Statistics

Material Type: Lab; Class: Introduction to Statistical Methods for Life and Health Sciences; Subject: Statistics; University: University of California - Los Angeles; Term: Fall 2008;

Typology: Lab Reports

Pre 2010

Uploaded on 08/26/2009

koofers-user-hmw
koofers-user-hmw 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Stat 13
Fall 2008
Nesbitt 2C
Lab 1 - Introduction to Stata
1. Start STATA: Go to Finder Applications Stata (folder) and
finally double click on the file called Stata (that has it’s icon next to
it).
You should see four windows: Review, Variables, Results and Com-
mand.
2. If you would like to take notes as we go along you can use Pages: Go
to Finder Applications iWork’08 Pages. This is the word
processor that we will be using in lab. If you will be working on this
document from home and use Microsoft Word, you can export the
document as a Word document and email it to yourself. Go to File
Export and choose Word format.
(Note: Most email accounts don’t let you attach Pages files so export-
ing it to Word is usually a good idea if you’ll be emailing the file to
yourself.)
3. Load data:
use http://www.stat.ucla.edu/labs/datasets/smallcen.dta
4. Exploring the data:
Getting an overview of the data file
describe
Q: What is the data set? How many variables are there? How
many observations?
Listing each observation:
list
In order to stop a list, use:
q
To get a list of one variable at a time:
list gender
1
pf3
pf4
pf5

Partial preview of the text

Download Introduction to Stata - Lab 1 - Fall 2008 | STATS 13 and more Lab Reports Statistics in PDF only on Docsity!

Stat 13 Fall 2008 Nesbitt 2C

Lab 1 - Introduction to Stata

  1. Start STATA: Go to Finder → Applications → Stata (folder) and finally double click on the file called Stata (that has it’s icon next to it). You should see four windows: Review, Variables, Results and Com- mand.
  2. If you would like to take notes as we go along you can use Pages: Go to Finder → Applications → iWork’08 → Pages. This is the word processor that we will be using in lab. If you will be working on this document from home and use Microsoft Word, you can export the document as a Word document and email it to yourself. Go to File → Export and choose Word format. (Note: Most email accounts don’t let you attach Pages files so export- ing it to Word is usually a good idea if you’ll be emailing the file to yourself.)
  3. Load data:

use http://www.stat.ucla.edu/labs/datasets/smallcen.dta

  1. Exploring the data:
    • Getting an overview of the data file describe Q: What is the data set? How many variables are there? How many observations?
    • Listing each observation: list In order to stop a list, use: q To get a list of one variable at a time: list gender

To get a list of more than one variable at a time:

list gender income

  • Stata also allows us to subset the data and concentrate on par- ticular observations. For example, we can look at the income for thirty of the youngest people. At rst, sort the data by age

sort age

And then type

list age income in 1/

  • Summarizing of all of the quantitative variables in the data le at once:

summarize

  • To get a summary of one variable at a time:

summarize income

Q: What is the typical income?

  • The average of the variable income may not actually tell us what the typical income is, there are many people that do not work and hence their income is recorded as 0. To remove the 0s, we will code them as missing values.

mvdecode income, mv(0=.a)

Q: How did this change the summarize income output?

  • We are interested in comparing the incomes of men and women. We can look at the summary of income for men and women sep- arately by typing

summarize income if gender== summarize income if gender==

Note: In this dataset, men are coded with a 1 and women are coded with a 2. Q: What differences or similarities do you notice about the income variable for men and women?

  1. To save and import graphs into text editors for your report:

After you make your plot, you have numerous options for saving it.

  1. Go to File>Save Graph. Be sure to change the format from “Stata Graph” file to either a .pdf or a .png file). Once you save it as such, you can import it into any text editor, such as Pages (Macs version of Microsoft Word).
  2. You can simply copy and past your graph into your text editor by going to Edit>Copy Graph. Then it is ready to be pasted at your desired location using the Paste option under the Edit menu.

Note: AGAIN, if you are working in Pages, make sure you save and export your document as a “Word” or .doc file if you want to attach it to your email and be able to open it in Microsoft Word as an editable file when you get home to your non-Mac computer.

  • To leave Stata, type clear exit
  1. Useful Commands for Getting Stated with Stata

use describe list sort summarize mvdecode hist, by gen drop clear

  1. A list of conditions:

in if by

On Your Own Assignment: Due Nov 4th. Prepare a typed report comparing Income w/ respect to Race. Be sure to include appropriate graphs where necessary.

  1. How many observations in the data set? List the values of race and income of the rst 10 observations.(10 points)
  2. Give the summary of income. Now, remove observations with income
    1. Give the summary of income again. Compare the di?erence of the two summaries. How many observations have income 0? (20 points)
  3. Write down the number of observations, mean, and standard deviation of income for each group of race. (Show the output in a table) ( points)
  4. Construct side-by-side box plots of income by race. (20 points)
  5. Write a paragraph to describe the differences in the income earned by different race groups. (25 points) Note: For question 3, 4, and 5, use the updated data (the data after removing the 0’s in income).