<>
Here are a few ways to do what you want. Note that -matrix accum- will
create the matrices (like X'X) that you need for most statistical
applications, thereby circumventing the need to create full data
matrices in Stata.
********************
clear*
set obs 10000
forv i=1/10 {
g z`i' = `i'+`i'*invnormal(uniform())
// or rnormal()
}
egen y = rowtotal(z*)
forv i=1/10 {
qui reg y z`i'
predict e`i', resid
}
mat accum ee = e*, nocons
mat ee=ee/(_N-1) // using Stata matrices
matlist ee
corr e*, cov // Stata
// mata
mata
X=st_data(.,(st_nvar()-9..st_nvar()))
makesymmetric(X'X/(rows(X)-1)) // calculation in Mata
end
********************
T
On Thu, Jul 16, 2009 at 11:48 PM, Kit Baum<[email protected]> wrote:
> <>
> I am calculating the covariance between two measurements predicted after a
> model fitting. This covariance involves some matrix operations of the
> covariates matrix. That's why I need the matrix.
>
> You can perform those operations on matrix X within Mata, per my prior
> message.
>
> Kit Baum | Boston College Economics & DIW Berlin |
> http://ideas.repec.org/e/pba1.html
> An Introduction to Stata Programming |
> http://www.stata-press.com/books/isp.html
> An Introduction to Modern Econometrics Using Stata |
> http://www.stata-press.com/books/imeus.html
>
>
>
> *
> * 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/
>
--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).
*
* 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/