--------------------------------------------------------------------------------
name: <unnamed>
log: C:\Users\Michael\Documents\newer web pages\soc_meth_proj3\soc_180B_
> win2013\class10.log
log type: text
opened on: 12 Feb 2013, 13:30:36
. *class starts here
. *(8 variables, 11 observations pasted into data editor)
* Import the data from the Anscombe Excel file on my website, and copy in Stata’s data editor (with first row as variable names)
. twoway (scatter y2 x2) (lfit y2 x2)
. regress y2 x2
Source | SS df MS Number of obs = 11
-------------+------------------------------ F( 1, 9) = 17.97
Model | 27.5000024 1 27.5000024 Prob > F = 0.0022
Residual | 13.776294 9 1.53069933 R-squared = 0.6662
-------------+------------------------------ Adj R-squared = 0.6292
Total | 41.2762964 10 4.12762964 Root MSE = 1.2372
------------------------------------------------------------------------------
y2 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x2 | .5 .1179638 4.24 0.002 .2331475 .7668526
_cons | 3.000909 1.125303 2.67 0.026 .4552978 5.54652
------------------------------------------------------------------------------
. regress y1 x1
Source | SS df MS Number of obs = 11
-------------+------------------------------ F( 1, 9) = 17.99
Model | 27.5100011 1 27.5100011 Prob > F = 0.0022
Residual | 13.7626904 9 1.52918783 R-squared = 0.6665
-------------+------------------------------ Adj R-squared = 0.6295
Total | 41.2726916 10 4.12726916 Root MSE = 1.2366
------------------------------------------------------------------------------
y1 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 | .5000909 .1179055 4.24 0.002 .2333701 .7668117
_cons | 3.000091 1.124747 2.67 0.026 .4557369 5.544445
------------------------------------------------------------------------------
. regress y2 x2
Source | SS df MS Number of obs = 11
-------------+------------------------------ F( 1, 9) = 17.97
Model | 27.5000024 1 27.5000024 Prob > F = 0.0022
Residual | 13.776294 9 1.53069933 R-squared = 0.6662
-------------+------------------------------ Adj R-squared = 0.6292
Total | 41.2762964 10 4.12762964 Root MSE = 1.2372
------------------------------------------------------------------------------
y2 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x2 | .5 .1179638 4.24 0.002 .2331475 .7668526
_cons | 3.000909 1.125303 2.67 0.026 .4552978 5.54652
------------------------------------------------------------------------------
. predict m2
(option xb assumed; fitted values)
* The predict command generates a new variable that has the predicted values for the model, for each X, Y_predicted=3+(0.5)X.
. gen resid_m2=y2-m2
* a new variable for the residuals, that is the difference between the actual Y and the predicted Y.
. twoway (scatter resid_m2 x2) (line m2 x2) (scatter y2 x2) (lfit y2 x2)
. gen abs_resid_m2=abs( resid_m2)
. gsort - abs_resid_m2
. list x2 y2 resid_m2 abs_resid_m2 if _n<4
+----------------------------------+
| x2 y2 resid_m2 abs_re~2 |
|----------------------------------|
1. | 14 8.1 -1.900909 1.900909 |
2. | 4 3.1 -1.900909 1.900909 |
3. | 9 8.77 1.269091 1.269091 |
|
* The above 3 commands create a new variable with absolute value residuals, then sort the data from largest to smallest, then list the first 3 (i.e. the biggest 3 residuals in absolute value).
. clear all
. use "C:\Users\Michael\Desktop\cps_mar_2000_new_unchanged.dta", clear
* How to generate the dummy variable for Vietnam veterans.
. codebook vetlast
--------------------------------------------------------------------------------
vetlast Veteran's most recent period of service
--------------------------------------------------------------------------------
type: numeric (byte)
label: vetlastlbl
range: [0,9] units: 1
unique values: 6 missing .: 0/133710
tabulation: Freq. Numeric Label
30904 0 NIU
91149 1 No service
2428 4 World War II
1716 6 Korean War
3683 8 Vietnam Era
3830 9 Other service
. gen viet_veteran=0
. replace viet_veteran=1 if vetlast==8
(3683 real changes made)
. tabulate vetlast viet_veteran, miss
Veteran's most recent | viet_veteran
period of service | 0 1 | Total
----------------------+----------------------+----------
NIU | 30,904 0 | 30,904
No service | 91,149 0 | 91,149
World War II | 2,428 0 | 2,428
Korean War | 1,716 0 | 1,716
Vietnam Era | 0 3,683 | 3,683
Other service | 3,830 0 | 3,830
----------------------+----------------------+----------
Total | 130,027 3,683 | 133,710
. log close
name: <unnamed>
log: C:\Users\Michael\Documents\newer web pages\soc_meth_proj3\soc_180B_
> win2013\class10.log
log type: text
closed on: 12 Feb 2013, 16:18:17
--------------------------------------------------------------------------------