📄 twoway_lowess_parse.class
字号:
/* twoway_lowess_parse
A parser for lowess smoothers. Works with twoway.ado.
*/
*! version 1.0.4 16jan2003
version 8
class {
bwidth = .8
y = ""
x = ""
lowess_options = ""
} , inherit(twoway_yxview_parse)
// ---------------------------------------------------------------------------
program parse
.must_create_serset = 1
.viewtype = "line"
.Super.parse `0'
_clsarr2list mlablist : labvars // allow marker labels
local vlist `.varlist'
local 0 : list vlist -mlablist
syntax varlist(numeric min=2 max=2)
gettoken y x : varlist
.y = "`y'"
.x = "`x'"
// weights are not allowed
local 0 `"[`.wtype'`.wtexp'], `.options'"'
syntax [, ///
BWidth(real .8) ///
Mean ///
noWeight ///
Adjust ///
LOgit ///
* ///
]
.bwidth = `bwidth'
.lowess_options = "`mean' `weight' `adjust' `logit'"
.options = `"`options'"'
end
/* -------------------------------------------------------------------------*/
/*
Creates a new serset and the view and returns its reference.
Assumes that the data in memory is the same as when parse was called.
Allows a touse(varname) option that further restricts the sample,
restricts beyond the held .if and .in
Additional options to the .serset.new command may be specified, but
this is unlikely to be necessary.
If must_create_serset == 1, then this command MUST be used,
otherwise the serset may be created by other means.
*/
program log_create_serset
syntax , LOG(name) SERSETNAME(string) [ TOUSE(passthru) * ]
.log_touse , log(`log') `touse'
local nolog .`log'.Arrpush __NOLOG__
// compute the smooth values
`nolog' tempvar yhat
`nolog' lowess `.y' `.x' ///
if \`touse1' , ///
bwidth(`.bwidth') ///
`.lowess_options' ///
generate(\`yhat') ///
nograph
// label the new variable
`nolog' label variable \`yhat' "lowess `.y' `.x'"
.`log'.Arrpush ///
.`sersetname' = .serset.new ///
\`yhat' `.x' ///
if \`touse1', ///
nocount ///
`.omitmethod' ///
`options'
`nolog' .`sersetname'.sort `.x'
`nolog' .`sersetname'.sers[1].name = "`.y'"
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -