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

st: RE: question matrix

From   "Nick Cox" <>
To   <>
Subject   st: RE: question matrix
Date   Mon, 2 Sep 2002 19:34:42 +0100

Michael Dobbins

> I am currently dealing with the following problem. I have a
> dataset with 86
> variables (representing legislative proposal of the
> European Commission) and
> 17 objects - the 15 member states with the European
> PArliament and the
> Commission. The Cells represent the preferences of the
> actors (0-100) on the 86 issues.
> I am trying to figure out how often the 17 actors have
> identical values,
> i.e. preferences across the 86 variables. Additionally, I
> must find out how
> many different political dimensions (e.g. pro vs. anti-integration,
> left-right, regulation-non-regulation) these preference
> configurations
> represent.
> This probably involves the creation of 86 identical
> matrixes and dummy
> values of 1 meaning identical preferences and 0
> non-identical preferences.
> How can this be done in Stata? I have very little
> experience with the
> program or statistics in general.
> Thanks a lot in advance.
> yours
> Michael

On 26 February 2002, I replied to Dietrich Drüner who asked
a remarkably similar question:

> I am currently fighting with the following problem:
> I have a dataset with 86 variables (which represent proposals for
> legislation of the Commission of the European Union) and 17 objects
> represent the 15 member states of the EU plus the European
Parliament and
> the Commission itself) with the cells representing political
> preferences of
> these actors (on a scale from 0 to 100) regarding a specified
> issue.
> I need to know how often - across the 86 variables (=legislative
> proposals)
> the 17 actors have identical values (=preferences), each actor with
> other actor.
> I guess the problem requires to create 86 structurally identical
> with the actors as rows as well as columns (17x17-matrices) and
> dummy-values
> in the cells with 1 meaning identical preferences and 0 non
> preferences. And then to add up the 86 matrices to find out the
> frequencies.
> But how do I do this in STATA (I know no other statistical software
> for a bit of SPSS)???

Here is a revised version of my posting.

Supposing you have variables <varlist>, you
can do the matrix calculation via a triple loop

matrix agree = J(17,17,0)
foreack v of var <varlist> { /* outer */
	forval j = 1/17 { /* middle */
		forval i = 1/17 { /* inner */
			local yesno = `v'[`i'] == `v'[`j']
			mat agree[`i',`j'] = agree[`i',`j'] + `yesno'

where my comments like /* outer */ are primarily designed
to spite a mailer bug. You can put the code in Stata's
do-file editor and run it, after replacing


with a list of your own variables. Going through that
more slowly,

initialise a 17 x 17 matrix to 0s

for each of 86 variables
	for values 1/17
		for values 1/17
			is this value equal to that value?
			add result (1 or 0) to count so far

Down the principal diagonal you will get, necessarily, 86.
You might want to modify that.

And the multivariate manipulations to extract those "dimensions"?
I am, I confess, unclear how you know they are lurking beneath
these data. Multivariate mavens can debate how best to do it.
My prejudice is that the agreement matrix is a poor starting
place, given that it keeps so little of the information
in the original data.


*   For searches and help try:

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