Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Steve Samuels <sjsamuels@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: matrix colnames, Kronecker direct products, and factor variables |

Date |
Sun, 8 Dec 2013 13:49:29 -0500 |

Here's code that illustrates the problem again and gives a Mata solution Steve Steven J. Samuels 18 Cantine's Island Saugerties NY USA Voice: 845-246-0774 *************CODE BEGINS******************** matrix A = (1,2) matrix B = I(3) matrix colnames A = 1.x 2bn.x matrix rownames A = z matrix colnames B = 1.y 2.y 3.y matrix rownames B = b1 b2 b3 matrix C = A#B matrix list C mata: /* Get crs: Row Stripe for C */ ars = st_matrixrowstripe("A") brs= st_matrixrowstripe("B") arsn = rows(ars) brsn = rows(brs) crsn = arsn*brsn crs = J(crsn,2,"") for (j = 1; j <= crsn; j++){ crs[j,1] = ars[ceil(j/brsn),2] crs[j,2] = brs[mod(j-1,brsn) +1, 2] } /*Get ccs: Column Stripe for C */ acs = st_matrixcolstripe("A") bcs= st_matrixcolstripe("B") acsn = rows(acs) bcsn = rows(bcs) ccsn = acsn*bcsn ccs = J(ccsn,2,"") for (j = 1; j <= ccsn; j++){ ccs[j,1] = acs[ceil(j/bcsn),2] ccs[j,2] = bcs[mod(j-1,bcsn) +1, 2] } st_matrixrowstripe("C",crs) st_matrixcolstripe("C",ccs) end matrix list C ************CODE ENDS******************** On Dec 4, 2013, at 3:02 PM, Doug Hemken wrote: I don't get what I expect. The documentation I find says the columns of the product matrix, A # B, will have names from matrix B and equation names from matrix A? But if I have factor variable names for the columns of A, they simply disappear in the product. (I also notice that when I assign column names that appear to be factor variables or interaction terms, Stata alters my labels, usually for the better.) For example: matrix A = (1,21 \ 0 ,1) matrix colnames A = _cons mpg matrix B = I(2) matrix colnames B = 0.foreign 1.foreign matrix C = B' # A matrix list A matrix list B matrix list C The column labeling on C is not what I expect! -- Doug Hemken 4226I Social Science Bldg. dehemken@wisc.edu 262-4327 * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: matrix colnames, Kronecker direct products, and factor variables***From:*Doug Hemken <dehemken@wisc.edu>

- Prev by Date:
**Re: st: combining two variables into one with matching type** - Next by Date:
**Re: st: using MATA FOOBAR with LOOPs** - Previous by thread:
**Re: st: matrix colnames, Kronecker direct products, and factor variables** - Next by thread:
**st: Forecasting GDP Levels when D.GDP was used in SVAR estimation** - Index(es):