📄 scoreplot.ado
字号:
*! version 1.0.1 16mar2005
program scoreplot
version 9.0
if "`e(cmd)'" == "" {
error 301
}
else if !inlist("`e(cmd)'","pca","factor") {
dis as err "scoreplot is only allowed after factor and pca"
exit 301
}
syntax [if] [in], ///
[ ///
FACtors(str) ///
COMponents(str) ///
noROTated ///
SCOREopt(str) ///
COMBINEd ///
MATRIX ///
* ///
]
if "`e(cmd)'" == "factor" {
local fname factor
}
else {
local fname component
}
if `e(f)' == 1 {
dis as err "only one `fname' retained"
exit 321
}
if "`combined'" != "" & "`matrix'" != "" {
display as error ///
"options matrix and combined may not be specified together"
exit 198
}
if `"`factors'"' != "" & `"`components'"' != "" {
display as error ///
"options factors() and components() may not be combined"
exit 198
}
if `"`factors'"' == "" & `"`components'"' == "" {
local f = 2
}
else {
local f = `components' `factors'
confirm integer number `f'
if ! inrange(`f',2,e(f)) {
display as error "option " ///
=cond("`components'" != "", ///
"components()", "factors()") ///
" invalid; out of range"
display as error ///
"expected " ///
= cond(`e(f)' == 2, "value is 2" , ///
"between 2 and `e(f)'")
exit 125
}
}
if ((`f' > 2 | "`matrix'" != "") & "`combined'" == "") {
local isMatrix = 1
}
else {
local isMatrix = 0
local getcombine getcombine
}
// parse graph options
_get_gropts , graphopts(`options') getallowed(scheme) `getcombine'
if `"`s(scheme)'"' != "" {
local scheme `"scheme(`s(scheme)')"'
}
local options `"`s(graphopts)'"'
local gcopts `"`s(combineopts)'"'
// create scores
marksample touse
forvalues i = 1 / `f' {
tempvar s`i'
local slist `slist' `s`i''
}
quietly predict `slist' , notable `rotated' `scoreopt'
forvalues i = 1/`f' {
local scname`i' : var label `s`i''
if "`scname`i''" == "" {
local scname`i' "score `i'"
}
}
local title `"Score variables (`e(cmd)')"'
if "`rotated'" != "norotated" & "`e(r_criterion)'" != "" {
if "`e(r_class)'`e(r_ctitle)'" != "" {
local rotation `""Rotation: `e(r_class)' `e(r_ctitle)'""'
}
if "`e(mtitle)'" != "" {
local method `""Method: `e(mtitle)'""'
}
local note note(`rotation' `method')
}
if `isMatrix' {
graph matrix `slist' if `touse', title(`title') `note' ///
`scheme' `options'
}
else {
// make individual plots
tempvar p
forvalues i = 1/`f' {
forvalues j = 1 / `=`i'-1' {
tempname f`i'_`j'
local clist `clist' `f`i'_`j''
scatter `s`i'' `s`j'' if `touse', ///
ytitle(`scname`i'') ///
xtitle(`scname`j'') ///
nodraw name(`f`i'_`j'') ///
`scheme' `options'
}
}
// show combined plot
graph combine `clist' , title(`title') `note' `scheme' `gcopts'
graph drop `clist'
}
end
exit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -