All commands
# |
content
|
3 [+]
|
use
crspsubseta
, clear
All properties
key |
content |
command |
use |
indent |
0 |
options |
clear |
parameters |
crspsubseta |
|
4 [+]
|
label
def ind 1 Kappa 2 Lambda 3 Nu 4 Xi 5 Tau 6 Upsilon 7 Phi 8 Chi 9 Psi
|
5 [+]
|
qui
levelsof
hiord
, local(indices)
|
6 [+]
|
local
nind : word count `indices'
All properties
key |
content |
command |
local |
indent |
0 |
parameters |
nind : word count `indices' |
|
7 [+]
|
qui
levelsof
permno
, local(firms)
All properties
key |
content |
command |
levelsof |
indent |
0 |
options |
local(firms) |
parameters |
permno |
prefix |
qui |
|
8 [+]
|
local
nf : word count `firms'
All properties
key |
content |
command |
local |
indent |
0 |
parameters |
nf : word count `firms' |
|
9 [+]
|
matrix
retcorr = J(`nf', `nind', .)
All properties
key |
content |
command |
matrix |
indent |
0 |
parameters |
retcorr = J(`nf', `nind', .) |
|
11 [+]
|
local
n 0
All properties
key |
content |
command |
local |
indent |
0 |
parameters |
n 0 |
|
12 [+]
|
qui
gen
meanret = .
All properties
key |
content |
command |
gen |
indent |
0 |
parameters |
meanret = . |
prefix |
qui |
|
13 [+]
|
qui
gen
ndays = .
All properties
key |
content |
command |
gen |
indent |
0 |
parameters |
ndays = . |
prefix |
qui |
|
14 [+]
|
local
row = `nind' + 1
All properties
key |
content |
command |
local |
indent |
0 |
parameters |
row = `nind' + 1 |
|
15 [+]
|
foreach
f of local firms {
All properties
key |
content |
command |
foreach |
indent |
0 |
parameters |
f of local firms { |
|
16 [+]
|
qui
correlate
index1-index`nind' ret
if permno == `f'
|
17 [+]
|
matrix
sigma = r(C)
All properties
key |
content |
command |
matrix |
indent |
1 |
parameters |
sigma = r(C) |
|
18 [+]
|
local
++n
All properties
key |
content |
command |
local |
indent |
1 |
parameters |
++n |
|
19 [+]
|
forvalues
i = 1/`nind' {
All properties
key |
content |
command |
forvalues |
indent |
1 |
parameters |
i = 1/`nind' { |
|
20 [+]
|
matrix
retcorr[`n', `i'] = sigma[`row', `i']
All properties
key |
content |
command |
matrix |
indent |
2 |
parameters |
retcorr[`n', `i'] = sigma[`row', `i'] |
|
21 [+]
|
}
All properties
key |
content |
command |
} |
indent |
1 |
parameters |
|
|
22 [+]
|
summarize
ret
if permno == `f'
, meanonly
All properties
key |
content |
command |
summarize |
if |
permno == `f' |
indent |
1 |
options |
meanonly |
parameters |
ret |
|
23 [+]
|
qui
replace
meanret = r(mean)
in `n'
All properties
key |
content |
command |
replace |
in |
`n' |
indent |
1 |
parameters |
meanret = r(mean) |
prefix |
qui |
|
24 [+]
|
qui
replace
ndays = r(N)
in `n'
All properties
key |
content |
command |
replace |
in |
`n' |
indent |
1 |
parameters |
ndays = r(N) |
prefix |
qui |
|
25 [+]
|
}
All properties
key |
content |
command |
} |
indent |
0 |
parameters |
|
|
30 [+]
|
svmat
double retcorr
All properties
key |
content |
command |
svmat |
indent |
0 |
parameters |
double retcorr |
|
31 [+]
|
qui
egen
double maxretcorr = rowmax(retcorr*)
|
32 [+]
|
qui
generate
highcorr = .
All properties
key |
content |
command |
generate |
indent |
0 |
parameters |
highcorr = . |
prefix |
qui |
|
33 [+]
|
forvalues
i = 1/`nind' {
All properties
key |
content |
command |
forvalues |
indent |
0 |
parameters |
i = 1/`nind' { |
|
34 [+]
|
qui
replace
highcorr = `i'
if maxretcorr == retcorr`i'
|
36 [+]
|
}
All properties
key |
content |
command |
} |
indent |
0 |
parameters |
|
|
38 [+]
|
gsort
-meanret highcorr
All properties
key |
content |
command |
gsort |
indent |
0 |
parameters |
-meanret highcorr |
|
39 [+]
|
label
values highcorr ind
|
40 [+]
|
list
permno meanret ndays highcorr
in 1/50
, noobs sep(0)
|