asdocx: Export from Stata to Word, Excel, LaTeX & HTML › Forums › asdocx Forum › Writing Local Matrices with asdocx in Stata
-
AuthorPosts
-
Hi Attaulah,
I am working with multi-level mixed model regressions and as a second step after running the regression I am estimating the beta coefficients. I was using asdocx with the
wmat
command last week to export the matrix of estimated betas and it was working great, but I just updated asdocx this morning and now I get the error"command what is unrecognized."
I tried switching to the flexmat commands to output the matrix but when I run the following code to add the matrix to an existing table, I get the error
"Option matname() must be used with sub-command addmat"
(Which, as you can see below, I AM including…)estadd beta matrix b = e(beta) matrix betas = b' asdocx addmat, matname(betas) right dec(3)
I was previously using the following code to export a standalone table of beta coefficients and up until this morning it was working perfectly:
estadd beta matrix b = e(beta) matrix b = b' asdocx wmat, mat(b) save(Tables/Tables) title(Standard Coefficients) dec(5) fs(12) font(Times New Roman) append
Hi Isabel
Perhaps, there is a spelling mistake in the sub-commandwmat
. The error message showswhat
, notwmat
. Here is a working example.webuse nlswork, clear mixed ln_w grade age c.age#c.age ttl_exp tenure c.tenure#c.tenure || id: estadd beta matrix b = e(beta) matrix betas = b' asdocx wmat, mat(betas) right dec(3) 0 |1 2 ----+----------------------------------------------------------------------------- 1 | y1 ----+----------------------------------------------------------------------------- 2 |grade 0.345 3 |age 0.446 4 |c.age#c.age .z 5 |ttl exp 0.343 6 |tenure 0.291 7 |c.tenure#c.tenure .z 8 | cons .z 9 | cons .z 10 | cons .z ----------------------------------------------------------------------------------
Sorry autocorrect changed it to what. The error reads “command wmat is unrecognized”
Please update asdocx and try the code that I have given above. If it does not work, you can report the error message from it. If it works but does not work on your sample or code, then please post the code that you are using and the example dataset that can replicate the given error. You can post example dataset using the
dataex
program (available on ssc)Ok, it appears that the code as you suggested is working now, but is there a way to nest that output with a previously generated nested table?
Nesting is possible using the merge sub-command of the flexmat. See examples on this page (Section 10. merge) https://asdocx.com/flexmat-create-flexible-tables-in-stata-mata/. However, it is must that you have the row names exactly the same for rows that needs to be nested.
I really appreciate all of your help!
I’ve set up my data in two matrices and checked that they are in loc 1 and loc 2 using flexmat showmat, locinfo. The row names match exactly, but when I run the following code:
flexmat merge, matloc(1,2)
I get the error:
merge_matrices(): 3001 expected 6 arguments but received 5 <istmt>: - function returned error r(3001);
Do you have any suggestions for how to make the merge sub-command work?
Please update asdocx and try the following example:
asdocx_update * Reset any previous matrix flexmat reset * Add data through addcell command flexmat addcell, data(Year) r(1) c(1) flexmat addcell, data(Mean) r(1) c(2) flexmat addcell, data(SD) r(1) c(3) flexmat addcell, data(2001) r(2) c(1) flexmat addcell, data(1.5%) r(2) c(3) flexmat addcell, data(1.5%) r(2) c(3) flexmat addcell, data(5.1%) r(2) c(2) * Add more data through addrow command flexmat addrow, data(2002, 6.74, 1.68) row(3) col(1) flexmat addrow, data(2003, 6.58, 1.61) row(4) col(1) * Start a new matrix at location 2 flexmat addrow, data(Year, P75) loc(2) flexmat addrow, data(2001, 4%) loc(2) row(2) flexmat addrow, data(2004, 9.3) loc(2) row(3) * Merge the matrices at location 1 and two flexmat merge, matloc(1,2) 0 |1 2 3 4 ----+----------------------------------------------------------------------------- 1 |Year Mean SD P75 ----+----------------------------------------------------------------------------- 2 |2001 5.1% 1.5% 4% 3 |2002 6.74 1.68 4 |2003 6.58 1.61 5 |2004 9.3 ----------------------------------------------------------------------------------
-
AuthorPosts
- You must be logged in to reply to this topic.