Hi,
I am trying to export my logit results into Word, however, putdocx only exports coefficients and significance levels. How do I also include standard error under coefficients?
I am trying to export my logit results into Word, however, putdocx only exports coefficients and significance levels. How do I also include standard error under coefficients?
Code:
. ssc install dataex
checking dataex consistency and verifying not already installed...
all files already exist and are up to date.
. do "C:\Users\sofiy\AppData\Local\Temp\STD33a4_000000.tmp"
. logit W1ExcludeYP i.W1ethgrpYP1 i.in_poverty i.W1hiqualgMP i.W1SOCMajorMP W1parmonMP W1dispar c.schooldis i.W1englangYP i.W1truantYP substance_use delinquency if mysample [pweight = Designweight], v
> ce (cluster SampPSU) // Model 2
Iteration 0: log pseudolikelihood = -2753.1739
Iteration 1: log pseudolikelihood = -2525.1759
Iteration 2: log pseudolikelihood = -2327.3282
Iteration 3: log pseudolikelihood = -2324.2697
Iteration 4: log pseudolikelihood = -2324.2664
Iteration 5: log pseudolikelihood = -2324.2664
Logistic regression Number of obs = 7,352
Wald chi2(12) = 728.70
Prob > chi2 = 0.0000
Log pseudolikelihood = -2324.2664 Pseudo R2 = 0.1558
(Std. Err. adjusted for 637 clusters in SampPSU)
----------------------------------------------------------------------------------------------
| Robust
W1ExcludeYP | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
W1ethgrpYP1 |
2 | .4389618 .2122285 2.07 0.039 .0230015 .8549221
3 | 1.039686 .2147347 4.84 0.000 .6188138 1.460558
|
1.in_poverty | .3435475 .1057649 3.25 0.001 .1362522 .5508428
|
W1hiqualgMP |
Low education | .7137303 .0984105 7.25 0.000 .5208493 .9066112
|
W1SOCMajorMP |
Low occupational status | .3495525 .1262489 2.77 0.006 .1021093 .5969957
W1parmonMP | .1356613 .0679428 2.00 0.046 .0024958 .2688268
W1dispar | -.2167022 .0968772 -2.24 0.025 -.406578 -.0268263
schooldis | .2782936 .0667631 4.17 0.000 .1474403 .4091468
|
W1englangYP |
English as Foreign Language | -1.647494 1.09933 -1.50 0.134 -3.802142 .5071542
|
W1truantYP |
Truancy | .9379643 .1173101 8.00 0.000 .7080407 1.167888
substance_use | .4282403 .0922831 4.64 0.000 .2473688 .6091118
delinquency | .3303547 .0698884 4.73 0.000 .1933758 .4673335
_cons | -4.477077 .3851041 -11.63 0.000 -5.231868 -3.722287
----------------------------------------------------------------------------------------------
. margins, dydx (W1ethgrpYP1 in_poverty W1hiqualgMP W1SOCMajorMP W1parmonMP W1dispar schooldis W1englangYP W1truantYP substance_use delinquency)
Average marginal effects Number of obs = 7,352
Model VCE : Robust
Expression : Pr(W1ExcludeYP), predict()
dy/dx w.r.t. : 2.W1ethgrpYP1 3.W1ethgrpYP1 1.in_poverty 2.W1hiqualgMP 2.W1SOCMajorMP W1parmonMP W1dispar schooldis 1.W1englangYP 1.W1truantYP substance_use delinquency
----------------------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
W1ethgrpYP1 |
2 | .0357636 .0195382 1.83 0.067 -.0025305 .0740577
3 | .1024289 .0272256 3.76 0.000 .0490677 .1557902
|
1.in_poverty | .0261442 .0085119 3.07 0.002 .0094611 .0428272
|
W1hiqualgMP |
Low education | .0568304 .0087276 6.51 0.000 .0397246 .0739362
|
W1SOCMajorMP |
Low occupational status | .0271704 .0106389 2.55 0.011 .0063186 .0480222
W1parmonMP | .0097422 .0048559 2.01 0.045 .0002249 .0192595
W1dispar | -.015562 .0070022 -2.22 0.026 -.0292861 -.0018378
schooldis | .019985 .0048564 4.12 0.000 .0104666 .0295035
|
W1englangYP |
English as Foreign Language | -.0693678 .0228426 -3.04 0.002 -.1141386 -.0245971
|
W1truantYP |
Truancy | .083903 .0127278 6.59 0.000 .0589569 .1088491
substance_use | .0307531 .0066712 4.61 0.000 .0176778 .0438285
delinquency | .0237237 .0050327 4.71 0.000 .0138598 .0335875
----------------------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.
. estimates store model2
.
end of do-file
. do "C:\Users\sofiy\AppData\Local\Temp\STD33a4_000000.tmp"
. logit W1ExcludeYP i.W1ethgrpYP1 i.in_poverty i.W1hiqualgMP i.W1SOCMajorMP W1parmonMP W1dispar c.schooldis i.W1englangYP i.IndSchool i.urbind i.gor i.W1truantYP substance_use delinquency if mysample
> [pweight = Designweight], vce (cluster SampPSU) // Model 2
Iteration 0: log pseudolikelihood = -2753.1739
Iteration 1: log pseudolikelihood = -2522.6522
Iteration 2: log pseudolikelihood = -2323.8644
Iteration 3: log pseudolikelihood = -2320.7121
Iteration 4: log pseudolikelihood = -2320.7083
Iteration 5: log pseudolikelihood = -2320.7083
Logistic regression Number of obs = 7,352
Wald chi2(15) = 766.91
Prob > chi2 = 0.0000
Log pseudolikelihood = -2320.7083 Pseudo R2 = 0.1571
(Std. Err. adjusted for 637 clusters in SampPSU)
----------------------------------------------------------------------------------------------
| Robust
W1ExcludeYP | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
W1ethgrpYP1 |
2 | .4097703 .212487 1.93 0.054 -.0066964 .8262371
3 | .9929835 .2197574 4.52 0.000 .5622668 1.4237
|
1.in_poverty | .3287288 .1049728 3.13 0.002 .1229859 .5344718
|
W1hiqualgMP |
Low education | .6958219 .1006095 6.92 0.000 .498631 .8930129
|
W1SOCMajorMP |
Low occupational status | .3384298 .1268992 2.67 0.008 .0897118 .5871477
W1parmonMP | .1351199 .0676346 2.00 0.046 .0025586 .2676813
W1dispar | -.2210846 .096875 -2.28 0.022 -.4109562 -.031213
schooldis | .2744052 .066923 4.10 0.000 .1432385 .4055719
|
W1englangYP |
English as Foreign Language | -1.62687 1.101177 -1.48 0.140 -3.785137 .5313964
|
IndSchool |
Public school | .1766755 .5116462 0.35 0.730 -.8261325 1.179484
|
urbind |
Urban | .2540162 .1263526 2.01 0.044 .0063697 .5016627
|
gor |
Northern England | .0373869 .1082035 0.35 0.730 -.1746881 .249462
|
W1truantYP |
Truancy | .9279133 .1169936 7.93 0.000 .69861 1.157217
substance_use | .4377186 .0911451 4.80 0.000 .2590775 .6163597
delinquency | .3244598 .0696483 4.66 0.000 .1879517 .4609679
_cons | -4.812779 .6214717 -7.74 0.000 -6.030841 -3.594716
----------------------------------------------------------------------------------------------
. margins, dydx (W1ethgrpYP1 in_poverty W1hiqualgMP W1SOCMajorMP W1parmonMP W1dispar schooldis W1englangYP IndSchool urbind gor W1truantYP substance_use delinquency)
Average marginal effects Number of obs = 7,352
Model VCE : Robust
Expression : Pr(W1ExcludeYP), predict()
dy/dx w.r.t. : 2.W1ethgrpYP1 3.W1ethgrpYP1 1.in_poverty 2.W1hiqualgMP 2.W1SOCMajorMP W1parmonMP W1dispar schooldis 1.W1englangYP 1.IndSchool 2.urbind 2.gor 1.W1truantYP substance_use delinquency
----------------------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
W1ethgrpYP1 |
2 | .0330522 .0192119 1.72 0.085 -.0046025 .0707068
3 | .0963451 .0272313 3.54 0.000 .0429728 .1497174
|
1.in_poverty | .0249209 .0084037 2.97 0.003 .00845 .0413919
|
W1hiqualgMP |
Low education | .0551695 .0088702 6.22 0.000 .0377843 .0725547
|
W1SOCMajorMP |
Low occupational status | .0262057 .0106254 2.47 0.014 .0053803 .047031
W1parmonMP | .0096926 .0048295 2.01 0.045 .0002269 .0191583
W1dispar | -.0158591 .0069884 -2.27 0.023 -.0295561 -.0021621
schooldis | .019684 .0048648 4.05 0.000 .0101492 .0292188
|
W1englangYP |
English as Foreign Language | -.0689109 .0232851 -2.96 0.003 -.1145487 -.023273
|
IndSchool |
Public school | .0120051 .0328376 0.37 0.715 -.0523554 .0763656
|
urbind |
Urban | .0173727 .0082266 2.11 0.035 .0012487 .0334966
|
gor |
Northern England | .0026935 .0078317 0.34 0.731 -.0126562 .0180433
|
W1truantYP |
Truancy | .0826806 .0126067 6.56 0.000 .0579719 .1073893
substance_use | .031399 .0065837 4.77 0.000 .0184951 .0443028
delinquency | .0232745 .0050122 4.64 0.000 .0134507 .0330983
----------------------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.
. estimates store model3
.
end of do-file
. do "C:\Users\sofiy\AppData\Local\Temp\STD33a4_000000.tmp"
. estimates table model1 model2 model3, b(%10.3f) star stats (sd N chi2 rank aic bic) varlabel allbaselevels // appending models together
--------------------------------------------------------------------------
Variable | model1 model2 model3
-------------------------+------------------------------------------------
1 | (base) (base) (base)
2 | 0.412* 0.439* 0.410
3 | 0.902*** 1.040*** 0.993***
|
YP: Whether played tru~s |
Did not play truant | (base) (base) (base)
Truancy | 1.157*** 0.938*** 0.928***
|
substance_use | 0.442*** 0.428*** 0.438***
delinquency | 0.374*** 0.330*** 0.324***
0 | (base) (base)
1 | 0.344** 0.329**
|
DV: Highest qualificat~b |
Higher education | (base) (base)
Low education | 0.714*** 0.696***
|
DV: Major groupings fo~r |
Higher occupational s.. | (base) (base)
Low occupational status | 0.350** 0.338**
|
W1parmonMP | 0.136* 0.135*
W1dispar | -0.217* -0.221*
schooldis | 0.278*** 0.274***
|
YP: Whether English is~ |
English as Main Langu.. | (base) (base)
English as Foreign La.. | -1.647 -1.627
|
DV: Whether YP was at ~n |
Private school | (base)
Public school | 0.177
|
Urban/Rural Indicator ~) |
Non-urban | (base)
Urban | 0.254*
|
Government Office Region |
Non-Northern | (base)
Northern England | 0.037
Constant | -3.687*** -4.477*** -4.813***
-------------------------+------------------------------------------------
sd |
N | 7352 7352 7352
chi2 | 628.172 728.698 766.913
rank | 6.000 13.000 16.000
aic | 4857.797 4674.533 4673.417
bic | 4899.214 4764.268 4783.860
--------------------------------------------------------------------------
legend: * p<0.05; ** p<0.01; *** p<0.001
.
.
. putdocx clear
. putdocx begin // writes into Word
. putdocx table tb6 = etable // specifying table name
. putdocx save results3, replace // specifying document name
successfully replaced "C:/Users/sofiy/Desktop/Studies 2021-2022/Summer Term 2023/Thesis/results3.docx"
.
end of do-file

Comment