📄 mdsshepard.ado
字号:
*! version 1.0.1 16mar2005
program mdsshepard
version 9.0
if !inlist("`e(cmd)'","mds","mdsmat","mdslong") {
error 301
}
syntax [, ///
SEParate ///
noTRANSform ///
BYOpts(string) ///
AUTOaspect ///
ASPECTratio(str) ///
* ///
]
local id `e(id)'
local nid : word count `e(id)'
if `nid' == 1 {
local id1 `id'1
local id2 `id'2
}
else if `nid' == 2 {
local id1 : word 1 of `e(id)'
local id2 : word 2 of `e(id)'
}
else {
_stata_internalerror
}
if "`aspectratio'" != "" & "`autoaspect'" != "" {
display as error ///
"options aspectratio() and autoaspect may not be combined"
exit 198
}
if "`separate'" == "" & "`byopts'" != "" {
display as error ///
"option byopts() may only be specified with separate option"
exit 198
}
if "`separate'" != "" {
local full full
}
tempfile f
quietly predict dissimilarity distance residual, ///
pairwise saving(`"`f'"') `full' `transform'
local tf = cond("`transform'" == "", "transformed", "raw")
preserve
quietly use `"`f'"', clear
quietly drop if `id1' == `id2'
label var dissimilarity
label var distance
summarize dissimilarity, meanonly
local xmin `r(min)'
local xmax `r(max)'
summarize distance, meanonly
local ymin `r(min)'
local ymax `r(max)'
.atk = .aspect_axis_toolkit.new
.atk.setPreferredLabelCount 7
_parse comma aspect_ratio placement : aspectratio
if "`aspect_ratio'" != "" {
confirm number `aspect_ratio'
.atk.setPreferredAspect `aspect_ratio'
.atk.setShowAspectTrue
}
if "`autoaspect'" != "" {
.atk.setAutoAspectTrue
}
.atk.getAspectAdjustedScales , ///
xmin(`xmin') xmax(`xmax') ymin(`ymin') ymax(`ymax')
local note note(Classical MDS, span)
local ytitle ytitle(fitted distances)
local xtitle xtitle(`tf' dissimilarities)
if "`separate'" == "" {
local title title(Shepard diagram)
twoway (scatter dist dissim, `title' `note' legend(off) ///
aspectratio(`s(aspectratio)'`placement') ///
`xtitle' `ytitle' `s(scales)' `options' ///
) ///
(function y=x, range(dissim)),
}
else {
dis as txt "(mdsshepard is producing a separate " ///
"plot for each obs; this may take a while)"
local title title(Shepard diagrams)
twoway (scatter dist dissim, `xtitle' `ytitle' ///
aspectratio(`s(aspectratio)'`placement') ///
`s(scales)' `options' ///
) ///
(function y=x, range(dissim)) , ///
by(`id1', note("") legend(off) compact ///
`title' `note' `byopts' ///
)
}
end
exit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -