-
Notifications
You must be signed in to change notification settings - Fork 6
/
calculate_coherence.ado
executable file
·66 lines (49 loc) · 1.54 KB
/
calculate_coherence.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
*===========================================================================
* File has two posible measures of coherence
*===========================================================================
/*
// Coherence Calculations // Sebastian's Measure
capture program drop calculate_coherence
program calculate_coherence
mata coh_c = J(Nix, 1, 1)
mata coh_p = J(Npx, 1, 1)
forvalues c=1/$Ni {
loc c = 1
mata tempc = M[`c',.] :* proximity
mata tempc[1,.]
mata tempc[2,.]
mata coh_c[`c'] = sum(tempc[1,.])/sum(M[`c',.])
mata coh_c
}
mata tempc = M :* proximity
mata mata des tempc
mata tempc[1,]
forvalues p=1/$Np {
mata tempp = M[.,`p'] :* country_proximity
mata coh_p[`c'] = sum(tempp[1,.])/sum(M[.,`p'])
}
*mata coh_c = coh_c * J(1, Npx, 1)
*mata coh_p = J(Nix, 1, 1) * coh_p'
end
*/
*===========================================================================
*===========================================================================
// Coherence Calculations // Muhammed's Measure
capture program drop calculate_coherence
program calculate_coherence
mata coh_c = J(Nix, 1, 1)
mata coh_p = J(Npx, 1, 1)
forvalues c=1/$Ni {
mata M_c = M[`c',.]
mata M_pp = M_c * M_c'
mata coh_c[`c'] = sum(M_pp :* proximity)
}
forvalues p=1/$Np {
mata M_p = M[.,`p']
mata M_cc = M_p * M_p'
mata coh_p[`p'] = sum(M_cc :* country_proximity)
}
mata coh_c = coh_c * J(1, Npx, 1)
mata coh_p = J(Nix, 1, 1) * coh_p'
end
*===========================================================================