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

From |
"Glenn Goldsmith" <glenn.goldsmith@gmail.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: -gen double- or -gen- |

Date |
Tue, 17 Mar 2009 02:11:04 -0000 |

Hi Jingjing, Didn't we already do this the other day: http://www.stata.com/statalist/archive/2009-03/msg00366.html? >I am wondering if -M= = st_matrix("M")- here make sure it is a *symmetric* matrix with the elements h11 h21... that I just generated. -st_matrix("M")- will return whatever is in your stata matrix M. If your stata matrix M is symmetric, then it will return a symmetric matrix. If not, then it won't. You've said that your stata matrix is Tx10, so that's what you'll get. But I don't think you want M to be symmetric anyway; you want mt to be symmetric. The expression mt = invvech(M[., t]) extracts the tth column of M and tries to turn it into a symmetric matrix. But that won't work, because it's the *rows* of M that contain the h* values you want to use. mt = invvech(M[t,.]') should give you what you want (the transpose is necessary because -invvech()- requires a colvector argument). Alternatively, if you only want to transpose once, it may be slightly more efficient to code: M = st_matrix("M")' At the top of your routine, and leave the rest as is. Best wishes, Glenn. jjc.li@utoronto.ca wrote: Thanks Maarten, I know what's "double" now. And I have to corrected my expression in the previous email. I first use -gen-... to calculate the elements of matrix M. Then -mkmat h*, mat(M)- creat matrix M as T*10, where T is the mumver of observations in the sample and there are 10 elements in the lower triangle of the matrix for a specific period Now I want to calculate the eigenvalues of the matrix for each time period: mata: M = st_matrix("M") lambda = J(cols(M), 4, .) for(t=1; t<=cols(M); t++) { mt = invvech(M[., t]) lambda[t, .] = symeigenvalues(mt) } lambda end I am wondering if -M= = st_matrix("M")- here make sure it is a *symmetric* matrix with the elements h11 h21... that I just generated. * * 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/

**Follow-Ups**:**Re: st: -gen double- or -gen-***From:*jjc.li@utoronto.ca

- Prev by Date:
**Re: st: twoway scatter returns "unmatched quote"** - Next by Date:
**st: loglikelihood and loglikelihood ratio** - Previous by thread:
**st: Skewness and kurtosis** - Next by thread:
**Re: st: -gen double- or -gen-** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |