|
|
|
||||
|
Help the Stat Consulting Group by
giving a gift
| |||||
|
Loading
|
|||||
| cd | Change directory |
| use | Load dataset into memory |
| describe | Describe a dataset |
| list | List the contents of a dataset |
| codebook | Detailed contents of a dataset |
| log | Create a log file |
| summarize | Descriptive statistics |
| tabstat | Table of descriptive statistics |
| table | Create a table of statistics |
| stem | Stem-and-leaf plot |
| graph | High resolution graphs |
| kdensity | Kernel density plot |
| sort | Sort observations in a dataset |
| histogram | Histogram for continuous and categorical variables |
| tabulate | One- and two-way frequency tables |
| correlate | Correlations |
| pwcorr | Pairwise correlations |
We will begin by loading hs0.dta, a dataset saved in Stata's format that we encountered in the Entering Data unit. Stata data files end with the dta extension. Stata data files are loaded into memory using the use command.
use http://www.ats.ucla.edu/stat/data/hs0, clear
describe list list gender-read codebook
log using unit2.txt, text replace
summarize summarize read math science write display 9.48^2 /* note: variance is the sd (9.48) squared */ summarize write, detail sum write if read>=60 /* note: sum is abbreviation of summarize */ sum write if prgtype=="academic" sum write in 1/40
tabstat read write math, by(prgtype) stat(n mean sd)
tabstat write, by(prgtype) stat(n mean sd p25 p50 p75)
Next, let's use some graphics commands to look at our data. We will begin with stem which generates an ASCII stem-and-leaf plot. We will also use the graph command with the hist (histogram) and box (boxplot) options. We also show the kdensity command which produces a smoothed density plot.
stem write stem write, lines(2)
histogram write, normal histogram write, normal start(30) width(5)
kdensity write, normal kdensity write, normal width(5) /* a smoother kdensity plot */ kdensity math, normal
graph box write graph box write, over(prgtype)
histogram ses histogram ses, discrete tabulate ses tab write /* note: tab is abbreviation of tabulate */ tab1 gender schtyp prgtype
tab prgtype ses
tab prgtype ses, row col
correlate write read science pwcorr write read science, obs scatter write read scatter write read, jitter(2) graph matrix read science write, half
log close
view unit2.txt
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services