[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"FEIVESON, ALAN H. (AL) (JSC-SK) (NASA)" <alan.h.feiveson@nasa.gov> |

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

Subject |
st: RE: quadratic form calculation |

Date |
Mon, 7 Mar 2005 08:22:54 -0600 |

Stephen - This is not a complete answer to your question, but if you could "fool" Stata into thinking your B matrix is proportional to the covariance matrix of estimated regression coefficients where your x-variables are the regressors, then you could use -predict- with the "stdp" option to calculate your quadratic forms. For example, if you regress some variable y on z1, z2, ..zM and B = (Z'Z)-1 where Z'Z is the cross-product matrix of the z's, then by adding your x's as extra observations (outside the regresion sample), the command -predict blah, stdp - would give you x'Bx times a constant (the residual mean square) for every "new" observation. AL Feiveson -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Stephen P. Jenkins Sent: Monday, March 07, 2005 3:40 AM To: statalist@hsphsun2.harvard.edu Subject: st: quadratic form calculation I have M x M symmetric matrix B, and wish to calculate, for each obs in my data set, the quadratic form defined by y = xBx' where x is 1 x M vector (and x' its transpose); x is a set of variables (x1,x2,...,xM). The dimension of M is not fixed in advance (but is typically < 10); the number of observations in the data set is typically several thousand. I have not discovered existing code to do this, and -findit quadratic form- was not helpful. I want to avoid using -mkmat- (for the reasons explained in its help file). I have looked at -matrix accum- and -matrix vecaccum- but they don't appear to be applicable in this case -- but please correct me if I am wrong. I was thinking of the following strategy: 1. create M (1 x M) vectors, where the Jth vector is the Jth row of B 2. create column names for these vectors using the varnames in vector x 3. use -matrix score- to create M variables, called s1,...,sM (say), corresponding to the (Mx1) Bx' part of the quadratic form for each obs 4. generate result y = x1*s1 + x2*s2 + ... + xM*sM Comments and suggestions please. Stephen ------------------------------------------------------------- Professor Stephen P. Jenkins <stephenj@essex.ac.uk> Institute for Social and Economic Research University of Essex, Colchester CO4 3SQ, U.K. Tel: +44 1206 873374. Fax: +44 1206 873151. http://www.iser.essex.ac.uk * * 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/

- Prev by Date:
**st: RE: RE: RE: yscale/range to plot** - Next by Date:
**st: RE: RE: RE: RE: yscale/range to plot** - Previous by thread:
**st: replacement of missing values [was: RE: Help]** - Next by thread:
**st: RE: RE: RE: RE: yscale/range to plot** - Index(es):

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