[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: manipulating matrix elements
I am trying to implement the following formula for estimating the
(standardized) informational entropy of a RxC contingency table:
sum(p*ln(p))+ln(M) where p (subscript ij omitted) is the proportion of
cases in each cell and M is the total number of cells. So far, I've
only managed to accomplish the following:
tab var1 var2, matcell(Cell)
matrix Proportions = Cell/r(N)
Frankly, I'm amazed I've managed even this much, but now I'm stuck.
What I need to do (as I understand it) is take the natural log of each
element of the Proportions matrix, multiply it times its corresponding
proportion, sum up all the elements, and add ln(M).
For some (probably good) reason, while you can easily multiply matrix
elements by a scalar, you can't do something like:
matrix LnP = ln(Proportions)
I've tried this, but it gives a type mismatch error. Again, I'm sure
this is for a good reason, but I'm not sure what to do.
So any idea what I should do?
National Science Foundation Graduate Research Fellow
Caroline H. and Thomas S. Royster, Jr. Fellow
Department of Sociology
University of North Carolina at Chapel Hill
200 Hamilton Hall (CB #3210)
Chapel Hill, NC 27599
* For searches and help try: