📄 twoway_lfit_parse.class
字号:
// twoway_lfit_parse
//
// A parser for adding a linear fit line. Works with twoway.ado.
//
// Consider making a derived view version where the fit is able to rederive
// itself from the original data.
*! version 1.0.0 13oct2002
version 8
class {
instance:
atobs = 0
points = 3
min = (.)
max = (.)
predict_opts = ""
regress_opts = ""
xtrans = ""
} , inherit(twoway_yxview_parse)
// ---------------------------------------------------------------------------
program parse
.must_create_serset = 1
.viewtype = "line"
.Super.parse `0'
// check number of vars
_clsarr2list mlablist : labvars // allow marker labels
local vlist `.varlist'
local vlist : list vlist - mlablist
if 0`:word count `vlist'' > 2 {
di in smcl "{error}{p 0 8}too many variables specified: `.varlist'"
exit 103
}
local 0 , `.options'
_parse combop 0 : 0 , option(N) rightmost
_parse combop 0 : 0 , option(Range) rightmost
_parse combop 0 : 0 , option(ESTopts) rightmost
_parse combop 0 : 0 , option(PREDopts) rightmost
_parse combop 0 : 0 , option(XTransform) rightmost
syntax [ , ATObs n(integer `.points') ///
Range(numlist min=2 max=2 missingok) ///
ESTopts(string) PREDopts(string) ///
XTransform(string) XLOG * ]
.options = `"`options'"'
if `"`predopts'"' != `""' {
_pred_opts popts : , `predopts'
}
if `"`popts'"' != `""' & "`range'" != "" {
di in smcl "{error}{p 0 8}may not combine `popts' with range()"
exit 198
}
if "`atobs'" != `""' & "`range'" != "" {
di in smcl "{error}{p 0 8}may not combine atobs with range()"
exit 198
}
if `"`popts'"' != `""' {
local atobs atobs
}
if `"`xtransform'"' != `""' | "`xlog'" != "" {
if `n' == 3 {
local n 100
}
}
.atobs = "`atobs'" != ""
.points = `n'
.regress_opts = `"`estopts'"'
.predict_opts = `"`predopts'"'
.xtrans = `"`xtransform'"'
if "`xlog'" != "" {
.xtrans = "ln(X)"
}
if "`range'" != "" {
tokenize `range'
.min = (`1')
.max = (`2')
}
.options = `"`options'"'
end
program _pred_opts
gettoken mac 0 : 0
gettoken color 0 : 0
local yoptions Cooksd Hat Leverage Residuals RSTAndared RSTUdent ///
COVRatio DFBeta(passthru) DFIts Welsch
syntax [ , `yoptions' * ]
c_local `mac' `cooksd' `hat' `leverage' `residuals' `rstandared' ///
`rstudent' `covratio' `dfbeta' `dfits' `welsch'
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 rest `.varlist'
gettoken y rest : rest
gettoken x rest : rest
.`log'.Arrpush __NOLOG__ twoway__lfit_serset , ///
sersetname(`sersetname') touse(\`touse1') x(`x') y(`y') ///
min(`.min') max(`.max') points(`.points') atobs(`.atobs') ///
predopts(`.predict_opts') regopts(`.regress_opts') ///
xtrans(`.xtrans') morevars(`rest') weight(`.wtype'`.wtexp')
.`log'.Arrpush LogMapping .`sersetname' // make _fr_runlog place
// mapping statement into
// permanent log.
.wtype = "" // so .Super.log_create_view will
.wtexp = "" // not try to add weight to serset
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -