-------------
      name:  <unnamed>
       log:  /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.smcl
  log type:  smcl
 opened on:  19 Oct 2020, 19:27:19

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. log using "Econ120_F20_Section3.smcl", replace // you can just comment out this line if you don't want to keep a Stata log file
log file already open
r(604);

end of do-file

r(604);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
end of do-file

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Constructing variables
. su kg_tdfert_diff = kg_tdfert_blue - kg_tdfert_unmarked
variable kg_tdfert_diff not found
r(111);

end of do-file

r(111);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Constructing variables
. gen kg_tdfert_diff = kg_tdfert_blue - kg_tdfert_unmarked
(435 missing values generated)

. ttest kg_tdfert_diff=0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. est clear

. estpost unmarked:       estpost summarize       kg_tdfert_unmarked      kg_plantfert_unmarked   packets_hyb_unmarked
invalid subcommand
r(198);

end of do-file

r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. est clear

. estpost unmarked:       estpost summarize       kg_tdfert_unmarked      kg_plantfert_unmarked   packets_hyb_unmarked
invalid subcommand
r(198);

end of do-file

r(198);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. est clear

. estpost unmarked:       estpost summarize       kg_tdfert_unmarked      kg_plantfert_unmarked   packets_hyb_unmarked
invalid subcommand
r(198);

end of do-file

r(198);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert_unmarked      kg_plantfert_unmarked   packets_hyb_unmarked

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert_~d   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfe~d   |       806          806     6.143238     40.22108     6.342009            0
packets_hy~d   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert_~d   |        75         6641
kg_plantfe~d   |        25      4951.45
packets_hy~d   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert_blue          kg_plantfert_blue               packets_hyb_blue

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert_~e   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfe~e   |       811          811     11.31751     11.49117     3.389863            0
packets_hy~e   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert_~e   |        25        10148
kg_plantfe~e   |        25       9178.5
packets_hy~e   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert_diff          kg_plantfert_diff               packets_hyb_diff
option by() required
r(198);

end of do-file

r(198);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert_unmarked      kg_plantfert_unmarked   packets_hyb_unmarked

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert_~d   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfe~d   |       806          806     6.143238     40.22108     6.342009            0
packets_hy~d   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert_~d   |        75         6641
kg_plantfe~d   |        25      4951.45
packets_hy~d   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert_blue          kg_plantfert_blue               packets_hyb_blue

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert_~e   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfe~e   |       811          811     11.31751     11.49117     3.389863            0
packets_hy~e   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert_~e   |        25        10148
kg_plantfe~e   |        25       9178.5
packets_hy~e   |        10      1118.08

. eststo difference:      estpost summarize       kg_tdfert_diff          kg_plantfert_diff               packets_hyb_diff

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert~ff   |       813          813     4.195572     48.73695     6.981185        -62.5
kg_plantf~ff   |       801          801     5.152996      38.4936     6.204321          -15
packets_h~ff   |       812          812     .0559975     .1534102     .3916762           -2

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert~ff   |      17.5         3411
kg_plantf~ff   |        25      4127.55
packets_h~ff   |       2.5        45.47

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(2)) b(pattern(0 0 1) fmt(2) star)" "sd(pattern(1 1 0) fmt(2) par)" "p(pattern(0 0 1) fmt(3) par)")
(note: file Section3_table1_raw.csv not found)
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. tab group_blue

 perception |
         of |
facilitator |
  valuation |
    of blue |
plot (1-10) |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          1        0.12        0.12
          2 |          3        0.36        0.48
          3 |          1        0.12        0.60
          4 |         10        1.21        1.81
          5 |         27        3.26        5.07
          6 |         44        5.31       10.39
          7 |        123       14.86       25.24
          8 |        300       36.23       61.47
          9 |        257       31.04       92.51
         10 |         62        7.49      100.00
------------+-----------------------------------
      Total |        828      100.00

. sort kg_tdfert_unmarked kg_tdfert_blue

. br kg_tdfert_unmarked kg_tdfert_blue

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
variable kg_tdfert_diff already defined
r(110);

end of do-file

r(110);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
end of do-file

. su kg_tdfert_diff

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert~ff |        813    4.195572    6.981185      -62.5       17.5

. ttest kg_tdfert_diff
by() option required
r(100);

. ttest kg_tdfert_diff=0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_tdfert_diff=0  kg_plantfert_diff=0
invalid 'kg_plantfert_diff'
r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. reshape kg_tdfert kg_plantfert packets_hyb, i(respondent_id)
invalid syntax


In the reshape command that you typed, you omitted the word wide or long,
or substituted some other word for it.  You should have typed

        . reshape wide varlist, ...
    or
        . reshape long varlist, ...


You might have omitted varlist, too.
The basic syntax of reshape is


         long                                wide
        +---------------+                   +------------------+
        | i   j   a   b |                   | i   a1 a2  b1 b2 |
        |---------------| <--- reshape ---> |------------------|
        | 1   1   1   2 |                   | 1   1   3   2  4 |
        | 1   2   3   4 |                   | 2   5   7   6  8 |
        | 2   1   5   6 |                   +------------------+
        | 2   2   7   8 |
        +---------------+

        long to wide: reshape wide a b, i(i) j(j)    (j existing variable)
        wide to long: reshape long a b, i(i) j(j)    (j    new   variable)
r(198);

end of do-file

r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id)
variable _j contains all missing values
r(498);

end of do-file

r(498);

. help reshape

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot)
variable plot contains all missing values
r(498);

end of do-file

r(498);

. codebook respondent_id

-------------
respondent_idFarmer  ID
-------------

                  type:  numeric (long)

                 range:  [53,93010]                   units:  1
         unique values:  1,248                    missing .:  0/1,248

                  mean:   6865.61
              std. dev:   5050.54

           percentiles:        10%       25%       50%       75%       90%
                              1503    3210.5    6602.5   10306.5     12301

. br kg_tdfert_blue kg_tdfert_unmarked kg_tdfert_rof

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _rof _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    3744
Number of variables                  75   ->      70
j variable (3 values)                     ->   plot
xij variables:
kg_tdfert_blue kg_tdfert_rof kg_tdfert_unmarked->kg_tdfert
kg_plantfert_blue kg_plantfert_rof kg_plantfert_unmarked->kg_plantfert
packets_hyb_blue packets_hyb_rof packets_hyb_unmarked->packets_hyb
-----------------------------------------------------------------------------

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
end of do-file

. tab plot

       plot |      Freq.     Percent        Cum.
------------+-----------------------------------
      _blue |      1,248       50.00       50.00
  _unmarked |      1,248       50.00      100.00
------------+-----------------------------------
      Total |      2,496      100.00

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot)

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2523719     16.82722         1640            1
kg_plantfert   |  5.174271         1617     .2526882      20.4769         1615            1
packets_hyb   |  .0557133         1628     .0260968     2.134869         1626     .9835396

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  9.75e-59     4.88e-59          822      12.3455          820      8.09878
kg_plantfert   |  4.94e-83     2.47e-83          811     11.31751          806     6.143238
packets_hyb   |  .0329209     .0164604          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(2)) b(pattern(0 0 1) fmt(2) star)" "sd(pattern(1 1 0) fmt(2) par)" "p(pattern(0 0 1) fmt(3) par)")
(output written to `"Section3_table1_raw.csv"')

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot)

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2523719     16.82722         1640            1
kg_plantfert   |  5.174271         1617     .2526882      20.4769         1615            1
packets_hyb   |  .0557133         1628     .0260968     2.134869         1626     .9835396

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  9.75e-59     4.88e-59          822      12.3455          820      8.09878
kg_plantfert   |  4.94e-83     2.47e-83          811     11.31751          806     6.143238
packets_hyb   |  .0329209     .0164604          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par)" "p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)
(output written to `"Section3_table1_raw.csv"')

.
end of do-file

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot)

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2523719     16.82722         1640            1
kg_plantfert   |  5.174271         1617     .2526882      20.4769         1615            1
packets_hyb   |  .0557133         1628     .0260968     2.134869         1626     .9835396

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  9.75e-59     4.88e-59          822      12.3455          820      8.09878
kg_plantfert   |  4.94e-83     2.47e-83          811     11.31751          806     6.143238
packets_hyb   |  .0329209     .0164604          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par)" "p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01) plain
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot)

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2523719     16.82722         1640            1
kg_plantfert   |  5.174271         1617     .2526882      20.4769         1615            1
packets_hyb   |  .0557133         1628     .0260968     2.134869         1626     .9835396

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  9.75e-59     4.88e-59          822      12.3455          820      8.09878
kg_plantfert   |  4.94e-83     2.47e-83          811     11.31751          806     6.143238
packets_hyb   |  .0329209     .0164604          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par)" "p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01) plain nomtitle
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot)

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2523719     16.82722         1640            1
kg_plantfert   |  5.174271         1617     .2526882      20.4769         1615            1
packets_hyb   |  .0557133         1628     .0260968     2.134869         1626     .9835396

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  9.75e-59     4.88e-59          822      12.3455          820      8.09878
kg_plantfert   |  4.94e-83     2.47e-83          811     11.31751          806     6.143238
packets_hyb   |  .0329209     .0164604          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par)" "p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01) nonumber nomtitle noobs plain
(output written to `"Section3_table1_raw.csv"')

.
.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par)" "p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01) nonumber nomtitle noobs plain
(output written to `"Section3_table1_raw.csv"')

.
.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells((mean(pattern(1 1 0) fmt(2)) b(pattern(0 0 1) fmt(2) star)) (sd(pattern(1 1 0) fmt(2) par) p(pattern(0 0 1) fmt(3) par))) starlevels(* 0.10 ** 0.05 *** 0.01) nonumber nomtitle noobs plain
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(2)) b(pattern(0 0 1) fmt(2) star)" "sd(pattern(1 1 0) fmt(2) par) p(pattern(0 0 1) fmt(3) par)") starlevels(* 0.10 ** 0.05 *** 0.01) nonumber nomtitle noobs plain
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01) nonumber nomtitle noobs plain
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) p(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. use "farming.dta", clear

. keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

. reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
. est clear

. eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

. eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

. eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
. esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. //
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. //
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue input_ksh_blue input_ksh_unmarked

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   9   ->       7
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb input_ksh if plot=="_unmarked"
input_ksh ambiguous abbreviation
r(111);

end of do-file

r(111);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. //
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue input_ksh_blue input_ksh_unmarked

.         reshape long kg_tdfert kg_plantfert packets_hyb input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   9   ->       6
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36
input_ksh   |      6095     947954.3

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08
input_ksh   |    3952.5      1451267

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // To export in nice-looking table formst, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_kshb if plot=="_unmarked"
variable input_kshb not found
r(111);

end of do-file

r(111);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // To export in nice-looking table formst, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot)

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.17651     21.56174         1511            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  4.05e-90     2.03e-90          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(note: file Section3_table2_raw.csv not found)
(output written to `"Section3_table2_raw.csv"')

.         restore

. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // To export in nice-looking table formst, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
end of do-file

. ttest input_ksh, by(plot) unequal

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
   _blue |     760    1909.561    10.34435    285.1742    1889.254    1929.868
_unmarke |     753    1258.903    28.46202     781.022    1203.029    1314.778
---------+--------------------------------------------------------------------
combined |   1,513    1585.738    17.24812    670.9054    1551.905     1619.57
---------+--------------------------------------------------------------------
    diff |            650.6579    30.28353                591.2273    710.0884
---------+--------------------------------------------------------------------
    diff = mean(_blue) - mean(_unmarke)                           t =  21.4855
Ho: diff = 0                     Satterthwaite's degrees of freedom =  947.409

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. br

. su input_ksh

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   input_ksh |      1,513    1585.738    670.9054          0       6095

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return =
invalid syntax
r(198);

end of do-file

r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

.
end of do-file

. su rate_of_return

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
rate_of_re~n |        622     2.10442    29.47147  -303.4385   313.5361

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(note: file histogram_revenue_blue.gph not found)
(file histogram_revenue_blue.gph saved)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. histogram revenue_blue, saving(histogram_revenue_blue.pdf, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(note: file histogram_revenue_blue.pdf not found)
(file histogram_revenue_blue.pdf saved)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
. // Histograms
. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(note: file histogram_revenue_blue.gph not found)
(file histogram_revenue_blue.gph saved)

. graph export "histogram_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/histogram_revenue_blue.pdf written in PDF format)

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. kdensity revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(file histogram_revenue_blue.gph saved)

. graph export "kdensity_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_revenue_blue.pdf written in PDF format)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. twoway (kdensity revenue_blue) (kdensity revenue_unmarked, lpattern("-")), saving(kdensity_both, replace) xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Blue Plot" 2 "Unmarked plot"));
option ; not allowed
r(198);

end of do-file

r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. twoway (kdensity revenue_blue) (kdensity revenue_unmarked, lpattern("-")), saving(kdensity_both, replace) xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Blue Plot" 2 "Unmarked plot"))
(note: file kdensity_both.gph not found)
(file kdensity_both.gph saved)

. graph export "both_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/both_revenue_blue.pdf written in PDF format)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. drop if rate_of_return < `p1'
invalid syntax
r(198);

end of do-file

r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. drop if rate_of_return < `r(p1)'
(6 observations deleted)

.
end of do-file

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
. // Histograms
. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(file histogram_revenue_blue.gph saved)

. graph export "histogram_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/histogram_revenue_blue.pdf written in PDF format)

.
. kdensity revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(file histogram_revenue_blue.gph saved)

. graph export "kdensity_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_revenue_blue.pdf written in PDF format)

.
. // Putting two graphs into a single figure
. twoway (kdensity revenue_blue) (kdensity revenue_unmarked, lpattern("-")), saving(kdensity_both, replace) xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Blue Plot" 2 "Unmarked plot"))
(file kdensity_both.gph saved)

. graph export "both_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/both_revenue_blue.pdf written in PDF format)

.
. // Dealing with outliers
. // Sample trimming (i.e., dropping observations that are too large/small)
. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. drop if rate_of_return < `r(p5)' | rate_of_return > `r(95)'
invalid syntax
r(198);

end of do-file

r(198);

. drop if rate_of_return < `r(p5)'
(32 observations deleted)

. drop if rate_of_return > `r(95)'
invalid syntax
r(198);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. use "farming.dta", clear

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
input_ksh_blue not found
r(111);

end of do-file

r(111);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. drop if rate_of_return < `r(p5)' | rate_of_return > `r(p95)'
(689 observations deleted)

.
end of do-file

. su rate_of_return

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
rate_of_re~n |        559     .695109    4.895663  -13.09754   18.81494

. su rate_of_return , d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%    -11.55018      -13.09754
 5%    -7.442477      -12.52147
10%    -4.722317      -12.16696       Obs                 559
25%    -1.595938      -11.84009       Sum of Wgt.         559

50%     .3028125                      Mean            .695109
                        Largest       Std. Dev.      4.895663
75%     2.789591       16.64224
90%      6.44464       16.68102       Variance       23.96751
95%     9.192067       16.68102       Skewness       .4769487
99%      16.2822       18.81494       Kurtosis       4.918137

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
. // Histograms
. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(file histogram_revenue_blue.gph saved)

. graph export "histogram_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/histogram_revenue_blue.pdf written in PDF format)

.
. kdensity revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(file histogram_revenue_blue.gph saved)

. graph export "kdensity_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_revenue_blue.pdf written in PDF format)

.
. // Putting two graphs into a single figure
. twoway (kdensity revenue_blue) (kdensity revenue_unmarked, lpattern("-")), saving(kdensity_both, replace) xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Blue Plot" 2 "Unmarked plot"))
(file kdensity_both.gph saved)

. graph export "both_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/both_revenue_blue.pdf written in PDF format)

.
. // Dealing with outliers
. // Sample trimming (i.e., dropping observations that are too large/small)
. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. di `r(p5)'  // 5th-%tile value
-13.514698

. di `r(p95)' // 95th-%tile value
18.814936

. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
. // Histograms
. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(file histogram_revenue_blue.gph saved)

. graph export "histogram_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/histogram_revenue_blue.pdf written in PDF format)

.
. kdensity revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(file histogram_revenue_blue.gph saved)

. graph export "kdensity_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_revenue_blue.pdf written in PDF format)

.
. // Putting two graphs into a single figure
. twoway (kdensity revenue_blue) (kdensity revenue_unmarked, lpattern("-")), saving(kdensity_both, replace) xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Blue Plot" 2 "Unmarked plot"))
(file kdensity_both.gph saved)

. graph export "both_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/both_revenue_blue.pdf written in PDF format)

.
. // Dealing with outliers
. // Sample trimming (i.e., dropping observations that are too large/small)
. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. gen rate_of_return_p5 = `r(p5)'

. gen rate_of_return_p95 = `r(p95)'

.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. su rate_of_return*

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
rate_of_re~n |        622     2.10442    29.47147  -303.4385   313.5361
rate_of_r~p5 |      1,248    -13.5147           0   -13.5147   -13.5147
rate_of_r~95 |      1,248    18.81494           0   18.81494   18.81494

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95, xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Rate of return - excluding top and bottom 5%")

. graph export "kdensity_return.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_return.pdf written in PDF format)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. twoway ///
> (kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95 & training==1) ///
> (kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95 & training==0, lpattern("-")), ///
> xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Training group" 2 "Control group"))

. graph export "kdensity_return_training.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_return_training.pdf written in PDF format)

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. reg revenue_blue training

      Source |       SS           df       MS      Number of obs   =       813
-------------+----------------------------------   F(1, 811)       =      7.42
       Model |  64899617.5         1  64899617.5   Prob > F        =    0.0066
    Residual |  7.0894e+09       811  8741588.15   R-squared       =    0.0091
-------------+----------------------------------   Adj R-squared   =    0.0078
       Total |  7.1543e+09       812  8810748.29   Root MSE        =    2956.6

-------------+----------------------------------------------------------------
 revenue_blue |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |     565.599    207.5787      2.72    0.007      158.1442     973.0538
       _cons |    7401.362     143.586     51.55    0.000      7119.518     7683.206
-------------+----------------------------------------------------------------

.
end of do-file

. do "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/Econ120_F20_Section3.do"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. //ssc install estout // you need to install this package only once
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
. // Histograms
. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(file histogram_revenue_blue.gph saved)

. graph export "histogram_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/histogram_revenue_blue.pdf written in PDF format)

.
. kdensity revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(file histogram_revenue_blue.gph saved)

. graph export "kdensity_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_revenue_blue.pdf written in PDF format)

.
. // Putting two graphs into a single figure
. twoway (kdensity revenue_blue) (kdensity revenue_unmarked, lpattern("-")), saving(kdensity_both, replace) xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Blue Plot" 2 "Unmarked plot"))
(file kdensity_both.gph saved)

. graph export "both_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/both_revenue_blue.pdf written in PDF format)

.
. // Dealing with outliers
. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. di `r(p5)'  // 5th-%tile value
-13.514698

. di `r(p95)' // 95th-%tile value
18.814936

.         gen rate_of_return_p5 = `r(p5)'

.         gen rate_of_return_p95 = `r(p95)'

.
. kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95, xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Rate of return - excluding top and bottom 5%")

. graph export "kdensity_return.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_return.pdf written in PDF format)

.
. // Bonus
. twoway ///
>         (kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95 & training==1) ///
>         (kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95 & training==0, lpattern("-")), ///
>         xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Training group" 2 "Control group"))

. graph export "kdensity_return_training.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_return_training.pdf written in PDF format)

.
. // REVIEW: exporting regression tables
. local i = 1

. foreach YYY in revenue_blue revenue_unmarked rate_of_return {
  2.         eststo s3_reg_`i': reg `YYY' training
  3.         su `YYY' if training==0
  4.         estadd scalar controlmean = r(mean)
  5.         local i = `i' + 1
  6. }

      Source |       SS           df       MS      Number of obs   =       813
-------------+----------------------------------   F(1, 811)       =      7.42
       Model |  64899617.5         1  64899617.5   Prob > F        =    0.0066
    Residual |  7.0894e+09       811  8741588.15   R-squared       =    0.0091
-------------+----------------------------------   Adj R-squared   =    0.0078
       Total |  7.1543e+09       812  8810748.29   Root MSE        =    2956.6

-------------+----------------------------------------------------------------
 revenue_blue |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |     565.599    207.5787      2.72    0.007      158.1442     973.0538
       _cons |    7401.362     143.586     51.55    0.000      7119.518     7683.206
-------------+----------------------------------------------------------------

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
revenue_blue |        424    7401.362     3049.71          0   18297.53

added scalar:
        e(controlmean) =  7401.362

      Source |       SS           df       MS      Number of obs   =       810
-------------+----------------------------------   F(1, 808)       =      0.38
       Model |  3374435.96         1  3374435.96   Prob > F        =    0.5399
    Residual |  7.2514e+09       808  8974473.65   R-squared       =    0.0005
-------------+----------------------------------   Adj R-squared   =   -0.0008
       Total |  7.2547e+09       809  8967551.47   Root MSE        =    2995.7

-------------+----------------------------------------------------------------
 revenue_un~d |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |    129.2463    210.7765      0.61    0.540     -284.4877     542.9804
       _cons |    6171.098    145.3149     42.47    0.000      5885.858     6456.337
-------------+----------------------------------------------------------------

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
revenue_un~d |        425    6171.098    3106.787          0   15273.14

added scalar:
        e(controlmean) =  6171.0975

      Source |       SS           df       MS      Number of obs   =       607
-------------+----------------------------------   F(1, 605)       =      0.73
       Model |  653.127029         1  653.127029   Prob > F        =    0.3918
    Residual |  538008.297       605  889.269912   R-squared       =    0.0012
-------------+----------------------------------   Adj R-squared   =   -0.0004
       Total |  538661.424       606  888.880237   Root MSE        =    29.821

-------------+----------------------------------------------------------------
 rate_of_re~n |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |    2.079826    2.426861      0.86    0.392     -2.686269     6.845921
       _cons |    1.201006    1.654151      0.73    0.468     -2.047569     4.449581
-------------+----------------------------------------------------------------

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
rate_of_re~n |        325    1.201006    32.57952  -303.4385   313.5361

added scalar:
        e(controlmean) =  1.2010062

.
. estout s3_reg_* using "Section3_table2_raw.csv", replace style(tab) delimiter(",") mlabel(,depvars) collabel(none) label ///
>         drop(_cons) stats(controlmean N, labels("Control mean" "Obs") fmt(%9.2f %9.0fc)) starlevels(* 0.10 ** 0.05 *** 0.01) ///
>         cells("b(fmt(%9.2f) star)" "se(fmt(%9.2f) par)")
(output written to `"Section3_table2_raw.csv"')

.
.
.
. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. local i = 1

. foreach YYY in revenue_blue revenue_unmarked rate_of_return {
  2.         eststo s3_reg_`i': reg `YYY' training
  3.         su `YYY' if training==0
  4.         estadd scalar controlmean = r(mean)
  5.         estadd scalar controlsd = r(sd)
  6.         local i = `i' + 1
  7. }

      Source |       SS           df       MS      Number of obs   =       813
-------------+----------------------------------   F(1, 811)       =      7.42
       Model |  64899617.5         1  64899617.5   Prob > F        =    0.0066
    Residual |  7.0894e+09       811  8741588.15   R-squared       =    0.0091
-------------+----------------------------------   Adj R-squared   =    0.0078
       Total |  7.1543e+09       812  8810748.29   Root MSE        =    2956.6

-------------+----------------------------------------------------------------
 revenue_blue |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |     565.599    207.5787      2.72    0.007      158.1442     973.0538
       _cons |    7401.362     143.586     51.55    0.000      7119.518     7683.206
-------------+----------------------------------------------------------------

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
revenue_blue |        424    7401.362     3049.71          0   18297.53

added scalar:
        e(controlmean) =  7401.362

added scalar:
          e(controlsd) =  3049.7096

      Source |       SS           df       MS      Number of obs   =       810
-------------+----------------------------------   F(1, 808)       =      0.38
       Model |  3374435.96         1  3374435.96   Prob > F        =    0.5399
    Residual |  7.2514e+09       808  8974473.65   R-squared       =    0.0005
-------------+----------------------------------   Adj R-squared   =   -0.0008
       Total |  7.2547e+09       809  8967551.47   Root MSE        =    2995.7

-------------+----------------------------------------------------------------
 revenue_un~d |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |    129.2463    210.7765      0.61    0.540     -284.4877     542.9804
       _cons |    6171.098    145.3149     42.47    0.000      5885.858     6456.337
-------------+----------------------------------------------------------------

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
revenue_un~d |        425    6171.098    3106.787          0   15273.14

added scalar:
        e(controlmean) =  6171.0975

added scalar:
          e(controlsd) =  3106.7869

      Source |       SS           df       MS      Number of obs   =       607
-------------+----------------------------------   F(1, 605)       =      0.73
       Model |  653.127029         1  653.127029   Prob > F        =    0.3918
    Residual |  538008.297       605  889.269912   R-squared       =    0.0012
-------------+----------------------------------   Adj R-squared   =   -0.0004
       Total |  538661.424       606  888.880237   Root MSE        =    29.821

-------------+----------------------------------------------------------------
 rate_of_re~n |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
    training |    2.079826    2.426861      0.86    0.392     -2.686269     6.845921
       _cons |    1.201006    1.654151      0.73    0.468     -2.047569     4.449581
-------------+----------------------------------------------------------------

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
rate_of_re~n |        325    1.201006    32.57952  -303.4385   313.5361

added scalar:
        e(controlmean) =  1.2010062

added scalar:
          e(controlsd) =  32.579525

.
. estout s3_reg_* using "Section3_table2_raw.csv", replace style(tab) delimiter(",") mlabel(,depvars) collabel(none) label ///
>         drop(_cons) stats(controlmean controlsd N, labels("Control mean" "Control SD" "Obs") fmt(%9.2f %9.2f %9.0fc)) starlevels(* 0.10 ** 0.05 *** 0.01) ///
>         cells("b(fmt(%9.2f) star)" "se(fmt(%9.2f) par)")
(output written to `"Section3_table2_raw.csv"')

.
end of do-file

. do "/var/folders/wy/26794k5d4ydcf0nqcms58wkr0000gn/T//SD43744.000000"

. * ---------------------------- *
. * Econ120 (J. Robinson, F2020) *
. * Section 3 (Oct. 19, 2020)        * NOTE: all the path directories are based on my own computer,
. * TA: David Sungho Park        *       so you should change them according to yours.
. * ---------------------------- *
.
. clear all

. set more off

.
. cap noisily cd "/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/" // Note: I changed this from previous do-files for Sections 1 & 2
/Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3

.
. //log using "Econ120_F20_Section3.smcl", replace // you can uncomment this line if you want to keep a Stata log file
.
. //ssc install estout // you need to install this package only once
.
. use "farming.dta", clear

.
. // Getting sumstats
. su kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~e |        822     12.3455    1.376406          0         25
kg_plantfe~e |        811    11.31751    3.389863          0         25
packets_hy~e |        816    1.370196    .4662883          0         10

. su kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
kg_tdfert_~d |        820     8.09878    7.103199          0         75
kg_plantfe~d |        806    6.143238    6.342009          0         25
packets_hy~d |        812    1.314483    .5807212          0         10

.
. // Testing for mean differences
. gen kg_tdfert_diff              = kg_tdfert_blue        - kg_tdfert_unmarked
(435 missing values generated)

. gen kg_plantfert_diff   = kg_plantfert_blue - kg_plantfert_unmarked
(447 missing values generated)

. gen packets_hyb_diff    = packets_hyb_blue      - packets_hyb_unmarked
(436 missing values generated)

.
. ttest kg_tdfert_diff    = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_td~ff |     813    4.195572    .2448409    6.981185    3.714976    4.676168
---------+--------------------------------------------------------------------
    mean = mean(kg_tdfert_diff)                                   t =  17.1359
Ho: mean = 0                                     degrees of freedom =      812

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest kg_plantfert_diff = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
kg_pl~ff |     801    5.152996    .2192189    6.204321    4.722684    5.583308
---------+--------------------------------------------------------------------
    mean = mean(kg_plantfert_diff)                                t =  23.5062
Ho: mean = 0                                     degrees of freedom =      800

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

. ttest packets_hyb_diff  = 0

One-sample t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
packe~ff |     812    .0559975    .0137451    .3916762    .0290173    .0829778
---------+--------------------------------------------------------------------
    mean = mean(packets_hyb_diff)                                 t =   4.0740
Ho: mean = 0                                     degrees of freedom =      811

    Ha: mean < 0                 Ha: mean != 0                 Ha: mean > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0001          Pr(T > t) = 0.0000

.
. // Constructing mean-difference table (similar to what you've done for Econ104)
. preserve

.         // First step: we need to reshape the dataset from "wide" format to "long" format
.         keep respondent_id kg_tdfert_unmarked kg_plantfert_unmarked packets_hyb_unmarked kg_tdfert_blue kg_plantfert_blue packets_hyb_blue

.         reshape long kg_tdfert kg_plantfert packets_hyb, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   7   ->       5
j variable (2 values)                     ->   plot
xij variables:
      kg_tdfert_blue kg_tdfert_unmarked   ->   kg_tdfert
kg_plantfert_blue kg_plantfert_unmarked   ->   kg_plantfert
  packets_hyb_blue packets_hyb_unmarked   ->   packets_hyb
-----------------------------------------------------------------------------

.
.         // Step 2: exporting into single table (similar to what you've done for Econ104)
.         est clear

.         eststo unmarked:        estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       820          820      8.09878     50.45543     7.103199            0
kg_plantfert   |       806          806     6.143238     40.22108     6.342009            0
packets_hyb   |       812          812     1.314483     .3372371     .5807212            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        75         6641
kg_plantfert   |        25      4951.45
packets_hyb   |        10      1067.36

.         eststo blue:            estpost summarize       kg_tdfert kg_plantfert packets_hyb if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
kg_tdfert   |       822          822      12.3455     1.894493     1.376406            0
kg_plantfert   |       811          811     11.31751     11.49117     3.389863            0
packets_hyb   |       816          816     1.370196     .2174247     .4662883            0

   | e(max)    e(sum)
-------------+----------------------
kg_tdfert   |        25        10148
kg_plantfert   |        25       9178.5
packets_hyb   |        10      1118.08

.         eststo difference:      estpost ttest           kg_tdfert kg_plantfert packets_hyb, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
kg_tdfert   |  4.246718         1642     .2526574     16.80821     880.2708            1
kg_plantfert   |  5.174271         1617     .2531229     20.44173     1228.602            1
packets_hyb   |  .0557133         1628     .0261107     2.133735     1550.406     .9834895

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
kg_tdfert   |  3.39e-55     1.69e-55          822      12.3455          820      8.09878
kg_plantfert   |  3.55e-80     1.78e-80          811     11.31751          806     6.143238
packets_hyb   |   .033021     .0165105          816     1.370196          812     1.314483

.
.         esttab unmarked blue difference using "Section3_table1_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table1_raw.csv"')

. restore

.
. // Calculating monetary cost of inputs
. gen input_ksh_blue = kg_tdfert_blue*65 + kg_plantfert_blue*70 + packets_hyb_blue*230
(488 missing values generated)

. gen input_ksh_unmarked = kg_tdfert_unmarked*65 + kg_plantfert_unmarked*70 + packets_hyb_unmarked*230
(495 missing values generated)

.
. ttest input_ksh_blue = input_ksh_unmarked

Paired t test
---------+--------------------------------------------------------------------
Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
input_~e |     741    1909.007    10.58548    288.1508    1888.226    1929.788
input_~d |     741    1265.847    28.75187    782.6636    1209.402    1322.292
---------+--------------------------------------------------------------------
    diff |     741    643.1601    27.52955    749.3906    589.1147    697.2054
---------+--------------------------------------------------------------------
     mean(diff) = mean(input_ksh_blue - input_ksh_unma~d)         t =  23.3625
 Ho: mean(diff) = 0                              degrees of freedom =      740

 Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

.
.         // FYI: To export in nice-looking table format, you can do something similar to above
.         preserve

.                 // Step 1: eshaping the dataset from "wide" to "long"
.                 keep respondent_id input_ksh_blue input_ksh_unmarked

.                 reshape long input_ksh, i(respondent_id) j(plot,string)
(note: j = _blue _unmarked)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1248   ->    2496
Number of variables                   3   ->       3
j variable (2 values)                     ->   plot
xij variables:
      input_ksh_blue input_ksh_unmarked   ->   input_ksh
-----------------------------------------------------------------------------

.
.                 // Step 2: exporting into single table (similar to what you've done for Econ104)
.                 est clear

.                 eststo unmarked:        estpost summarize       input_ksh if plot=="_unmarked"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       753          753     1258.903     609995.3      781.022            0

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |      6095     947954.3

.                 eststo blue:            estpost summarize       input_ksh if plot=="_blue"

   | e(count)    e(sum_w)    e(mean)    e(Var)    e(sd)    e(min)
-------------+------------------------------------------------------------------
input_ksh   |       760          760     1909.561      81324.3     285.1742        812.5

   | e(max)    e(sum)
-------------+----------------------
input_ksh   |    3952.5      1451267

.                 eststo difference:      estpost ttest           input_ksh, by(plot) unequal

   | e(b)    e(count)    e(se)    e(t)    e(df_t)    e(p_l)
-------------+------------------------------------------------------------------
input_ksh   |  650.6579         1513     30.28353     21.48553     947.4087            1

   | e(p)    e(p_u)    e(N_1)    e(mu_1)    e(N_2)    e(mu_2)
-------------+------------------------------------------------------------------
input_ksh   |  9.90e-84     4.95e-84          760     1909.561          753     1258.903

.
.                 esttab unmarked blue difference using "Section3_table2_raw.csv", replace  cells("mean(pattern(1 1 0) fmt(%9.2f)) b(pattern(0 0 1) fmt(%9.2f) star)" "sd(pattern(1 1 0) fmt(%9.2f) par) se(pattern(0 0 1) fmt(%9.2f) par)") starlevels(* 0.10 ** 0.05 *** 0.01)  plain
(output written to `"Section3_table2_raw.csv"')

.         restore

.
. // Calculating rate of return
. gen rate_of_return = ((revenue_blue - revenue_unmarked) - (input_ksh_blue - input_ksh_unmarked)) / (input_ksh_blue - input_ksh_unmarked)
(626 missing values generated)

. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

.
. // Histograms
. histogram revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(bin=28, start=0, width=653.48319)
(file histogram_revenue_blue.gph saved)

. graph export "histogram_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/histogram_revenue_blue.pdf written in PDF format)

.
. kdensity revenue_blue, saving(histogram_revenue_blue, replace) xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Distribution of revenue on blue plot")
(file histogram_revenue_blue.gph saved)

. graph export "kdensity_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_revenue_blue.pdf written in PDF format)

.
. // Putting multiple plots into a single graph
. twoway ///
>         (kdensity revenue_blue) ///
>         (kdensity revenue_unmarked, lpattern("-")), ///
>         saving(kdensity_both, replace) ///
>         xtitle("revenue (Ksh)") ytitle("Percentage of farmers") ///
>         legend(order(1 "Blue Plot" 2 "Unmarked plot"))
(file kdensity_both.gph saved)

. graph export "both_revenue_blue.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/both_revenue_blue.pdf written in PDF format)

.
. // Dealing with outliers
. su rate_of_return, d

                       rate_of_return
-------------------------------------------------------------
      Percentiles      Smallest
 1%     -43.0784      -303.4385
 5%     -13.5147      -115.2545
10%    -7.141827      -82.52691       Obs                 622
25%    -1.924888      -70.56084       Sum of Wgt.         622

50%     .3028125                      Mean            2.10442
                        Largest       Std. Dev.      29.47147
75%      3.27173       240.9508
90%     8.119684       262.5536       Variance       868.5675
95%     18.81494        313.536       Skewness       4.151109
99%     77.63403       313.5361       Kurtosis       77.86307

. di `r(p5)'  // 5th-%tile value
-13.514698

. di `r(p95)' // 95th-%tile value
18.814936

.
.         // Saving the values for later reference
.         gen rate_of_return_p5 = `r(p5)'

.         gen rate_of_return_p95 = `r(p95)'

.
. kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95, xtitle("revenue (Ksh)") ytitle("percentage of farmers") title("Rate of return - excluding top and bottom 5%")

. graph export "kdensity_return.pdf", replace // this line is necessary to save in PDF format
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_return.pdf written in PDF format)

.
. // Bonus
. twoway ///
>         (kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95 & training==1, lpattern(solid)) ///
>         (kdensity rate_of_return if rate_of_return>rate_of_return_p5 & rate_of_return<rate_of_return_p95 & training==0, lpattern(dash)), ///
>         xtitle("revenue (Ksh)") ytitle("Percentage of farmers") legend(order(1 "Training group" 2 "Control group"))

. graph export "kdensity_return_training.pdf", replace
(file /Users/DSP/Google Drive/UCSC/Teaching/Econ120_F20/SectionNotes/Section3/kdensity_return_training.pdf written in PDF format)

. sss
command sss is unrecognized
r(199);

end of do-file

r(199);

. exit, clear