/*****************************************************************/ // Public Policy Modeling // markov.do: Markov Chain (Long-term bahaviors) // Hun Myoung Park kucc625@ // International University of Japan // Graduate School of International Relations // Public Management and Policy Analsyis Program // Last modified on 05/22/2014 // Created on 02/28/2012 /*****************************************************************/ /*****************************************************************/ // Daily Weather // Using Matrix algebra: X=INV(B)*Y matrix P=(.8, .2 \ /// .6, .4) matrix B = (-.2, .6 \ /// 1, 1 ) matrix Y = (0 \ 1) matrix invB = inv(B) matrix X = inv(B)*Y matrix list P matrix list B matrix list Y matrix list X /*****************************************************************/ /*****************************************************************/ // SUV Market // Using Matrix algebra: X=INV(B)*Y matrix P=(.8, .05, .15 \ /// .1, .7, .2 \ /// .25, .15, .6) matrix B = (-.2, .1, .25 \ /// .05, -.3, .15 \ /// 1, 1, 1 ) matrix Y = (0 \ 0 \ 1) matrix invB = inv(B) matrix X = inv(B)*Y matrix list P matrix list B matrix list Y matrix list X /*****************************************************************/ /*****************************************************************/ // Poverty and Crime of a City // Using Matrix algebra: X=INV(B)*Y matrix P=(.8, .15, .05 \ /// .30, .55, .15 \ /// .05, .35, .60) matrix B = (.15, -.45, .35 \ /// .05, .15, -.40 \ /// 1, 1, 1 ) matrix Y = (0 \ 0 \ 1) matrix invB = inv(B) matrix X = inv(B)*Y matrix list P matrix list B matrix list Y matrix list X /*****************************************************************/ /*****************************************************************/ // HIV Cracker // Using Stata .matrix command matrix define Q=(.98, .01, 0 \ /// 0, .94, .04 \ /// 0, 0, .90) matrix define R=(.01 \ .02 \ .10) matrix define I=I(3) matrix IQ=inv(I-Q) matrix IQR=inv(I-Q)*R matrix list Q matrix list R matrix list IQ matrix list IQR // Using Stata Mata mata // beginning Stata MATA Q = (.98, .01, 0 \ /// 0, .94, .04 \ /// 0, 0, .90) R = (.01 \ .02 \ .10) I=I(cols(Q)) IQ=luinv(I-Q) IQR=IQ*R Q // Print Q R IQ IQR end // end of Stata MATA /*****************************************************************/ /*****************************************************************/ // Tax Appeal and Refund mata // beginning of Stata MATA Q=(.15, .20, .00, .25, .00 \ /// .00, .10, .15, .25, .00 \ /// .00, .00, .30, .00, .10 \ /// .00, .00, .00, .45, .25 \ /// .00, .00, .00, .00, .80) R=(.40, .00, .00 \ /// .25, .25, .00 \ /// .15, .35, .10 \ /// .30, .00, .00 \ /// .10, .00, .10) tax=(1500 \ 400 \ 700 \ 200 \ 100) I=I(cols(Q)) IQ=luinv(I-Q) IQR=IQ*R Q, R IQ IQR tax_IQR = IQR :* tax total = colsum(tax_IQR) tax_IQR total end // end of Stata Mata /*****************************************************************/ // end of file