Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: calculations behind syminv( )


From   "victor michael zammit" <[email protected]>
To   <[email protected]>
Subject   st: Re: calculations behind syminv( )
Date   Sun, 25 May 2003 23:02:33 +0200

Dear Statalisters,
given the following dataset ,can anyone help me with what goes on in
minv(  ) ,that is to say how I could get " matrix list XZi" ,by hand
especially for more than two independent variables...
              Y          X          Z
  1.         1          2          4
  2.         2          3          6
  3.         3          5          7
  4.         4          5          9

. do "C:\WINDOWS\TEMP\STD010000.tmp"

. matrix accum YXZ = Y X Z
(obs=4)

. local nobs = _result(1)

. local nvar = rowsof(YXZ)

. local nvarm1 = `nvar' - 1

. matrix XZ = YXZ[2...,2...]

. matrix Xy = YXZ[1,2...]

. matrix XZi = syminv(XZ)

. matrix b = Xy * XZi

. matrix pv = b * Xy'

. local df = `nobs'  - `nvarm1'

. scalar rv = (YXZ[1,1] - pv[1,1])/`df'

. matrix V = XZi * rv

. matrix post b V , dof(`df') obs(`nobs') depname(Y)

. matrix mlout
----------------------------------------------------------------------------
--
       Y |      Coef.   Std. Err.       t     P>|t|       [95% Conf.
Interval]
---------+------------------------------------------------------------------
--
       X |   .2258065   .1163081      1.941   0.303      -1.252028
1.703641
       Z |   .4677419   .0838089      5.581   0.113      -.5971512
1.532635
   _cons |  -1.387097   .2446089     -5.671   0.111      -4.495147
1.720954
----------------------------------------------------------------------------
--

.
end of do-file

. matrix list YXZ

symmetric YXZ[4,4]
           Y      X      Z  _cons
    Y     30
    X     43     63
    Z     73    106    182
_cons     10     15     26      4

. matrix list XZ

symmetric XZ[3,3]
           X      Z  _cons
    X     63
    Z    106    182
_cons     15     26      4

. matrix list XZi

symmetric XZi[3,3]
                X           Z       _cons
    X   .83870968
    Z   -.5483871   .43548387
_cons   .41935484  -.77419355   3.7096774

.
Thank you very much,
Victor M.Zammit

*
*   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/



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