logo资料库

GMM的R程序.doc

第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
资料共4页,全文预览结束
open htv.gdt set force_hc on matrix y={wage} matrix x={const, educ} list inst = const motheduc fatheduc matrix w0 = I(3) matrix z = { inst } matrix b = invpd(x'z*(w0)*z'x)*x'z*(w0)*z'y matrix u = y - x*b scalar SSR = u'u matrix S =z'z matrix H = (SSR*S) / (rows(x)-rows(b)) matrix w1=inv(H) gmm u = y - x*b orthog u ; inst weights w0 params b end gmm gmm u = y - x*b orthog u ; inst
weights w1 params b end gmm gmm u = y - x*b orthog u ; inst weights w0 params b end gmm --iterate gmm u = y - x*b orthog u ; inst weights w1 params b end gmm --iterate 二 open htv.gdt set force_hc on matrix y={wage} matrix x={const, educ} list inst = const motheduc fatheduc matrix V0 = I(3)
matrix z = { inst } matrix b = invpd(x'z*(V0)*z'x)*x'z*(V0)*z'y matrix e = y - x*b gmm e = y - x*b orthog e ; inst weights V0 params b end gmm 三 open htv.gdt # setup for gmm matrix y={wage} matrix x={const, educ} matrix w=I(3) matrix z={const,motheduc,fatheduc} matrix b1 = inv(x'z*(w)*z'x)*x'z*(w)*z'y print "estimated coefficient vector" b1 matrix u = y - x*b1
#scalar SSR=u'u matrix S =z'u*u'*z matrix H = S/ (rows(x)-rows(b1)) H matrix M =inv(x'z*(w)*z'x)*x'z*(w) matrix N =(w)*z'x*inv(x'z*(w)*z'x) matrix V = M*(H)*N V matrix se = sqrt(diag(V)) print "estimated standard errors" se
分享到:
收藏