I am receiving unexpected results when using the -colnumb()- matrix function following -margins, pwcompare-. The -colnumb()- function should “return missing if the column cannot be found” (per the help file). In my case, it returns seemingly valid column numbers for columns that do not exist in the matrix. The following code should illustrate the problem:
I need to use column names instead of column numbers because I need to loop over many matrices, some of which have different numbers of columns (and thus the relevant information is not always in the same numbered column). I am using Stata/SE 13.1. Thanks.
Code:
webuse auto, clear reg price i.rep margins i.rep, pwcompare matrix list r(table_vs) matrix A = r(table_vs) di colnumb(A, "2vs1.rep78") //Returns accurate column number (1). di colnumb(A, "2vs6.rep78") //Returns inaccurate column number (1); there is no column with this name.