-----------------------------------------------------------------------------------------------------

name:  <unnamed>

log type:  text

opened on:  26 Sep 2018, 10:06:31

. use "C:\Users\mexmi\Documents\newer web pages\soc_meth_proj3\cps_mar_2000_new.dta", clear

. *class starts here

. ttest yrsed if age>=25 & age<=34, by(sex)

Two-sample t test with equal variances

------------------------------------------------------------------------------

Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]

---------+--------------------------------------------------------------------

Male |    9027    13.31212    .0312351    2.967666    13.25089    13.37335

Female |    9511    13.55657    .0292693    2.854472    13.49919    13.61394

---------+--------------------------------------------------------------------

combined |   18538    13.43753    .0213921    2.912627     13.3956    13.47946

---------+--------------------------------------------------------------------

diff |           -.2444469    .0427623               -.3282649   -.1606289

------------------------------------------------------------------------------

diff = mean(Male) - mean(Female)                              t =  -5.7164

Ho: diff = 0                                     degrees of freedom =    18536

Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0

Pr(T < t) = 0.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 1.0000

·        When we left off last class, we had done a T-test on the difference between men and women’s educational attainment. The t-test came up with a statistic of -5.7, and a P value of 0.0000. What does this mean? Let’s get a more accurate P value.

. display 1- ttail(18536, -5.7164)

5.524e-09

. display  ttail(18536, 5.7164)

5.524e-09

. display  2*ttail(18536, 5.7164)

1.105e-08

·        This above is the two-tailed P value for this T-test, 1 in 100 million. That means that if men’s and women’s educations were actually the same in the US as a whole, we would have expected to see a difference this big (0.244 years) in a sample this size in either direction once in a hundred million trials. Since that P value is small, we reject the null hypothesis of no difference, and recognize that women in the US had more education than men.

. summarize incwelfr

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |    103226    40.62242    478.8231          0      25000

·        What does it mean to say that average welfare income (within the CPS sample) is \$40. It means that most people get zero welfare income.

. summarize incwelfr if age>=15 & incwelfr>0 & incwelfr~=.

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |      1289    3253.134    2813.505          1      25000

. summarize incwelfr if age>=15 & incwelfr>0 & incwelfr~=. [fweight= perwt_rounded]

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |   2551246    3072.095    2803.442          1      25000

·        For the whole US, there were 2.5 million welfare recipients in 1999, and an average welfare income of \$3000 for the year.

. summarize incwelfr if incwelfr>0 & incwelfr~=. [fweight= perwt_rounded]

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |   2551246    3072.095    2803.442          1      25000

. summarize incwelfr if incwelfr>0 [fweight= perwt_rounded]

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |   2551246    3072.095    2803.442          1      25000

·        Here we go through the exercise of generating a new variable, and attaching value labels and a variable label to it:

. replace receives_welfare=1 if incwelfr>0 & incwelfr~=.

lfare |      Freq.     Percent        Cum.

------------+-----------------------------------

0 |    132,421       99.04       99.04

1 |      1,289        0.96      100.00

------------+-----------------------------------

Total |    133,710      100.00

. label define receives_welfare_lbl 0 "no welfare" 1 "yes welfare"

lfare |      Freq.     Percent        Cum.

------------+-----------------------------------

no welfare |    132,421       99.04       99.04

yes welfare |      1,289        0.96      100.00

------------+-----------------------------------

Total |    133,710      100.00

does |

respondent |

welfare |      Freq.     Percent        Cum.

------------+-----------------------------------

no welfare |    132,421       99.04       99.04

yes welfare |      1,289        0.96      100.00

------------+-----------------------------------

Total |    133,710      100.00

-----------------------------------------------------------------------------------------------------

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

yrsed |    101937    12.79583    3.153618          0         17

-----------------------------------------------------------------------------------------------------

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

yrsed |      1289     10.9903    2.817995          0         17

. table receives_welfare sex [fweight= perwt_rounded] , contents(freq mean age mean yrsed mean incwag

> e) row col

------------------------------------------------------------------------

does        |

respondent  |

welfare     |               Male              Female               Total

------------+-----------------------------------------------------------

no welfare |           1.34e+08            1.38e+08            2.72e+08

| 34.216377258300781  36.402645111083984  35.327167510986328

|           12.92792            12.90996             12.9187

|        26619.92881         14124.35177         20203.23216

|

yes welfare |            357,702             2193544             2551246

| 34.846588134765625  32.796371459960938  33.083827972412109

|           10.75763            11.14463            11.09037

|        4196.737659         3577.073717         3663.954806

|

Total |           1.34e+08            1.40e+08            2.74e+08

| 34.218059539794922  36.346202850341797  35.306285858154297

|           12.92039            12.87497            12.89688

|        26542.14272         13915.27974         20005.84709

------------------------------------------------------------------------

. describe age

storage   display    value

variable name   type    format     label      variable label

-----------------------------------------------------------------------------------------------------

age             byte    %19.0g     agelbl     Age

. format age %4.1g

. describe age

storage   display    value

variable name   type    format     label      variable label

-----------------------------------------------------------------------------------------------------

age             byte    %4.1g      agelbl     Age

. table receives_welfare sex [fweight= perwt_rounded] , contents(freq mean age mean yrsed mean incwag

> e) row col

---------------------------------------------------

does        |

respondent  |

welfare     |        Male       Female        Total

------------+--------------------------------------

no welfare |    1.34e+08     1.38e+08     2.72e+08

|          34           36           35

|    12.92792     12.90996      12.9187

| 26619.92881  14124.35177  20203.23216

|

yes welfare |     357,702      2193544      2551246

|          35           33           33

|    10.75763     11.14463     11.09037

| 4196.737659  3577.073717  3663.954806

|

Total |    1.34e+08     1.40e+08     2.74e+08

|          34           36           35

|    12.92039     12.87497     12.89688

| 26542.14272  13915.27974  20005.84709

---------------------------------------------------

. format age %4.2g

. table receives_welfare sex [fweight= perwt_rounded] , contents(freq mean age mean yrsed mean incwag

> e) row col

---------------------------------------------------

does        |

respondent  |

welfare     |        Male       Female        Total

------------+--------------------------------------

no welfare |    1.34e+08     1.38e+08     2.72e+08

|          34           36           35

|    12.92792     12.90996      12.9187

| 26619.92881  14124.35177  20203.23216

|

yes welfare |     357,702      2193544      2551246

|          35           33           33

|    10.75763     11.14463     11.09037

| 4196.737659  3577.073717  3663.954806

|

Total |    1.34e+08     1.40e+08     2.74e+08

|          34           36           35

|    12.92039     12.87497     12.89688

| 26542.14272  13915.27974  20005.84709

·        Here I was trying to reformat the display format of the age variable so as to get one decimal place, and it took me a few tries…

. format age %6.3g

. table receives_welfare sex [fweight= perwt_rounded] , contents(freq mean age mean yrsed mean incwag

> e) row col

---------------------------------------------------

does        |

respondent  |

welfare     |        Male       Female        Total

------------+--------------------------------------

no welfare |    1.34e+08     1.38e+08     2.72e+08

|        34.2         36.4         35.3

|    12.92792     12.90996      12.9187

| 26619.92881  14124.35177  20203.23216

|

yes welfare |     357,702      2193544      2551246

|        34.8         32.8         33.1

|    10.75763     11.14463     11.09037

| 4196.737659  3577.073717  3663.954806

|

Total |    1.34e+08     1.40e+08     2.74e+08

|        34.2         36.3         35.3

|    12.92039     12.87497     12.89688

| 26542.14272  13915.27974  20005.84709

·        The steps for ingesting data: First, unzip the file. Then, change directory, cd command, within stata to the directory that has the asci data file and the do file. Then use the File menu to go and select the do file, and run it.

. cd "C:\Users\mexmi\Documents\current class files\intro soc methods\1995 HW1 data"

C:\Users\mexmi\Documents\current class files\intro soc methods\1995 HW1 data

. clear all

. do "C:\Users\mexmi\Documents\current class files\intro soc methods\1995 HW1 data\cps_00006.do"

. /* Important: you need to put the .dat and .do files in one folder/

>    directory and then set the working folder to that folder. */

.

. set more off

.

. clear

. infix ///

>  int     year                                 1-4 ///

>  float  perwt                                5-12 ///

>  byte    age                                 13-14 ///

>  byte    sex                                 15 ///

>  long    inctot                              16-21 ///

>  using cps_00006.dat

.

. replace perwt=perwt/100

.

. label var year `"Survey year"'

. label var perwt `"Person weight"'

. label var age `"Age"'

. label var sex `"Sex"'

. label var inctot `"Total personal income"'

.

. label define agelbl 00 `"Under 1 year"'

. label define agelbl 01 `"1"', add

. label define agelbl 02 `"2"', add

. label define agelbl 03 `"3"', add

. label define agelbl 04 `"4"', add

. label define agelbl 05 `"5"', add

. label define agelbl 06 `"6"', add

. label define agelbl 07 `"7"', add

. label define agelbl 08 `"8"', add

. label define agelbl 09 `"9"', add

. label define agelbl 10 `"10"', add

. label define agelbl 11 `"11"', add

. label define agelbl 12 `"12"', add

. label define agelbl 13 `"13"', add

. label define agelbl 14 `"14"', add

. label define agelbl 15 `"15"', add

. label define agelbl 16 `"16"', add

. label define agelbl 17 `"17"', add

. label define agelbl 18 `"18"', add

. label define agelbl 19 `"19"', add

. label define agelbl 20 `"20"', add

. label define agelbl 21 `"21"', add

. label define agelbl 22 `"22"', add

. label define agelbl 23 `"23"', add

. label define agelbl 24 `"24"', add

. label define agelbl 25 `"25"', add

. label define agelbl 26 `"26"', add

. label define agelbl 27 `"27"', add

. label define agelbl 28 `"28"', add

. label define agelbl 29 `"29"', add

. label define agelbl 30 `"30"', add

. label define agelbl 31 `"31"', add

. label define agelbl 32 `"32"', add

. label define agelbl 33 `"33"', add

. label define agelbl 34 `"34"', add

. label define agelbl 35 `"35"', add

. label define agelbl 36 `"36"', add

. label define agelbl 37 `"37"', add

. label define agelbl 38 `"38"', add

. label define agelbl 39 `"39"', add

. label define agelbl 40 `"40"', add

. label define agelbl 41 `"41"', add

. label define agelbl 42 `"42"', add

. label define agelbl 43 `"43"', add

. label define agelbl 44 `"44"', add

. label define agelbl 45 `"45"', add

. label define agelbl 46 `"46"', add

. label define agelbl 47 `"47"', add

. label define agelbl 48 `"48"', add

. label define agelbl 49 `"49"', add

. label define agelbl 50 `"50"', add

. label define agelbl 51 `"51"', add

. label define agelbl 52 `"52"', add

. label define agelbl 53 `"53"', add

. label define agelbl 54 `"54"', add

. label define agelbl 55 `"55"', add

. label define agelbl 56 `"56"', add

. label define agelbl 57 `"57"', add

. label define agelbl 58 `"58"', add

. label define agelbl 59 `"59"', add

. label define agelbl 60 `"60"', add

. label define agelbl 61 `"61"', add

. label define agelbl 62 `"62"', add

. label define agelbl 63 `"63"', add

. label define agelbl 64 `"64"', add

. label define agelbl 65 `"65"', add

. label define agelbl 66 `"66"', add

. label define agelbl 67 `"67"', add

. label define agelbl 68 `"68"', add

. label define agelbl 69 `"69"', add

. label define agelbl 70 `"70"', add

. label define agelbl 71 `"71"', add

. label define agelbl 72 `"72"', add

. label define agelbl 73 `"73"', add

. label define agelbl 74 `"74"', add

. label define agelbl 75 `"75"', add

. label define agelbl 76 `"76"', add

. label define agelbl 77 `"77"', add

. label define agelbl 78 `"78"', add

. label define agelbl 79 `"79"', add

. label define agelbl 80 `"80"', add

. label define agelbl 81 `"81"', add

. label define agelbl 82 `"82"', add

. label define agelbl 83 `"83"', add

. label define agelbl 84 `"84"', add

. label define agelbl 85 `"85"', add

. label define agelbl 86 `"86"', add

. label define agelbl 87 `"87"', add

. label define agelbl 88 `"88"', add

. label define agelbl 89 `"89"', add

. label define agelbl 90 `"90 (90+, 1988-2002)"', add

. label define agelbl 91 `"91"', add

. label define agelbl 92 `"92"', add

. label define agelbl 93 `"93"', add

. label define agelbl 94 `"94"', add

. label define agelbl 95 `"95"', add

. label define agelbl 96 `"96"', add

. label define agelbl 97 `"97"', add

. label define agelbl 98 `"98"', add

. label define agelbl 99 `"99+"', add

. label values age agelbl

.

. label define sexlbl 1 `"Male"'

. label define sexlbl 2 `"Female"', add

. label values sex sexlbl

.

.

end of do-file

. tabulate sex

Sex |      Freq.     Percent        Cum.

------------+-----------------------------------

Male |     71,769       47.96       47.96

Female |     77,873       52.04      100.00

------------+-----------------------------------

Total |    149,642      100.00

. log close

name:  <unnamed>