Introduction to Programming in Stata

Size: px
Start display at page:

Download "Introduction to Programming in Stata"

Transcription

1 Introduction to in Stata Laron K. University of Missouri

2 Goals

3 Goals Replicability!

4 Goals Replicability! Simplicity/efficiency

5 Goals Replicability! Simplicity/efficiency Take a peek under the hood!

6

7 Data Management General rules of data management:

8 Data Management General rules of data management: 1 Never save over original variables!

9 Data Management General rules of data management: 1 Never save over original variables! 2 Never save over original data sets!

10 Data Management General rules of data management: 1 Never save over original variables! 2 Never save over original data sets! 3 Invest your time in learning new commands!

11 Data Management Potential issues when combining data sets with merge and append

12 Data Management Potential issues when combining data sets with merge and append Are you adding variables?

13 Data Management Potential issues when combining data sets with merge and append Are you adding variables? Or, are you adding observations?

14 Data Management Potential issues when combining data sets with merge and append

15 Data Management Potential issues when combining data sets with merge and append What is the unit of analysis for the master data set? What is the unit of analysis for the using data set?

16 . merge 1:1 id using filename in memory in filename.dta master + using = merged result Data Management id age id wgt id age wgt (matched) (matched) (master only) (using only) Potential issues when combining data sets with merge and append The original data in memory are called the master data. The data in filename.dta are called the using data. After merge, the merged result is left in memory. The id variable is called the key variable. Stata jargon is that the datasets were merged on id. What is the unit of analysis for the master data set? What is the unit of analysis for the using data set? Observations for id==1 existed in both the master and using datasets and so were combined in the merged result. The same occurred for id==2. For id==5 and id==4, however, no matches were found and thus each became a separate observation in the merged result. Thus each observation in the merged result came from one of three possible sources: numeric equivalent code word description 1 master originally appeared in master only 2 using originally appeared in using only 3 match originally appeared in both merge encodes this information into new variable in memory in filename.dta master + using = merged result id age id wgt id age wgt _merge merge, which merge adds to the merged result:

17 each observation in each of the datasets. Merge Example #1 A variable or variable list uniquely identifies the observations if each distinct value of th corresponds to one observation in the dataset. In some datasets, multiple variables are required to identify the observations. Imagine d by observing patients at specific points in time so that variables pid and time, taken toget the observations. Below we have two such datasets and run a 1:1 merge on pid and ti. merge 1:1 pid time using filename master + using = merged result pid time x1 pid time x2 pid time x1 x2 _merge This is a 1:1 merge because the combination of the values of pid and time unique observations in both datasets. By default, there is nothing about a 1:1 merge that implies that all, or even any of, the o match. Above five observations matched, one observation was only in the master (subjec 4), and another was only in the using (subject 17 at time 2).

18 each observation in each of the datasets. Merge Example #1 A variable or variable list uniquely identifies the observations if each distinct value of th corresponds to one observation in the dataset. In some datasets, multiple variables are required to identify the observations. Imagine d by observing patients at specific points in time so that variables pid and time, taken toget the observations. Below we have two such datasets and run a 1:1 merge on pid and ti. merge 1:1 pid time using filename master + using = merged result pid time x1 pid time x2 pid time x1 x2 _merge This is a 1:1 merge because the combination of the values of pid and time unique observations This is A-OK! in both datasets. By default, there is nothing about a 1:1 merge that implies that all, or even any of, the o match. Above five observations matched, one observation was only in the master (subjec 4), and another was only in the using (subject 17 at time 2).

19 4), and another was only in the using (subject 17 at time 2). Merge Example #2 :1 merges In an m:1 merge, the key variable or variables uniquely identify the observations in the but not necessarily in the master data. Suppose you had person-level data within regio wished to bring in regional data. Here is an example:. merge m:1 region using filename master + using = merged result id region a region x id region a x _merge To bring in the regional information, we need to merge on region. The values of reg individual observations in the using data, but it is not an identifier in the master data. We show the merged dataset sorted by id because this makes it easier to see how dataset was constructed. For each observation in the master data, merge finds the co observation in the using data. merge combines the values of the variables in the using d

20 4), and another was only in the using (subject 17 at time 2). Merge Example #2 :1 merges In an m:1 merge, the key variable or variables uniquely identify the observations in the but not necessarily in the master data. Suppose you had person-level data within regio wished to bring in regional data. Here is an example:. merge m:1 region using filename master + using = merged result id region a region x id region a x _merge To bring in the regional information, we need to merge on region. The values of reg individual This isobservations A-OK! in the using data, but it is not an identifier in the master data. We show the merged dataset sorted by id because this makes it easier to see how dataset was constructed. For each observation in the master data, merge finds the co observation in the using data. merge combines the values of the variables in the using d

21 merges Merge Example #3 1:m merges are similar to m:1, except that now the key variables identify unique obser the master dataset. Any datasets that can be merged using an m:1 merge may be merge 1:m merge by reversing the roles of the master and using datasets. Here is the same examp previously, with the master and using datasets reversed:. merge 1:m region using filename master + using = merged result region x id region a region x id a _merge This merged result is identical to the merged result in the previous section, except fo order and the contents of merge. This time, we show the merged result sorted by regi than id. Reversing the roles of the files causes a reversal in the 1s and 2s for merge: wher was previously 1, it is now 2, and vice versa. These exchanged merge values reflect th roles of the master and using data.

22 merges Merge Example #3 1:m merges are similar to m:1, except that now the key variables identify unique obser the master dataset. Any datasets that can be merged using an m:1 merge may be merge 1:m merge by reversing the roles of the master and using datasets. Here is the same examp previously, with the master and using datasets reversed:. merge 1:m region using filename master + using = merged result region x id region a region x id a _merge This merged result is identical to the merged result in the previous section, except fo orderdanger! and the contents of merge. This time, we show the merged result sorted by regi than id. Reversing the roles of the files causes a reversal in the 1s and 2s for merge: wher was previously 1, it is now 2, and vice versa. These exchanged merge values reflect th roles of the master and using data.

23 Comparative Manifesto Project

24 Comparative Manifesto Project

25 Data Management

26 Data Management

27 Data Management. isid party ts.. di _N 76.. gen year = year(ts). preserve

28 Data Management. isid party ts.. di _N 76.. gen year = year(ts). preserve. use "C:\Users\williamslaro\Documents\Teaching\UTD\\Stata\Data\PWT.dta", clear.. isid ccode year.. keep ccode year annual_ch_rgdppc.. sort ccode year. tempfile pwt. save `pwt', replace (note: file C:\Users\WILLIA~1\AppData\Local\Temp\ST_ e.tmp not found) file C:\Users\WILLIA~1\AppData\Local\Temp\ST_ e.tmp saved. restore. sort ccode year. merge ccode year using `pwt' (note: you are using old merge syntax; see [D] merge for new syntax) variables ccode year do not uniquely identify observations in the master data (label ccode already defined). drop if _merge == 2 (1424 observations deleted)

29 . isid ccode year. Data Management. keep ccode year annual_ch_rgdppc.. sort ccode year. tempfile pwt. save `pwt', replace (note: file C:\Users\WILLIA~1\AppData\Local\Temp\ST_ e.tmp not found) file C:\Users\WILLIA~1\AppData\Local\Temp\ST_ e.tmp saved. restore. sort ccode year. merge ccode year using `pwt' (note: you are using old merge syntax; see [D] merge for new syntax) variables ccode year do not uniquely identify observations in the master data (label ccode already defined). drop if _merge == 2 (1424 observations deleted). drop _merge

30 . restore Data Management. sort ccode year. merge ccode year using `pwt' (note: you are using old merge syntax; see [D] merge fo variables ccode year do not uniquely identify observati (label ccode already defined). tab _merge _merge Freq. Percent Cum , Total 1, drop if _merge == 2 (1424 observations deleted). drop _merge

31 Data Management

32 Data Management

33 _merge Freq. Percent Data Management , Total 1, drop if _merge == 2 (1424 observations deleted). drop _merge

34 Functions

35 Functions. generate sdp = 1 if party == (59 missing values generated). recode sdp (.=0) (sdp: 59 changes made). tab sdp. drop sdp. generate sdp = cond(party==41320,1,0). tab sdp sdp Freq. Percent Cum Total sdp Freq. Percent Cum Total

36 Functions

37 Functions. list partyname party if ccode == 255 & ts == date("22sep2002","dmy") partyname party. list partyname party if ccode == 255 & ts == date("22sep2002","dmy") /Greens Alliance '90/Greens PDS Party of Democratic Socialism partyname SPD Social Democratic Party party FDP Free Democratic Party /Greens Alliance '90/Greens CDU/CSU Christian Democratic Union/Social Union PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party generate govt = CDU/CSU 1 if inlist(party, Christian Democratic 41113, 41320) Union/Social Union (3 missing values generated). recode govt (.=0). generate govt = 1 if inlist(party, 41113, 41320) (govt: 3 changes made) (3 missing values generated). tab2 party govt. recode govt (.=0) (govt: 3 changes made) -> tabulation of party by govt. tab2 party govt govt party 0 1 Total -> tabulation of party by govt govt party 0 1 Total Total generate left = 1 if inrange(party, 41113, 41320) (2 missing values Total generated) recode left (.=0). generate left = 1 if inrange(party, 41113, 41320) (left: 2 changes made) (2 missing values generated). tab2 party left. recode left (.=0)

38 Functions FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union generate govt = 1 if inlist(party, 41113, 41320) (3 missing values generated). recode govt (.=0) (govt: 3 changes made). list partyname. tab2 party party govt if ccode == 255 & ts == date("22sep2002","dmy") -> tabulation of party by govt partyname party /Greens govt party 0 Alliance 1 '90/Greens Total PDS Party of Democratic Socialism SPD Social Democratic Party FDP 0 Free Democratic 1 Party CDU/CSU Christian Democratic Union/Social Union generate govt = 1 if inlist(party, 41113, 41320) (3 missing values Total generated) recode govt. generate (.=0) left = 1 if inrange(party, 41113, 41320) (govt: 3 changes (2 missing made) values generated). tab2 party. recode govt left (.=0) (left: 2 changes made) -> tabulation of party by govt. tab2 party left govt party -> tabulation 0 of party 1 by left Total left party Total Total generate left = 1 if inrange(party, 41113, 41320) (2 missing values Total generated) recode left (.=0) (left: 2 changes made). tab2 party left

39 Extensions to Generate

40 Extensions to Generate. bys ts: egen govt_seats = total(g * absseat).. list partyname party absseat G govt_seats if ts == date("22sep2002","dmy") partyname party absseat G govt_s /Greens Alliance '90/Greens PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union

41 Extensions to Generate. bys ts: egen govt_seats = total(g * absseat).. list partyname party absseat G govt_seats if ts == date("22sep2002","dmy") partyname party absseat G govt_s~s /Greens Alliance '90/Greens PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union

42 Extensions to Generate. gen govt_seats_share = absseat / govt_seats if G == 1 (43 missing values generated).. bys ts: egen w_govt_rile = total(govt_seats_share * rile).. list partyname party absseat G govt_seats rile w_govt_rile if ts == date("22sep2002" partyname party absseat G govt_s~ /Greens Alliance '90/Greens PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union display (55/306 * ) + (251/306 * )

43 Extensions to Generate. gen govt_seats_share = absseat / govt_seats if G == 1 (43 missing values generated).. bys ts: egen w_govt_rile = total(govt_seats_share * rile).. list partyname party absseat G govt_seats rile w_govt_rile if ts == date("22sep2002","dmy") partyname party absseat G govt_s~s rile w_govt_~e /Greens Alliance '90/Greens PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union display (55/306 * ) + (251/306 * )

44 Extensions to Generate. gen govt_seats_share = absseat / govt_seats if G == 1 (43 missing values generated).. bys ts: egen w_govt_rile = total(govt_seats_share * rile).. list partyname party absseat G govt_seats rile w_govt_rile if ts == date("22sep2002","dmy") partyname party absseat G govt_s~s rile w_govt_~e /Greens Alliance '90/Greens PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union display (55/306 * ) + (251/306 * )

45 Extensions to Generate. bys party: egen party_rile = mean(rile).. list partyname party party_rile if ts == date("22sep2002","dmy") partyname party party_r~e 4. 90/Greens Alliance '90/Greens PDS Party of Democratic Socialism SPD Social Democratic Party FDP Free Democratic Party CDU/CSU Christian Democratic Union/Social Union

46 Extensions to Generate. bys ts: egen leftist_party = min(rile). bys ts: egen rightist_party = max(rile)

47 Extensions to Generate

48 Extensions to Generate. egen intpeace = rowtotal(per102 per105 per106).. list partyname per102 per105 per106 intpeace if ts == date("22sep2002","dmy") partyname per102 per105 per106 intpeace 62. SPD Social Democratic Party /Greens Alliance '90/Greens FDP Free Democratic Party PDS Party of Democratic Socialism CDU/CSU Christian Democratic Union/Social Union

49 Macros. local b1 = display `b1' 4. local b2 = "2 + 2". display "`b2'" 2 + 2

50 Loops

51 Loops

52 Loops. foreach n of numlist 1(1)5 { 2. summarize rile in `n' 3. } Variable Obs Mean Std. Dev. Min rile Variable Obs Mean Std. Dev. Min rile Variable Obs Mean Std. Dev. Min rile

53 Loops. foreach n of numlist 1(1)5 { 2. summarize rile in `n' 3. } Variable Obs Mean Std. Dev. Min Max rile Variable Obs Mean Std. Dev. Min Max rile Variable Obs Mean Std. Dev. Min Max rile Variable Obs Mean Std. Dev. Min Max rile Variable Obs Mean Std. Dev. Min Max rile

54 Loops. foreach k of varlist per102 - welfare { 2. summarize `k' 3. } Variable Obs Mean Std. Dev. Min Max per Variable Obs Mean Std. Dev. Min Max per Variable Obs Mean Std. Dev. Min Max per Variable Obs Mean Std. Dev. Min Max welfare

55 Loops

56 Loop. levelsof party, local(p) > foreach i of local P { 2. display "Party = " `i' 3. summarize rile if party == `i' 4. display _skip(2) 5. } Party = Variable Obs Mean Std. Dev. Min Max Party = rile Variable Obs Mean Std. Dev. Min Max rile

57 Loop. levelsof party, local(p) > foreach i of local P { 2. display "Party = " `i' 3. summarize rile if party == `i' 4. display _skip(2) 5. } Party = Variable Obs Mean Std. Dev. Min Max Party = Variable Obs Mean Std. Dev. Min Max Party = Variable Obs Mean Std. Dev. Min Max Party = rile rile rile Variable Obs Mean Std. Dev. Min Max rile

58 Return List

59 Return List. tabulate party party Freq. Percent Cum Total return list scalars: r(n) = 76 r(r) = 17. display "There are " `r(n)' " observations with " `r(r)' " unique values" There are 76 observations with 17 unique values

60 Return List. regress rile i.party Source SS df MS Number of obs = 76 F( 16, 59) = 6.30 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] party _cons ereturn list

61 Return List _cons ereturn list scalars: macros: e(n) = 76 e(df_m) = 16 e(df_r) = 59 e(f) = e(r2) = e(rmse) = e(mss) = e(rss) = e(r2_a) = e(ll) = e(ll_0) = e(rank) = 17 e(cmdline) : "regress rile i.party" e(title) : "Linear regression" e(marginsok) : "XB default" e(vce) : "ols" e(depvar) : "rile" e(cmd) : "regress" e(properties) : "b V" e(predict) : "regres_p" e(model) : "ols" e(estat_cmd) : "regress_estat" matrices: functions: e(b) : 1 x 18 e(v) : 18 x 18 e(sample)

62 Return List matrices: e(predict) : "regres_p" e(model) : "ols" e(estat_cmd) : "regress_estat" e(b) : 1 x 18 e(v) : 18 x 18 functions: e(sample). display "R Squared = " `e(r2)' R Squared = display "R Squared = " `e(mss)' / (`e(rss)' + `e(mss)') R Squared = summarize rile if e(sample) Variable Obs Mean Std. Dev. Min rile

63 matrices: Return List functions: e(b) : 1 x 18 e(v) : 18 x 18 e(sample). display "R Squared = " `e(r2)' R Squared = display "R Squared = " `e(mss)' / (`e(rss)' + `e(mss)') R Squared = summarize rile if e(sample) Variable Obs Mean Std. Dev. Min Max rile

64 Return List _cons ereturn list scalars: macros: e(n) = 76 e(df_m) = 16 e(df_r) = 59 e(f) = e(r2) = e(rmse) = e(mss) = e(rss) = e(r2_a) = e(ll) = e(ll_0) = e(rank) = 17 e(cmdline) : "regress rile i.party" e(title) : "Linear regression" e(marginsok) : "XB default" e(vce) : "ols" e(depvar) : "rile" e(cmd) : "regress" e(properties) : "b V" e(predict) : "regres_p" e(model) : "ols" e(estat_cmd) : "regress_estat" matrices: functions: e(b) : 1 x 18 e(v) : 18 x 18 e(sample)

65 Return List. `e(cmdline)' Source SS df MS Number of obs = 76 F( 16, 59) = 6.30 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] party _cons

66 Matrices We define matrices with the matrix define command:. matrix define C = (1, 0 \ 0, 1). matrix list C symmetric C[2,2] c1 c2 r1 1 r2 0 1

67 Matrices. regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons matrix list e(b) e(b)[1,2] pervote _cons y matrix b = e(b). matrix list b

68 Matrices. regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons matrix list e(b) e(b)[1,2] pervote _cons y matrix b = e(b). matrix list b b[1,2] pervote _cons

69 Matrices. regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons matrix list e(b) e(b)[1,2] pervote _cons y matrix b = e(b). matrix list b b[1,2] pervote _cons y

70 Matrices y matrix b = e(b). matrix list b b[1,2] pervote _cons y regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons matrix V = e(v). matrix list V symmetric V[2,2] pervote _cons pervote _cons

71 Matrices. regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons display "Coefficient for pervote = " b[1,1] Coefficient for pervote = display "Coefficient for pervote = " _b[pervote] Coefficient for pervote = regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27

72 Matrices. regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons display "Coefficient for pervote = " b[1,1] Coefficient for pervote = display "Coefficient for pervote = " _b[pervote] Coefficient for pervote = regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F =

73 Matrices pervote _cons display "Coefficient for pervote = " b[1,1] Coefficient for pervote = display "Coefficient for pervote = " _b[pervote] Coefficient for pervote = regress rile pervote Source SS df MS Number of obs = 76 F( 1, 74) = 5.27 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote _cons display "Standard error for pervote = " sqrt(v[1,1]) Standard error for pervote = display "Standard error for pervote = " _se[pervote] Standard error for pervote =

74 Matrices. regress rile pervote PM G Source SS df MS Number of obs = 66 F( 3, 62) = 6.52 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote PM G _cons matrix V = e(v). local cols = colsof(v). foreach i of numlist 1(1)`cols' { 2. local se_`i' = sqrt(v[`i',`i']) 3. }. matrix SE = [`se_1',`se_2',`se_3',`se_4']

75 Matrices. regress rile pervote PM G Source SS df MS Number of obs = 66 F( 3, 62) = 6.52 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = rile Coef. Std. Err. t P> t [95% Conf. Interval] pervote PM G _cons matrix V = e(v). local cols = colsof(v). foreach i of numlist 1(1)`cols' { 2. local se_`i' = sqrt(v[`i',`i']) 3. }. matrix SE = [`se_1',`se_2',`se_3',`se_4']. matrix list SE SE[1,4] c1 c2 c3 c4 r matrix SE_t = SE'. matrix list SE_t

76 . matrix V = e(v) Matrices. local cols = colsof(v). foreach i of numlist 1(1)`cols' { 2. local se_`i' = sqrt(v[`i',`i']) 3. }. matrix SE = [`se_1',`se_2',`se_3',`se_4']. matrix list SE SE[1,4] c1 c2 c3 c4 r matrix SE_t = SE'. matrix list SE_t SE_t[4,1] r1 c c c c matrix SE_nocons = SE[1,1..3]. matrix list SE_nocons SE_nocons[1,3]

77 Matrices. local cols = colsof(v). foreach i of numlist 1(1)`cols' { 2. local se_`i' = sqrt(v[`i',`i']) 3. }. matrix SE = [`se_1',`se_2',`se_3',`se_4']. matrix list SE SE[1,4] c1 c2 c3 c4 r matrix SE_t = SE'. matrix list SE_t SE_t[4,1] r1 c c c c matrix SE_nocons = SE[1,1..3]. matrix list SE_nocons SE_nocons[1,3] c1 c2 c3 r

78 Post

79 Post. postfile test ts number min mean max using "Test.dta", replace.. levelsof ts, local(t) foreach i of local T { 2.. quietly tabulate party if ts == `i' 3. local number = r(r) 4.. quietly summarize rile if ts == `i' 5. local min = r(min) 6. local mean = r(mean) 7. local max = r(max) 8.. post test (`i') (`number') (`min') (`mean') (`max') 9. }.. postclose test. preserve. use "Test.dta", clear. format ts %td. list

80 Post 8.. post test (`i') (`number') (`min') (`mean') (`max') 9. }.. postclose test. preserve. use "Test.dta", clear. format ts %td. list ts number min mean max 1. 14aug sep sep sep sep sep nov oct oct mar jan dec oct sep sep sep sep restore

81 0 Density Simulations. clear. set seed drawnorm r, n(1000) (obs 1000). hist r (bin=29, start= , width= ) r

82 0.5 Density Simulations. generate X = runiform(). hist X (bin=29, start= , width= ) X

Lab 2: OLS regression

Lab 2: OLS regression Lab 2: OLS regression Andreas Beger February 2, 2009 1 Overview This lab covers basic OLS regression in Stata, including: multivariate OLS regression reporting coefficients with different confidence intervals

More information

Review of Stata II AERC Training Workshop Nairobi, May 2002

Review of Stata II AERC Training Workshop Nairobi, May 2002 Review of Stata II AERC Training Workshop Nairobi, 20-24 May 2002 This note provides more information on the basics of Stata that should help you with the exercises in the remaining sessions of the workshop.

More information

Lecture 3: The basic of programming- do file and macro

Lecture 3: The basic of programming- do file and macro Introduction to Stata- A. Chevalier Lecture 3: The basic of programming- do file and macro Content of Lecture 3: -Entering and executing programs do file program ado file -macros 1 A] Entering and executing

More information

Further processing of estimation results: Basic programming with matrices

Further processing of estimation results: Basic programming with matrices The Stata Journal (2005) 5, Number 1, pp. 83 91 Further processing of estimation results: Basic programming with matrices Ian Watson ACIRRT, University of Sydney i.watson@econ.usyd.edu.au Abstract. Rather

More information

Stata Session 2. Tarjei Havnes. University of Oslo. Statistics Norway. ECON 4136, UiO, 2012

Stata Session 2. Tarjei Havnes. University of Oslo. Statistics Norway. ECON 4136, UiO, 2012 Stata Session 2 Tarjei Havnes 1 ESOP and Department of Economics University of Oslo 2 Research department Statistics Norway ECON 4136, UiO, 2012 Tarjei Havnes (University of Oslo) Stata Session 2 ECON

More information

Bivariate (Simple) Regression Analysis

Bivariate (Simple) Regression Analysis Revised July 2018 Bivariate (Simple) Regression Analysis This set of notes shows how to use Stata to estimate a simple (two-variable) regression equation. It assumes that you have set Stata up on your

More information

Lecture 4: Programming

Lecture 4: Programming Introduction to Stata- A. chevalier Content of Lecture 4: -looping (while, foreach) -branching (if/else) -Example: the bootstrap - saving results Lecture 4: Programming 1 A] Looping First, make sure you

More information

Week 5: Multiple Linear Regression II

Week 5: Multiple Linear Regression II Week 5: Multiple Linear Regression II Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ARR 1 Outline Adjusted R

More information

25 Working with categorical data and factor variables

25 Working with categorical data and factor variables 25 Working with categorical data and factor variables Contents 25.1 Continuous, categorical, and indicator variables 25.1.1 Converting continuous variables to indicator variables 25.1.2 Converting continuous

More information

/23/2004 TA : Jiyoon Kim. Recitation Note 1

/23/2004 TA : Jiyoon Kim. Recitation Note 1 Recitation Note 1 This is intended to walk you through using STATA in an Athena environment. The computer room of political science dept. has STATA on PC machines. But, knowing how to use it on Athena

More information

Introduction to Stata: An In-class Tutorial

Introduction to Stata: An In-class Tutorial Introduction to Stata: An I. The Basics - Stata is a command-driven statistical software program. In other words, you type in a command, and Stata executes it. You can use the drop-down menus to avoid

More information

THE LINEAR PROBABILITY MODEL: USING LEAST SQUARES TO ESTIMATE A REGRESSION EQUATION WITH A DICHOTOMOUS DEPENDENT VARIABLE

THE LINEAR PROBABILITY MODEL: USING LEAST SQUARES TO ESTIMATE A REGRESSION EQUATION WITH A DICHOTOMOUS DEPENDENT VARIABLE PLS 802 Spring 2018 Professor Jacoby THE LINEAR PROBABILITY MODEL: USING LEAST SQUARES TO ESTIMATE A REGRESSION EQUATION WITH A DICHOTOMOUS DEPENDENT VARIABLE This handout shows the log of a Stata session

More information

SOCY7706: Longitudinal Data Analysis Instructor: Natasha Sarkisian. Panel Data Analysis: Fixed Effects Models

SOCY7706: Longitudinal Data Analysis Instructor: Natasha Sarkisian. Panel Data Analysis: Fixed Effects Models SOCY776: Longitudinal Data Analysis Instructor: Natasha Sarkisian Panel Data Analysis: Fixed Effects Models Fixed effects models are similar to the first difference model we considered for two wave data

More information

Page 1. Notes: MB allocated to data 2. Stata running in batch mode. . do 2-simpower-varests.do. . capture log close. .

Page 1. Notes: MB allocated to data 2. Stata running in batch mode. . do 2-simpower-varests.do. . capture log close. . tm / / / / / / / / / / / / 101 Copyright 1984-2009 Statistics/Data Analysis StataCorp 4905 Lakeway Drive College Station, Texas 77845 USA 800-STATA-PC http://wwwstatacom 979-696-4600 stata@statacom 979-696-4601

More information

schooling.log 7/5/2006

schooling.log 7/5/2006 ----------------------------------- log: C:\dnb\schooling.log log type: text opened on: 5 Jul 2006, 09:03:57. /* schooling.log */ > use schooling;. gen age2=age76^2;. /* OLS (inconsistent) */ > reg lwage76

More information

Week 11: Interpretation plus

Week 11: Interpretation plus Week 11: Interpretation plus Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ARR 1 Outline A bit of a patchwork

More information

Creating LaTeX and HTML documents from within Stata using texdoc and webdoc. Example 2

Creating LaTeX and HTML documents from within Stata using texdoc and webdoc. Example 2 Creating LaTeX and HTML documents from within Stata using texdoc and webdoc Contents Example 2 Ben Jann University of Bern, benjann@sozunibech Nordic and Baltic Stata Users Group meeting Oslo, September

More information

Week 1: Introduction to Stata

Week 1: Introduction to Stata Week 1: Introduction to Stata Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ALL RIGHTS RESERVED 1 Outline Log

More information

texdoc 2.0 An update on creating LaTeX documents from within Stata Example 2

texdoc 2.0 An update on creating LaTeX documents from within Stata Example 2 texdoc 20 An update on creating LaTeX documents from within Stata Contents Example 2 Ben Jann University of Bern, benjann@sozunibech 2016 German Stata Users Group Meeting GESIS, Cologne, June 10, 2016

More information

range: [1,20] units: 1 unique values: 20 missing.: 0/20 percentiles: 10% 25% 50% 75% 90%

range: [1,20] units: 1 unique values: 20 missing.: 0/20 percentiles: 10% 25% 50% 75% 90% ------------------ log: \Term 2\Lecture_2s\regression1a.log log type: text opened on: 22 Feb 2008, 03:29:09. cmdlog using " \Term 2\Lecture_2s\regression1a.do" (cmdlog \Term 2\Lecture_2s\regression1a.do

More information

Introduction to Stata - Session 2

Introduction to Stata - Session 2 Introduction to Stata - Session 2 Siv-Elisabeth Skjelbred ECON 3150/4150, UiO January 26, 2016 1 / 29 Before we start Download auto.dta, auto.csv from course home page and save to your stata course folder.

More information

Week 4: Simple Linear Regression II

Week 4: Simple Linear Regression II Week 4: Simple Linear Regression II Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ARR 1 Outline Algebraic properties

More information

Week 4: Simple Linear Regression III

Week 4: Simple Linear Regression III Week 4: Simple Linear Regression III Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ARR 1 Outline Goodness of

More information

Linear regression Number of obs = 6,866 F(16, 326) = Prob > F = R-squared = Root MSE =

Linear regression Number of obs = 6,866 F(16, 326) = Prob > F = R-squared = Root MSE = - /*** To demonstrate use of 2SLS ***/ * Case: In the early 1990's Tanzania implemented a FP program to reduce fertility, which was among the highest in the world * The FP program had two main components:

More information

Week 10: Heteroskedasticity II

Week 10: Heteroskedasticity II Week 10: Heteroskedasticity II Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ARR 1 Outline Dealing with heteroskedasticy

More information

Introduction to STATA 6.0 ECONOMICS 626

Introduction to STATA 6.0 ECONOMICS 626 Introduction to STATA 6.0 ECONOMICS 626 Bill Evans Fall 2001 This handout gives a very brief introduction to STATA 6.0 on the Economics Department Network. In a few short years, STATA has become one of

More information

Title. Description. Quick start. stata.com. misstable Tabulate missing values

Title. Description. Quick start. stata.com. misstable Tabulate missing values Title stata.com misstable Tabulate missing values Description Quick start Menu Syntax Options Remarks and examples Stored results Also see Description misstable makes tables that help you understand the

More information

Thanks to Petia Petrova and Vince Wiggins for their comments on this draft.

Thanks to Petia Petrova and Vince Wiggins for their comments on this draft. Intermediate Stata Christopher F Baum Faculty Micro Resource Center Academic Technology Services, Boston College August 2004 baum@bc.edu http://fmwww.bc.edu/gstat/docs/statainter.pdf Thanks to Petia Petrova

More information

A quick introduction to STATA

A quick introduction to STATA A quick introduction to STATA Data files and other resources for the course book Introduction to Econometrics by Stock and Watson is available on: http://wps.aw.com/aw_stock_ie_3/178/45691/11696965.cw/index.html

More information

Data analysis using Stata , AMSE Master (M1), Spring semester

Data analysis using Stata , AMSE Master (M1), Spring semester Data analysis using Stata 2016-2017, AMSE Master (M1), Spring semester Notes Marc Sangnier Data analysis using Stata Virtually infinite number of tasks for data analysis. Almost infinite number of commands

More information

STATA TUTORIAL B. Rabin with modifications by T. Marsh

STATA TUTORIAL B. Rabin with modifications by T. Marsh STATA TUTORIAL B. Rabin with modifications by T. Marsh 5.2.05 (content also from http://www.ats.ucla.edu/stat/spss/faq/compare_packages.htm) Why choose Stata? Stata has a wide array of pre-defined statistical

More information

. predict mod1. graph mod1 ed, connect(l) xlabel ylabel l1(model1 predicted income) b1(years of education)

. predict mod1. graph mod1 ed, connect(l) xlabel ylabel l1(model1 predicted income) b1(years of education) DUMMY VARIABLES AND INTERACTIONS Let's start with an example in which we are interested in discrimination in income. We have a dataset that includes information for about 16 people on their income, their

More information

Results Based Financing for Health Impact Evaluation Workshop Tunis, Tunisia October Stata 2. Willa Friedman

Results Based Financing for Health Impact Evaluation Workshop Tunis, Tunisia October Stata 2. Willa Friedman Results Based Financing for Health Impact Evaluation Workshop Tunis, Tunisia October 2010 Stata 2 Willa Friedman Outline of Presentation Importing data from other sources IDs Merging and Appending multiple

More information

Community Resource: Egenmore, by command, return lists, and system variables. Beksahn Jang Feb 22 nd, 2016 SOC561

Community Resource: Egenmore, by command, return lists, and system variables. Beksahn Jang Feb 22 nd, 2016 SOC561 Community Resource: Egenmore, by command, return lists, and system variables. Beksahn Jang Feb 22 nd, 2016 SOC561 Egenmore Egenmore is a package in Stata that extends the capabilities of the egen command.

More information

DOCUMENTATION FOR THE ESTIMATION 3D RANDOM EFFECTS PANEL DATA ESTIMATION PROGRAMS

DOCUMENTATION FOR THE ESTIMATION 3D RANDOM EFFECTS PANEL DATA ESTIMATION PROGRAMS DOCUMENTATION FOR THE ESTIMATION 3D RANDOM EFFECTS PANEL DATA ESTIMATION PROGRAMS All algorithms stored in separate do files. Usage is to first run the full.do file in Stata, then run the desired estimations

More information

Panel Data 4: Fixed Effects vs Random Effects Models

Panel Data 4: Fixed Effects vs Random Effects Models Panel Data 4: Fixed Effects vs Random Effects Models Richard Williams, University of Notre Dame, http://www3.nd.edu/~rwilliam/ Last revised April 4, 2017 These notes borrow very heavily, sometimes verbatim,

More information

Stata versions 12 & 13 Week 4 Practice Problems

Stata versions 12 & 13 Week 4 Practice Problems Stata versions 12 & 13 Week 4 Practice Problems SOLUTIONS 1 Practice Screen Capture a Create a word document Name it using the convention lastname_lab1docx (eg bigelow_lab1docx) b Using your browser, go

More information

piecewise ginireg 1 Piecewise Gini Regressions in Stata Jan Ditzen 1 Shlomo Yitzhaki 2 September 8, 2017

piecewise ginireg 1 Piecewise Gini Regressions in Stata Jan Ditzen 1 Shlomo Yitzhaki 2 September 8, 2017 piecewise ginireg 1 Piecewise Gini Regressions in Stata Jan Ditzen 1 Shlomo Yitzhaki 2 1 Heriot-Watt University, Edinburgh, UK Center for Energy Economics Research and Policy (CEERP) 2 The Hebrew University

More information

Dr. Barbara Morgan Quantitative Methods

Dr. Barbara Morgan Quantitative Methods Dr. Barbara Morgan Quantitative Methods 195.650 Basic Stata This is a brief guide to using the most basic operations in Stata. Stata also has an on-line tutorial. At the initial prompt type tutorial. In

More information

Week 9: Modeling II. Marcelo Coca Perraillon. Health Services Research Methods I HSMP University of Colorado Anschutz Medical Campus

Week 9: Modeling II. Marcelo Coca Perraillon. Health Services Research Methods I HSMP University of Colorado Anschutz Medical Campus Week 9: Modeling II Marcelo Coca Perraillon University of Colorado Anschutz Medical Campus Health Services Research Methods I HSMP 7607 2017 c 2017 PERRAILLON ARR 1 Outline Taking the log Retransformation

More information

Getting Started Using Stata

Getting Started Using Stata Categorical Data Analysis Getting Started Using Stata Scott Long and Shawna Rohrman cda12 StataGettingStarted 2012 05 11.docx Getting Started in Stata Opening Stata When you open Stata, the screen has

More information

PubHlth 640 Intermediate Biostatistics Unit 2 - Regression and Correlation. Simple Linear Regression Software: Stata v 10.1

PubHlth 640 Intermediate Biostatistics Unit 2 - Regression and Correlation. Simple Linear Regression Software: Stata v 10.1 PubHlth 640 Intermediate Biostatistics Unit 2 - Regression and Correlation Simple Linear Regression Software: Stata v 10.1 Emergency Calls to the New York Auto Club Source: Chatterjee, S; Handcock MS and

More information

ECON Introductory Econometrics Seminar 4

ECON Introductory Econometrics Seminar 4 ECON4150 - Introductory Econometrics Seminar 4 Stock and Watson EE8.2 April 28, 2015 Stock and Watson EE8.2 ECON4150 - Introductory Econometrics Seminar 4 April 28, 2015 1 / 20 Current Population Survey

More information

Data Management 2. 1 Introduction. 2 Do-files. 2.1 Ado-files and Do-files

Data Management 2. 1 Introduction. 2 Do-files. 2.1 Ado-files and Do-files University of California, Santa Cruz Department of Economics ECON 294A (Fall 2014)- Stata Lab Instructor: Manuel Barron 1 Data Management 2 1 Introduction Today we are going to introduce the use of do-files,

More information

Stata 10/11 Tutorial 1

Stata 10/11 Tutorial 1 Stata 1/11 Tutorial 1 TOPIC: Estimation and Hypothesis Testing in Linear Regression Models: A Review DATA: auto1.raw and auto1.txt auto1.dta (two text-format (ASCII) data files) (a Stata-format dataset)

More information

An Introductory Guide to Stata

An Introductory Guide to Stata An Introductory Guide to Stata Scott L. Minkoff Assistant Professor Department of Political Science Barnard College sminkoff@barnard.edu Updated: July 9, 2012 1 TABLE OF CONTENTS ABOUT THIS GUIDE... 4

More information

1 Introducing Stata sample session

1 Introducing Stata sample session 1 Introducing Stata sample session Introducing Stata This chapter will run through a sample work session, introducing you to a few of the basic tasks that can be done in Stata, such as opening a dataset,

More information

Lecture 2: Advanced data manipulation

Lecture 2: Advanced data manipulation Introduction to Stata- A. Chevalier Content of Lecture 2: Lecture 2: Advanced data manipulation -creating data -using dates -merging and appending datasets - wide and long -collapse 1 A] Creating data

More information

Getting Started Using Stata

Getting Started Using Stata Quant II 2011: Categorical Data Analysis Getting Started Using Stata Shawna Rohrman 2010 05 09 Revised by Trisha Tiamzon 2010 12 26 Note: Parts of this guide were adapted from Stata s Getting Started with

More information

Introduction to Stata Session 3

Introduction to Stata Session 3 Introduction to Stata Session 3 Tarjei Havnes 1 ESOP and Department of Economics University of Oslo 2 Research department Statistics Norway ECON 3150/4150, UiO, 2015 Before we start 1. In your folder statacourse:

More information

Subject index. ASCII data, reading comma-separated fixed column multiple lines per observation

Subject index. ASCII data, reading comma-separated fixed column multiple lines per observation Subject index Symbols %fmt... 106 110 * abbreviation character... 374 377 * comment indicator...346 + combining strings... 124 125 - abbreviation character... 374 377.,.a,.b,...,.z missing values.. 130

More information

Ninth ARTNeT Capacity Building Workshop for Trade Research "Trade Flows and Trade Policy Analysis"

Ninth ARTNeT Capacity Building Workshop for Trade Research Trade Flows and Trade Policy Analysis Ninth ARTNeT Capacity Building Workshop for Trade Research "Trade Flows and Trade Policy Analysis" June 2013 Bangkok, Thailand Cosimo Beverelli and Rainer Lanz (World Trade Organization) 1 Introduction

More information

Introduction to Hierarchical Linear Model. Hsueh-Sheng Wu CFDR Workshop Series January 30, 2017

Introduction to Hierarchical Linear Model. Hsueh-Sheng Wu CFDR Workshop Series January 30, 2017 Introduction to Hierarchical Linear Model Hsueh-Sheng Wu CFDR Workshop Series January 30, 2017 1 Outline What is Hierarchical Linear Model? Why do nested data create analytic problems? Graphic presentation

More information

Empirical Asset Pricing

Empirical Asset Pricing Department of Mathematics and Statistics, University of Vaasa, Finland Texas A&M University, May June, 2013 As of May 17, 2013 Part I Stata Introduction 1 Stata Introduction Interface Commands Command

More information

A quick introduction to STATA:

A quick introduction to STATA: 1 Revised September 2008 A quick introduction to STATA: (by E. Bernhardsen, with additions by H. Goldstein) 1. How to access STATA from the pc s at the computer lab After having logged in you have to log

More information

Recoding and Labeling Variables

Recoding and Labeling Variables Updated July 2018 Recoding and Labeling Variables This set of notes describes how to use the computer program Stata to recode variables and save them as new variables as well as how to label variables.

More information

Stata Training. AGRODEP Technical Note 08. April Manuel Barron and Pia Basurto

Stata Training. AGRODEP Technical Note 08. April Manuel Barron and Pia Basurto AGRODEP Technical Note 08 April 2013 Stata Training Manuel Barron and Pia Basurto AGRODEP Technical Notes are designed to document state-of-the-art tools and methods. They are circulated in order to help

More information

Reproducible Research: Weaving with Stata

Reproducible Research: Weaving with Stata StataCorp LP Italian Stata Users Group Meeting October, 2008 Outline I Introduction 1 Introduction Goals Reproducible Research and Weaving 2 3 What We ve Seen Goals Reproducible Research and Weaving Goals

More information

Introduction to STATA

Introduction to STATA Center for Teaching, Research and Learning Research Support Group American University, Washington, D.C. Hurst Hall 203 rsg@american.edu (202) 885-3862 Introduction to STATA WORKSHOP OBJECTIVE: This workshop

More information

Title. Syntax. stata.com. intreg Interval regression. weight. indepvars. intreg depvar 1 depvar 2. , options. Description. options

Title. Syntax. stata.com. intreg Interval regression. weight. indepvars. intreg depvar 1 depvar 2. , options. Description. options Title stata.com intreg Interval regression Syntax Menu Description Options Remarks and examples Stored results Methods and formulas References Also see Syntax intreg depvar 1 depvar 2 [ indepvars ] [ if

More information

Saving Time with Prudent Data Management. Basic Principles To Save Time. Introducing Our Data. Yearly Directed Dyads (Multiple Panel Data)

Saving Time with Prudent Data Management. Basic Principles To Save Time. Introducing Our Data. Yearly Directed Dyads (Multiple Panel Data) Saving Time with Prudent Data Management Brandon Bartels & Kevin Sweeney Program In Statistics and Methodology Outline Some Basic Principles Introducing the Data (Dyad-Years) Common Tasks Sorting Generating

More information

ECON Stata course, 3rd session

ECON Stata course, 3rd session ECON4150 - Stata course, 3rd session Andrea Papini Heavily based on last year s session by Tarjei Havnes February 4, 2016 Stata course, 3rd session February 4, 2016 1 / 19 Before we start 1. Download caschool.dta

More information

Instrumental variables, bootstrapping, and generalized linear models

Instrumental variables, bootstrapping, and generalized linear models The Stata Journal (2003) 3, Number 4, pp. 351 360 Instrumental variables, bootstrapping, and generalized linear models James W. Hardin Arnold School of Public Health University of South Carolina Columbia,

More information

Introduction to Stata - Session 1

Introduction to Stata - Session 1 Introduction to Stata - Session 1 Simon, Hong based on Andrea Papini ECON 3150/4150, UiO January 15, 2018 1 / 33 Preparation Before we start Sit in teams of two Download the file auto.dta from the course

More information

MODULE ONE, PART THREE: READING DATA INTO STATA, CREATING AND RECODING VARIABLES, AND ESTIMATING AND TESTING MODELS IN STATA

MODULE ONE, PART THREE: READING DATA INTO STATA, CREATING AND RECODING VARIABLES, AND ESTIMATING AND TESTING MODELS IN STATA MODULE ONE, PART THREE: READING DATA INTO STATA, CREATING AND RECODING VARIABLES, AND ESTIMATING AND TESTING MODELS IN STATA This Part Three of Module One provides a cookbook-type demonstration of the

More information

BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA

BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA Learning objectives: Getting data ready for analysis: 1) Learn several methods of exploring the

More information

Getting started with Stata 2017: Cheat-sheet

Getting started with Stata 2017: Cheat-sheet Getting started with Stata 2017: Cheat-sheet 4. september 2017 1 Get started Graphical user interface (GUI). Clickable. Simple. Commands. Allows for use of do-le. Easy to keep track. Command window: Write

More information

A Short Introduction to STATA

A Short Introduction to STATA A Short Introduction to STATA 1) Introduction: This session serves to link everyone from theoretical equations to tangible results under the amazing promise of Stata! Stata is a statistical package that

More information

Source:

Source: Time Series Source: http://www.princeton.edu/~otorres/stata/ Time series data is data collected over time for a single or a group of variables. Date variable For this kind of data the first thing to do

More information

Missing Data Part II: Multiple Imputation Richard Williams, University of Notre Dame, https://www3.nd.edu/~rwilliam/ Last revised January 24, 2015

Missing Data Part II: Multiple Imputation Richard Williams, University of Notre Dame, https://www3.nd.edu/~rwilliam/ Last revised January 24, 2015 Missing Data Part II: Multiple Imputation Richard Williams, University of Notre Dame, https://www3.nd.edu/~rwilliam/ Last revised January 24, 2015 Warning: I teach about Multiple Imputation with some trepidation.

More information

Econ Stata Tutorial I: Reading, Organizing and Describing Data. Sanjaya DeSilva

Econ Stata Tutorial I: Reading, Organizing and Describing Data. Sanjaya DeSilva Econ 329 - Stata Tutorial I: Reading, Organizing and Describing Data Sanjaya DeSilva September 8, 2008 1 Basics When you open Stata, you will see four windows. 1. The Results window list all the commands

More information

Instruction on JMP IN of Chapter 19

Instruction on JMP IN of Chapter 19 Instruction on JMP IN of Chapter 19 Example 19.2 (1). Download the dataset xm19-02.jmp from the website for this course and open it. (2). Go to the Analyze menu and select Fit Model. Click on "REVENUE"

More information

Compute MI estimates of coefficients by fitting estimation command to mi data

Compute MI estimates of coefficients by fitting estimation command to mi data Title mi estimate Estimation using multiple imputations Syntax Compute MI estimates of coefficients by fitting estimation command to mi data mi estimate [, options ] : estimation command... Compute MI

More information

CH5: CORR & SIMPLE LINEAR REFRESSION =======================================

CH5: CORR & SIMPLE LINEAR REFRESSION ======================================= STAT 430 SAS Examples SAS5 ===================== ssh xyz@glue.umd.edu, tap sas913 (old sas82), sas https://www.statlab.umd.edu/sasdoc/sashtml/onldoc.htm CH5: CORR & SIMPLE LINEAR REFRESSION =======================================

More information

Detailed Explanation of Stata Code for a Marginal Effect Plot for X

Detailed Explanation of Stata Code for a Marginal Effect Plot for X Detailed Explanation of Stata Code for a Marginal Effect Plot for X Below, I go through the Stata code for creating the equivalent of a marginal effect plot for X from a probit model with an interaction

More information

Heteroskedasticity and Homoskedasticity, and Homoskedasticity-Only Standard Errors

Heteroskedasticity and Homoskedasticity, and Homoskedasticity-Only Standard Errors Heteroskedasticity and Homoskedasticity, and Homoskedasticity-Only Standard Errors (Section 5.4) What? Consequences of homoskedasticity Implication for computing standard errors What do these two terms

More information

Programming MLE models in STATA 1

Programming MLE models in STATA 1 Programming MLE models in STATA 1 Andreas Beger 30 November 2008 1 Overview You have learned about a lot of different MLE models so far, and most of them are available as pre-defined commands in STATA.

More information

A quick introduction to STATA:

A quick introduction to STATA: 1 HG Revised September 2011 A quick introduction to STATA: (by E. Bernhardsen, with additions by H. Goldstein) 1. How to access STATA from the pc s at the computer lab and elsewhere at UiO. At the computer

More information

Title. Description. Quick start. stata.com. label Manipulate labels

Title. Description. Quick start. stata.com. label Manipulate labels Title stata.com label Manipulate labels Description Quick start Menu Syntax Options Remarks and examples Stored results References Also see Description label data attaches a label (up to 80 characters)

More information

After opening Stata for the first time: set scheme s1mono, permanently

After opening Stata for the first time: set scheme s1mono, permanently Stata 13 HELP Getting help Type help command (e.g., help regress). If you don't know the command name, type lookup topic (e.g., lookup regression). Email: tech-support@stata.com. Put your Stata serial

More information

Description Syntax Remarks and examples Diagnostics References Also see

Description Syntax Remarks and examples Diagnostics References Also see Title stata.com docx*( ) Generate Office Open XML (.docx) file Description Syntax Remarks and examples Diagnostics References Also see Description docx*() provides a set of Mata functions to generate Office

More information

Box-Cox Transformation for Simple Linear Regression

Box-Cox Transformation for Simple Linear Regression Chapter 192 Box-Cox Transformation for Simple Linear Regression Introduction This procedure finds the appropriate Box-Cox power transformation (1964) for a dataset containing a pair of variables that are

More information

Programming and Post-Estimation

Programming and Post-Estimation Programming and Post-Estimation Bootstrapping Monte Carlo Post-Estimation Simulation (Clarify) Extending Clarify to Other Models Censored Probit Example What is Bootstrapping? A computer-simulated nonparametric

More information

Empirical trade analysis

Empirical trade analysis Empirical trade analysis Introduction to Stata Cosimo Beverelli World Trade Organization Cosimo Beverelli Stata introduction Bangkok, 18-21 Dec 2017 1 / 23 Outline 1 Resources 2 How Stata looks like 3

More information

A Short Guide to Stata 10 for Windows

A Short Guide to Stata 10 for Windows A Short Guide to Stata 10 for Windows 1. Introduction 2 2. The Stata Environment 2 3. Where to get help 2 4. Opening and Saving Data 3 5. Importing Data 4 6. Data Manipulation 5 7. Descriptive Statistics

More information

Repeated Measures Part 4: Blood Flow data

Repeated Measures Part 4: Blood Flow data Repeated Measures Part 4: Blood Flow data /* bloodflow.sas */ options linesize=79 pagesize=100 noovp formdlim='_'; title 'Two within-subjecs factors: Blood flow data (NWK p. 1181)'; proc format; value

More information

Intermediate Stata. Jeremy Craig Green. 1 March /29/2011 1

Intermediate Stata. Jeremy Craig Green. 1 March /29/2011 1 Intermediate Stata Jeremy Craig Green 1 March 2011 3/29/2011 1 Advantages of Stata Ubiquitous in economics and political science Gaining popularity in health sciences Large library of add-on modules Version

More information

Research Support. Processing Results in Stata

Research Support. Processing Results in Stata Most Stata functions (such as reg) display their results in the Stata results window. Sometimes this is not quite sufficient: we might want to either preserve some of the output and use it in future computations,

More information

Introduction to Stata Toy Program #1 Basic Descriptives

Introduction to Stata Toy Program #1 Basic Descriptives Introduction to Stata 2018-19 Toy Program #1 Basic Descriptives Summary The goal of this toy program is to get you in and out of a Stata session and, along the way, produce some descriptive statistics.

More information

Soci Statistics for Sociologists

Soci Statistics for Sociologists University of North Carolina Chapel Hill Soci708-001 Statistics for Sociologists Fall 2009 Professor François Nielsen Stata Commands for Module 7 Inference for Distributions For further information on

More information

International Graduate School of Genetic and Molecular Epidemiology (GAME) Computing Notes and Introduction to Stata

International Graduate School of Genetic and Molecular Epidemiology (GAME) Computing Notes and Introduction to Stata International Graduate School of Genetic and Molecular Epidemiology (GAME) Computing Notes and Introduction to Stata Paul Dickman September 2003 1 A brief introduction to Stata Starting the Stata program

More information

Introduction to Stata. Getting Started. This is the simple command syntax in Stata and more conditions can be added as shown in the examples.

Introduction to Stata. Getting Started. This is the simple command syntax in Stata and more conditions can be added as shown in the examples. Getting Started Command Syntax command varlist, option This is the simple command syntax in Stata and more conditions can be added as shown in the examples. Preamble mkdir tutorial /* to create a new directory,

More information

Computing Murphy Topel-corrected variances in a heckprobit model with endogeneity

Computing Murphy Topel-corrected variances in a heckprobit model with endogeneity The Stata Journal (2010) 10, Number 2, pp. 252 258 Computing Murphy Topel-corrected variances in a heckprobit model with endogeneity Juan Muro Department of Statistics, Economic Structure, and International

More information

A Quick Guide to Stata 8 for Windows

A Quick Guide to Stata 8 for Windows Université de Lausanne, HEC Applied Econometrics II Kurt Schmidheiny October 22, 2003 A Quick Guide to Stata 8 for Windows 2 1 Introduction A Quick Guide to Stata 8 for Windows This guide introduces the

More information

Introduction to STATA

Introduction to STATA Introduction to STATA Duah Dwomoh, MPhil School of Public Health, University of Ghana, Accra July 2016 International Workshop on Impact Evaluation of Population, Health and Nutrition Programs Learning

More information

Appendix II: STATA Preliminary

Appendix II: STATA Preliminary Appendix II: STATA Preliminary STATA is a statistical software package that offers a large number of statistical and econometric estimation procedures. With STATA we can easily manage data and apply standard

More information

Use data on individual respondents from the first 17 waves of the British Household

Use data on individual respondents from the first 17 waves of the British Household Applications of Data Analysis (EC969) Simonetta Longhi and Alita Nandi (ISER) Contact: slonghi and anandi; @essex.ac.uk Week 1 Lecture 2: Data Management Use data on individual respondents from the first

More information

Advanced Stata Skills

Advanced Stata Skills Advanced Stata Skills Contents Stata output in Excel & Word... 2 Copy as Table... 2 putexcel... 2 tabout (v3)... 2 estout / esttab... 2 Common Options... 2 Nice Looking Tables in Stata... 3 Descriptive

More information

Why should you become a Stata programmer?

Why should you become a Stata programmer? Why should you become a Stata programmer? Christopher F Baum Boston College and DIW Berlin January 2009 Christopher F Baum (BC & DIW Berlin) Why become a Stata programmer? 1 / 52 Introduction Should you

More information

ECONOMICS 452* -- Stata 12 Tutorial 1. Stata 12 Tutorial 1. TOPIC: Getting Started with Stata: An Introduction or Review

ECONOMICS 452* -- Stata 12 Tutorial 1. Stata 12 Tutorial 1. TOPIC: Getting Started with Stata: An Introduction or Review Stata 12 Tutorial 1 TOPIC: Getting Started with Stata: An Introduction or Review DATA: auto1.raw and auto1.txt (two text-format data files) TASKS: Stata 12 Tutorial 1 is intended to introduce you to some

More information