Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exporting regressions to excel


    Effect of various farm practices on crop yield (Kg/Acre)
    Lentil Lentil green gram green gram peas peas dasasd dasasd sasa sasa
    Mean without Change associated with Mean without Change associated with Mean without Change associated with Mean without Change associated with Mean without Change associated with
    Intercropping 342 19 (2.035)***
    Subsidy
    Seed treatment
    Fertilizers
    dsdssa
    das
    dasd
    dfsa
    dfas
    sd

    Hi, I want to export a table like above in excel using my regression results. Basically, my regression is something like this: reg yield intercropping if crop == blackgram.

    I want to export regression coefficient, its standard error, p value and average value (calculated using summ command for each cell i.e. if a farmer has done intercropping for black gram.

    I am unable to write a state matrix code.

    It would be really helpful if anyone could help me on this.

    I wrote the following:


    set trace on
    levelsof seed_variety_combined, local(cropname)

    foreach crop of local cropname{

    matrix ResultsTables = J(22,8,.)
    matrix rownames ResultsTables = intercropping subsidypct source_of_seed succ_yrs land_preparation_cat storage_method_cat life_saving_irrigation_cat disease_pest_treatment_cat fertiliser_qty_cat spacing_cat seed_treatment_method_cat sowing_method_final category skymet_final
    matrix colnames ResultsTables = bg_b bg_se bg_p len_b len_se len_p

    levelsof seed_variety_combined, local(cropname)

    local indepvar intercropping subsidypct source_of_seed succ_yrs land_preparation_cat storage_method_cat life_saving_irrigation_cat disease_pest_treatment_cat fertiliser_qty_cat spacing_cat seed_treatment_method_cat sowing_method_final category skymet_final


    foreach var of local indepvar {

    quietly reg yield i.`var' i.district_code i.year if seed_variety_combined == `crop'
    *matrix ResultsTables[rownumb(ResultsTables,"`var'"), 1] = e(N)
    matrix ResultsTables[rownumb(ResultsTables,"`var'"), 2] = e(b)
    matrix ResultsTables[rownumb(ResultsTables,"`var'"), 3] = e(se)
    matrix ResultsTables[rownumb(ResultsTables,"`var'"), 4] = e(pval)

    quietly sum yield if seed_variety_combined == `v' & e(sample) == 1 & `var'== 1
    matrix ResultsTables[`rows', 2] = r(mean)

    }


    }


    Something is wrong in this code, I'm unable to figure out what it is. Also, I do not understand what exactly does 'rownumb' does.

    Any help would be highly appreciated.

    Thanks in advance.
Working...
X