Professional Documents
Culture Documents
Peter A. Lachenbruch
&
Alan C. Acock
Oregon State University
peter.lachenbruch@oregonstate.edu
alan.acock@oregonstate.edu
Merging
Merging two waves of data
WCSUG Presentation
geny=1ifcategory
geny=1if(category==1)
geny=1if(category>0)
The first and third will give scores of 1 for missing values. The
second will give a score of 0 for missing values - BEWARE
WCSUG Presentation
WCSUG Presentation
WCSUG Presentation
Examples
summarizesp,detail;listsp;
describes*;codebooks*
displaybinomial(10,3,0.1) for
cumulative or display
Binomial(10,3,.1) for reverse
cumulative; Note disp1
binomial(10,2,.1)givesthesame
result(alsobinomialtail(10,3,.1)
displaynormal(1.2)
geny=invnormal(uniform())*5+20
WCSUG Presentation
Percentiles
summarize,d
centileprice,c(10(10)90)
WCSUG Presentation
Examples
cii204;
cii204,agresti
Sometimes we want to use the Agresti formulation. The
exact is usually preferable
civarname,level(99)
summarizeweakness,detail
Can use suweakn,d(i.e.abbreviate
commands,optionsandvariables)
centileweakness,c(20,40,60,80)
Or centileweakness,c(20(20)80)
WCSUG Presentation
10
Binomial variables
One sample proportion
Two samples tabulate,chi2
WCSUG Presentation
11
Examples
ttestsp=120 [one-sample]
ttestspmen=spfem [paired]
ttestspmen=spfem,unpaired
unequalwelch
ttest sp, by(sex) [unequal welch etc.]
Also immediate form see help
anovaspagegrp
WCSUG Presentation
12
Examples
bitestsuccess=0.8 [one sample
binomial]
tabulatesuccessgroup,chi2
rowcol
prtestsuccess,by(group) [two
sample binomial]
WCSUG Presentation
13
WCSUG Presentation
14
Examples
sampsi132.86127.44,p(0.8)r(2)
sd1(15.34)sd2(18.23)
ranksumsp,by(survive)
signrankbefore=after
When should we supplement Stata with other
software such as G*power3 that is free and
more flexible than sampsi or other software
such as PASS or nQuery Advisor?
WCSUG Presentation
15
WCSUG Presentation
16
Examples
regressmpgweight
rvfplot
Statas type a little, get a little very different from
other packages
correlatempgweightorpwcorrmpg
weight (especially when you have more than 2
variables can specify sig and obsNote that
these only work withpwcorr)
spearmanmpgweight would be nice to have
Stata produce a Spearman correlation matrix
WCSUG Presentation
17
Examples
Its easy to use permutation tests
.permuteanyhcqt=r(t):ttestald7ifadult==1&assnum==1,by(anyhcq)(runningtteston
estimationsample)
MonteCarlopermutationresultsNumberofobs=97
command:ttestald7,by(anyhcq)
t:r(t)
permutevar:anyhcq
T|T(obs)cnp=c/nSE(p)[95%Conf.Interval]
+
t|1.648305131000.13000.0336.071073.2120407
Note:confidenceintervaliswithrespecttop=c/n.
Note:c=#{|T|>=|T(obs)|}
18
WCSUG Presentation
19
Data Sets
Place data sets on a LAN or common
drive or available for copying to flash
drive or CD
Use real data
Not too many variables
May have missing values but should not
affect main analyses unless you want to
demonstrate the problems with missing
values
WCSUG Presentation
20
In the Classroom
Using CD rather than flash drive is
better(?)
Many desktops have USB port located
inconveniently (darn you Dell!)
Sometimes newer PCs have USB port on
monitor, and laptops usually have an easy slot
for the flash drive
Light level in the room should allow students
to read easily
Days of dim projectors are over
WCSUG Presentation
21
22
23
Virtual Lab
A server supporting 30 simultaneous sessions of
Stata is remarkably inexpensive.
A department can require students to have
laptops or provide a cart with enough laptops
Because laptops are really dumb terminals with
server, the laptops can be cheap and not
updated very often
Any room becomes a lab
Students should have 24/7 access to the server
WCSUG Presentation
24
Data sets
On line LAN or CD or Floppy disk --Lots of laptops
dont have floppy drives any more, flash drives are
inexpensive
Include
Student generated datasets
Datasets with large Ns and relatively few variables
WCSUG Presentation
25
Emphasis in Course
Lectures devoted to statistics
Labs to learning Stata and working on
homework and discussion
Proper printing of output
Dont split output between two pages if
possible (at least, find a good break point)
Always use a monotype font (such as Courier
New)
WCSUG Presentation
26
WCSUG Presentation
27
The End
WCSUG Presentation
28