Forum Replies Created
-
AuthorPosts
-
I forgot to change a macro in the table1 template, this is why dec() and dect() had no effect on the output. I have fixed that. You can update to the beta version and test it. To update, please type:
asdocx_update, beta mlib
Here is an example where I would like to report 4 dp for the p-values and 1 dp for the percentages.
asdocx tabulate diabetes i.agegrp , template(table1) /// col dec(1) dect(1) replace
Table 1: DemographicsVariables Not diabetic (n=9850) Diabetic (n = 499) Total (10349) P-value Age group 0.0000 20–292305 (23.4%) 15 (3.0%) 2320 (22.4%) 30–391600 (16.2%) 21 (4.2%) 1621 (15.7%) 40–491229 (12.5%) 42 (8.4%) 1271 (12.3%) 50–591219 (12.4%) 72 (14.4%) 1291 (12.5%) 60–692622 (26.6%) 238 (47.7%) 2860 (27.6%) 70+875 (8.9%) 111 (22.2%) 986 (9.5%) P-values by t-test for continuous variables and Chi2 test for binary/categorical variables. On your request, I have now added support for
estat teffects
sub-command. The full syntax and examples are discussed on this page https://asdocx.com/table-of-direct-indirect-and-total-effects-after-sem-word-excel-latex-stata/
It is being released in the beta version of asdocx, therfore, first you need to run this code to get the beta versionasdocx_update, beta mlib
in reply to: Export xttab to LaTeX with asdocx #16613I have now added xttab to asdocx, here is an example
* Load example data webuse nlswork xtset idcode year * use xttab with asdocx asdocx xttab race
race Overall Between Overall value Freq Percent Freq Percent Percent white 20180 70.723 3329 70.664 100 black 8051 28.215 1325 28.126 100 other 303 1.062 57 1.21 100 Total 28534 100 4711 100 100 Notes: In the nested regressions, you can add any statistics that is available in the
e()
macro. This is documented in the help file of asdocx, type help asdocx and then browse to the section4.10
, you shall find the relevant details and example. Here is one example. Since the log likelihood is reported in thee(ll)
macro, we need to add the optionstat(ll)
.webuse rod93 , clear generate logexp=ln(exposure) asdocx nbreg deaths i.cohort , exposure(exp) nest stat(ll)
Table: Regression results(1) deaths 1b.cohort 2.cohort -0.268 (0.724) 3.cohort -0.457 (0.724) Intercept -2.087*** (0.512) /lnalpha 0.594** (0.258) Observations 21 Pseudo R2 0.002 ll -131.38 Notes: \iStandard errors are in parentheses. *** p<.01, ** p<.05, * p<.1 I have added
xtmlogit
to asdocx in its latest update. You can update and try it. Here is an examplewebuse estatus xtset id asdocx xtmlogit estatus i.hhchild age hhincome i.hhsigno i.bwinner , label abb(.)
Random-effects multinomial logistic regressionestatus Coef. St.Err. t-value p-value [95% Co Interval] Sig Children <18 years old in household : base No 0 . . . . . Yes 0.463 0.096 4.81 0 0.274 0.652 *** Age (in years) -0.005 0.007 -0.73 0.468 -0.018 0.008 Annual household income (in $1,000s) -0.005 0.002 -2.55 0.011 -0.008 -0.001 ** Significant other living in household : base No 0 . . . . . Yes 0.497 0.095 5.25 0 0.311 0.682 *** Primary/sole breadwinner in household : base No 0 . . . . . Yes -0.474 0.073 -6.51 0 -0.617 -0.331 *** Constant -0.479 0.285 -1.68 0.092 -1.036 0.079 * Children <18 years old in household : base No 0 . . . . . Yes -0.04 0.12 -0.34 0.737 -0.275 0.194 Age (in years) 0.004 0.008 0.52 0.602 -0.012 0.02 Annual household income (in $1,000s) -0.031 0.003 -11.63 0 -0.036 -0.026 *** Significant other living in household : base No 0 . . . . . Yes 0.097 0.119 0.81 0.417 -0.137 0.331 Primary/sole breadwinner in household : base No 0 . . . . . Yes -0.225 0.095 -2.37 0.018 -0.412 -0.039 ** Constant -0.095 0.351 -0.27 0.786 -0.783 0.592 var(u1) 0.859 0.109 .b .b 0.67 var(u2) 0.737 0.139 .b .b 0.509 1.066 Prob > chi2 Akaike crit. (AIC) 8965.683 I think what you are asking for is available in the reg1 template.
See details here https://asdocx.com/creating-and-working-with-asdocx-template-files/reg1-template-of-asdocx-regression-for-epidemiology/.asdocx nbreg daysabs mathnce langnce female , irr template(reg1)
An example of using the reg1 template command and its results are given below.
Table: Regression Results – daysabsVariable OR [95% CI] P-value ctbs math nce 0.998 [0.989, 1.008] 0.741 ctbs lang nce 0.986 [0.975, 0.997] 0.010 female 1.539 [1.171, 2.024] 0.002 Constant 9.825 [6.511, 14.824] 0.000 /lnalpha 0.253 [0.066, 0.441] .b _diparm1:alpha 1.288 [1.068, 1.554] .b Observations 316 Seems you need the
tableonly
option, that creates just the table without the file header and package list. For exampleasdocx cor Diaper GetupNight PutBabyToSleep PlayWithBaby , /// save(CorrCaringWork.tex) abb(.) title(\notitle) replace tableonly
Also, in the master file where you call the input(), you should include the following lines to the package list
\usepackage{tabularx, booktabs, threeparttable, caption} \captionsetup{font=bf, aboveskip=1ex, belowskip=2ex} \usepackage{multirow}
I shall look into the table
title(\i)
, obviously, it is not working.Adding support for
factor
will take some time. However, you can quickly export the tables of factor command using thewmat
command of asdocx, that is writing matrix. See this example.* Load example data webuse bg2, clear * Run the factor command factor bg2cost1-bg2cost6 * Save the matrix in L mat L = e(L) * Export the matrix with asdocx using wmat command asdocx wmat, mat(L) replace title(Factor loadings (pattern matrix)
Factor loadings (pattern matrix) and unique variancesFactor1 Factor2 Factor3 bg2cost1 0.247 0.367 -0.045 bg2cost2 -0.337 0.332 -0.077 bg2cost3 -0.376 0.376 0.02 bg2cost4 -0.322 0.194 0.103 bg2cost5 0.455 0.248 0.064 bg2cost6 0.476 0.236 -0.007 in reply to: xtgcause not working with asdocx #16431The command xtgcause is not a Stata official command. Hence asdocx is not aware of that. The help file of xtgcause shows that the command leaves scalar in r(), and hence these can be written with flexmat and then exported with asdocx. Here is an example.
The dataset Data_demo.xls used in this example is provided by Dumitrescu and Hurlin at
http://www.runmycode.org/companion/view/42, along with a few results.. import excel using Data_demo.xls, clear . ren (A-J) x#, addnumber . ren (K-T) y#, addnumber . gen t = _n . reshape long x y, i(t) j(id) . xtset id t . xtgcause y x, lag(1)
Now create the table from the scalars with flexmat
flexmat reset flexmat addrow, data(Lag order, `r(lags)', \empty, \empty) row(1) flexmat addrow, data(W-bar, `r(wbar)', \empty, \empty) row(2) dec(3) flexmat addrow, data(Z-bar, `r(zbar)', p-value, `r(zbar_pv)') row(3) dec(3) flexmat addrow, data(Z-bar tilde, `r(zbart)', p-value, `r(zbart_pv)') row(4) dec(3) asdocx export
Table: ResultsLag order 1 W-bar 1.291 Z-bar 0.650 p-value 0.515 Z-bar tilde 0.259 p-value 0.796 I have now updated the core of asdocx. It handles the interaction terms in a graceful manner. Following are few examples.
asdocx_update webuse nhanes2b * Interaction of continuous variables asdocx reg hgb hdresult c.tgresult#c.weight , nest replace abb(.) asdocx reg hgb hdresult c.tgresult#c.hct , nest abb(.)
Table: Regression results(1) (2) hgb hgb hdresult -0.019*** -0.016*** (0.002) (0.001) tgresult × weight 0*** (0) tgresult × hct 0*** (0) Intercept 14.951*** 14.575*** (0.096) (0.096) Observations 4222 4222 R\super2 0.08 0.107 Table: Regression results(1) (2) hgb hgb hdresult -0.013*** -0.009*** (0.001) (0.001) sex × tgresult 0.004*** (0) Female × tgresult -0.003*** (0) sex × tibc 0.004*** (0) Female × tibc 0 (0) Intercept 14.79*** 14.076*** (0.09) (0.09) Observations 4222 8720 R\super2 0.23 0.322 I have update the asdocx package. The update adds a new sub-command
change(old, new)
to flexmat to find and replace existing string with new string. Therefore, if you want to change the#
withx
, the option change will be used aschange("#", " x ")
. See the following example*update asdocx asdocx_update * Load example data sysuse auto * Estimate a regression with interaction terms asdocx reg price c.turn#c.trunk, replace nest 0 |1 2 ----+----------------------------------------------------------------------------- 1 | (1) 2 | price ----+----------------------------------------------------------------------------- 3 |c.turn#c.trunk 4.737*** 4 | (1.515) 5 |Intercept 3528.565*** 6 | (903.25) 7 |Observations 74 8 |R2 0.12 ---------------------------------------------------------------------------------- * Replace the # string with x flexmat change(#, " x ") 0 |1 2 ----+----------------------------------------------------------------------------- 1 | (1) ----+----------------------------------------------------------------------------- 2 | price 3 |c.turn x c.trunk 4.737*** 4 | (1.515) 5 |Intercept 3528.565*** 6 | (903.25) 7 |Observations 74 8 |R\super2 0.12 ---------------------------------------------------------------------------------- * Replace c. string with empty flexmat change(c., "") * Finally, export the modified table asdocx export
asdocx can report lables for variables, but not for interaction terms. You can suggest any standard practice in your field and I shall try to come up with a solution. For this, you may refer a paper or send your own example to show how interaction terms should be reported.
in reply to: margins function not complying with asdocx #16413margins is still in the beta version. You can update to beta version by
asdocx_update, beta
This is documented in the flexmat help file.
help flexmat
Section 9 of the help file reads
9. addparts:
Sub-command addparts with optionnotes(Table notes text)
adds table notes to the current table. Table notes appear at the bottom of the
table when the table is exported with asdocx. When sub-command addparts is used with optiontitle(Table title text)
, it sets the table
title.flexmat reset mat A = (1,2,3\ 4,5,6\ 7,8,9) matrix rownames A = myrow1 myrow2 myrow3 mat colnames A = mycol1 mycol2 mycol3 flexmat addmat, matname(A) flexmat addparts, title(My Stata matrix) notes(My notes from flexmat) My Stata matrix 0 |1 2 3 4 ----+------------------------------------------------------------------ 1 | mycol1 mycol2 mycol3 ----+------------------------------------------------------------------- 2 |myrow1 1 2 3 3 |myrow2 4 5 6 4 |myrow3 7 8 9 ------------------------------------------------------------------------ My notes from flexmat
This issue is now fixed in the asdocx beta version. I have added the new features to the beta version of asdocx. All new features are first added to the beta version. Once that version is stable, it is released as a regular version. To install the new version, copy and paste the following line in Stata and press enter.
asdocx_update, beta
Restart Stata after installation of the new version.
Here is an example
mat A = (1,2,3\ 4,5,6\ 7,8,9) matrix rownames A = myrow1 myrow2 myrow3 mat colnames A = mycol1 mycol2 mycol3 flexmat addmat, matname(A) 0 |1 2 3 4 ----+-------------------------------------------------------------------- 1 | mycol1 mycol2 mycol3 ----+--------------------------------------------------------------------- 2 |myrow1 1 2 3 3 |myrow2 4 5 6 4 |myrow3 7 8 9 ---------------------------------------------------------------------------
-
AuthorPosts