Thanks to N. Cox, but in my original message I mean
I'd like to create a matrix B such that
B[i,j]=A[i,i]+A[j,j]-2*A[i,j]
I'm a user of Stata 8.2
---- Original message ----
>Date: Fri, 2 Dec 2005 14:07:09 -0000
>From: "Nick Cox" <[email protected]>
>Subject: st: RE: matrix creation
>To: <[email protected]>
>
>I am not sure if you mean what you say, as
>B appears on both sides here. However,
>assuming by Statalist convention that
>you are using Stata 9.1, in Mata the
>following code, given a matrix A, may help:
>
>B = A
>
>for(i = 1; i <= rows(A) ; i++) {
> for(j = 1; j <= cols(A); j++) {
> B[i,j] = A[i,i] + A[j,j] - 2 * A[i,j]
> }
>}
>
>Note how close is it to your algebra.
>
>Nick
>[email protected]
>
>U.A.QU.AP (a.k.a. AbdelRahmen)
>
>> I have a square matrix A (100x100). I’d to create a matrix
B
>> such that
>> B[i,j]=A[i,i]+B[j,j]-2*A[i,j]
>
>*
>* For searches and help try:
>* http://www.stata.com/support/faqs/res/findit.html
>* http://www.stata.com/support/statalist/faq
>* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/