matrix - Creating pairwise matrices with Stata -


i have several datasets containing roll call data various parliaments , assemblies. each dataset has between 100 , 800 observations. there few variables recognise mp/representative (name, party, consituency etc.), , remaining variables (up 1500 in cases) bills or motions upon have voted (for cases voting variables named v1, v2, v3 etc.). these variables coded numerically 1 = yay, -1 = nay, , 0 = absent/abstained.

i need create several pairwise matrices data. have managed basic functions on matrices stata, trouble i'm having finding easy way create each matrix pairwise functions. aside commonly used functions correlation , distance matrices seems has entered manually!

the first matrix need create contains proportion of times 2 representatives voted nay on same motion. ignores instances either 1 didn't vote. is, each pair of representatives, number both -1 each variable, on total number both have value other 0 each variable.

the other matrices need same, need count pairs nay-yay, yay-nay , yay-yay, if can me out how create 1 of these matrices i'll on way. i've been trying work out 4 days , literally don't have single line of code gets anywhere near i'm sorry if seems i'm asking me. total newbie matrices in stata if can give me smallest pointer appreciated.

thanks!

here's example of how first matrix:

clear  /* fake data */ input str1 voter law1 law2 law3 law4 "a" 0 1 1 1  "b" -1 -1 0 0  "c" 1 -1 1 0 "d" 0 1 1 1 "e" -1 -1 -1 -1 end  /* convert data nays vs not-nays */ recode law* (-1=1) (0=0) (1=0)  /* similarity */ matrix diss m_nay = law*, matching observations names(voter) matrix list m_nay 

as is, won't quite work missing data. can if you're willing use dissimilarity coefficient:

matrix diss m_nay = law*, gower observations names(voter) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -