Hi,
I would like to compute the following in Stata:
Sum over all n of: Sum over all m unequal n of:
(D_nt - p)*(D_mt - p),
where m, n, t are subindices.
If it was with only a single sum and without the unequal condition, I
would just have used sth like this:
bysort m n t: gen factor1 = (D_nt - p)
bysort m n t: gen factor2 = (D_mt - p)
bysort t: egen result = sum(factor1*factor2)
But I'm not sure how to get the product for each element n with each
other element from the same set except itself.
Should I do this with a loop or sth?
Many thanks,
Chris
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/