Statalist The Stata Listserver


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

st: RE: Matrix question- square roots of matrix elements


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: RE: Matrix question- square roots of matrix elements
Date   Wed, 24 Jan 2007 20:30:06 -0500

clear
qui {
input y x1 x2 x3
123.1 1 1.92 12.4
124.3 1 2.15 9.9
89.3 1 1.67 2.4
141.3 1 1.68 13.8
112.8 1 1.75 3.5
108.1 1 1.55 1.8
143.9 1 1.54 17.8
124.2 1 2.1 9.8
110.1 1 2.44 8.3
111.7 1 2.47 9.8
123.8 1 1.86 12.6
123.5 1 1.93 11.5
110.2 1 2.47 7.4
100.9 1 2.11 6.1
123.3 1 2.1 9.5
115.7 1 1.73 8.8
116.6 1 1.86 4.9
153.5 1 2.19 18.8
149.2 1 1.9 18.9
89 1 1.67 2.3
132.6 1 2.43 14.1
97.5 1 2.13 2.9
106.1 1 2.33 5.9
115.3 1 1.75 7.6
98.5 1 2.05 5.3
135.1 1 2.35 16.8
124.2 1 2.12 8.8
98.4 1 2.13 3.2
114.8 1 1.89 5.4
142.5 1 1.5 17.3
122.6 1 1.93 11.2
127.7 1 2.27 11.2
113 1 1.66 7.9
144.2 1 1.73 17
109.2 1 1.59 3.3
106.8 1 2.29 7.1
145 1 1.86 15.3
124 1 1.91 12.7
106.7 1 2.34 6.1
153.2 1 2.13 19.6
120.1 1 2.05 6.3
119.3 1 1.89 9
150.6 1 2.12 18.7
92.2 1 1.87 2.2
130.5 1 2.09 16
112.5 1 1.76 4.5
111.8 1 1.77 4.3
120.1 1 1.94 9.3
107.4 1 2.37 8.3
128.6 1 2.1 15.4
124.6 1 2.29 9.2
127.2 1 2.36 10.2
end
}
mata:
st_view(y=.,.,"y")
st_view(X=.,.,("x1", "x2" ,"x3"))
b = invsym(X' * X) * (X' * y)
ehat = y - X * b
sigma = sqrt((ehat' * ehat)/(rows(X)-rows(b)))
se = diagonal(sqrt((sigma^2)*invsym(X' * X)))
t = b :/ se
bse = b,se,t
bse
cp = corr(variance((y,X * b),1))
r2 = cp[2,1]^2
bse
sigma
r2
end

regress y x2 x3


Note that r^2 can always be expressed as the square of the correlation of y, yhat.


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.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/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