Statistics for the
Social Sciences Handout

Richard (rick) Barton
Statistical consultant
Academic Computing
richard.barton@dartmouth.edu


Help

The Social Science Computing (SSC) lab is located in 26 Silsby.  Staff there can help you install Stata or other related software, get data into Stata, and do basic analyses with Stata; they cannot teach you statistics.  Lab computers have Stata 8 installed and there is a set of Stata manuals available. The lab is open most weekday and Sunday afternoons and evenings.  See http://www.dartmouth.edu/~ssc/supported.htm for a description of lab hours and support services.


Installing Stata and supporting software

Stata is free software for Dartmouth students; the current version is 8. Students who own a Macintosh running OS 9 cannot install Stata 8; use Stata 7 instead.

Stata and supporting software that you need to run Stata can be downloaded from http://www.dartmouth.edu/software   Academic Applications include Stata and KeyAccess.  General Productivity Applications include Stuffit Expander.  Be sure to carefully read the website's instructions on how to download and install the various applications, along with any ReadMe file that gets downloaded with an installer.

You may need to install Kerberos to download other software; students who bought their computers through Dartmouth should already have Kerberos, KeyAccess, and Stuffit installed.

1) SideCar (Kerberos) gets you a Kerberos ticket. This authenticates you to the Dartmouth network, which allows you to download from the Dartmouth website. Your Blitzmail password is also your Kerberos password.

2) KeyAccess (KSClient) allows you to run keyserved software. You must be logged on to keyserver.dartmouth.edu to install and run Stata.

3) Stuffit (Aladdin) Expander is used to decompress (unzip) files.

4) Stata.



Some Stata windows

Results   Shows the commands you've entered and the output of those commands. Upon seeing -more- at the bottom of the window, enter continues and q quits.

Review  Shows the most recent commands entered. Highlighting a command here enters it in the command window.

Variables  Lists the variables in the current data set. Highlighting a variable here enters it in the command window.

Data editor  Opens the current data set in spreadsheet editor. This window must be closed out to return you to the command window.

Graph  Where graphs are displayed.



Log files

A log file can contain the commands you type and the results of your analyses.  To open a log file, usually at the beginning of a session, just go to the File/Log menu.  Make sure the file has a .log extension so you can open the file in applications other than Stata.



Data files

Rows are cases, columns are variables.

.dta indicates a data file already in Stata format
.txt or .raw indicates data in ASCII (text) formats
.xls indicates data in an Excel file

You may already have a data set that you wish to bring into Stata. The file can be either:

You may need a codebook that indicates the format of the file, what columns hold what variables, how missing values are defined, what value labels should be applied, etc.

Use  Opens a data file that is already in Stata format.   The directory path must be specified and can be obtained from the File/Filename menu

Insheet  Will read data from a file that is already in a spreadsheet format

Infile  Will read freefield data and tab- or comma-delimited data from a text file

Infix  Will read fixed field data from a text (ASCII) file.


Note that Macintosh and Windows file paths are somewhat different.  Example:

     insheet id sex using ':Macintosh HD:Desktop Folder:hsb.raw'   (Mac file path)

     insheet id sex using 'c:\my documents\clients\hsb.raw'   (PC file path)


General commands

Clear  Clears data out of memory.

Search  If you make a mistake with a Stata command, it may return an error message along with a return code   {for example, r(199)}.  The search command can be used to get a more detailed description of the return code.

Generate   Computes a new variable from an expression.

Labels   Maps string value labels to numeric values of a categorical variable
     label define sexlbl  0 "male" 1 "female"      (defines labels for the format sexlbl)
     label values sex sexlbl       (associates sexlbl format with variable sex)


Basic analysis commands

Most analysis commands can be followed by a comma and a list of options.  Stata 8 also allows you to do many analyses from the Statistics menu instead of issuing commands from the command window.

Tabulate  Gets counts and percents of subgroups for 1 or 2 variables.  

Summarize  Calculates summary statistics such as means and sd’s. 

Correlate  Displays the correlation matrix for a list of variables.  

Regress   Fits a linear regression model of a dependent variable on a single predictor or set of predictors


Some other analysis commands

ttest does single sample, dependent, and independent t-tests
anova estimates ANOVA and ANCOVA models
oneway estimates one-way ANOVA models and can report multiple comparisons
regress   estimates linear regression models
glm   estimates complicated general linear models
canon   conducts a canonical correlation analysis
factor conducts a factor or principal components analysis
cluster conducts a cluster analysis




Graphs

Graph commands differ in Stata 7 and Stata 8. Stata 8 also allows you to build graphs from the Graphics menu.

Graph type

Stata 7 command examples

Stata 8 command examples

Bar chart

graph x y z, bar options

graph bar x y z, options

Histogram

graph x, histogram options

histogram x, options

Scatterplot

graph y x, twoway options

scatter y x, options