⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acprplot.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 3.3.2  07mar2005
program define acprplot /* augmented component-plus-residual */
	version 6.0
	if _caller() < 8 {
		acprplot_7 `0'
		exit
	}

	_isfit cons anovaok
	syntax varname [, LOWess MSPline *]

	_get_gropts , graphopts(`options') 			///
		getallowed(RLOPts LSOPts MSOPts plot addplot)
	local options `"`s(graphopts)'"'
	local rlopts `"`s(rlopts)'"'
	local lsopts `"`s(lsopts)'"'
	local msopts `"`s(msopts)'"'
	local plot `"`s(plot)'"'
	local addplot `"`s(addplot)'"'
	_check4gropts rlopts, opt(`rlopts')
	_check4gropts lsopts, opt(`lsopts')
	_check4gropts msopts, opt(`msopts')
	if `"`lsopts'"' != "" {
		local lowess lowess
	}
	if `"`msopts'"' != "" {
		local mspline mspline
	}

	local wgt `"[`e(wtype)' `e(wexp)']"'

	local lhs "e(depvar)"

	if "`e(cmd)'" == "anova" {
		anova_terms
		local cterms `r(continuous)'
		local found 0
		foreach trm of local cterms {
			if "`trm'" == "`varlist'" {
				local found 1
				continue, break
			}
		}
		if !`found' {
			di in red /*
			*/ "`varlist' is not a continuous variable in the model"
			exit 398
		}
		local r "*"
	}
	else { /* e(cmd) is regress */
		local a "*"
	}

	/* `r' and `a' at the beginning of a line indicate that the line will
	   only be run when regress and anova respectively */

	capture local beta=_b[`varlist']
	if _rc { 
		di in red "`varlist' is not in the model"
		exit 398
	}
	tempvar resid hat lest v2 sifvar
`a'	anova_terms
`a'	local svl "`e(depvar)' `r(rhs)'"
`a'	local acont `r(continuous)'
`r'	_getrhs svl
`r'	local svl "`e(depvar)' `svl'"
	qui gen byte `sifvar' = e(sample)
	local sif "if `sifvar'"
	estimate hold `lest'
	capture { 
		gen `v2'=`varlist'*`varlist' `sif' 
`a'		anova `svl' `v2' `wgt' `sif' , cont(`acont' `v2')
`r'		reg `svl' `v2' `wgt' `sif' 
		local b0=_b[`varlist']
		local b1=_b[`v2']
		_predict `resid' `sif', resid
		replace `resid'=`resid'+`b0'*`varlist'+`b1'*`v2'
		reg `resid' `varlist' `sif'
		_predict `hat' `sif'
	}
	local rc=_rc
	estimate unhold `lest'
	if `rc' { error `rc' } 
	if `b0'==0 | `b1'==0 { 
		di in gr "`varlist'^2 is collinear with `varlist'"
		exit
	}
	local yttl "Augmented component plus residual"
	local xttl : var label `varlist'
	if `"`xttl'"' == "" {
		local xttl `varlist'
	}
	if `"`lowess'"' != "" {
		if `"`e(wtype)'"'!="" { 
			di in red "not possible with weighted fit"
			exit 398
		}
		local grlow				///
		(lowess `resid' `varlist'		///
			`sif',				///
			sort				///
			yvarlabel("Lowess smooth")	///
			`lsopts'			///
		)
	}
	if `"`mspline'"' != "" {
		local grmsp				///
		(mspline `resid' `varlist'		///
			`sif',				///
			sort				///
			yvarlabel("Spline smooth")	///
			`msopts'			///
		)
	}
	if `"`plot'`addplot'"' == "" {
		local legend legend(nodraw)
	}
	version 8: graph twoway				///
	(scatter `resid' `varlist' 			///
		`sif',					///
		sort					///
		ytitle(`"`yttl'"')			///
		xtitle(`"`xttl'"')			///
		`legend'				///
		`options'				///
	)						///
	(line `hat' `varlist' 				///
		`sif',					///
		sort					///
		lstyle(refline)				///
		`rlopts'				///
	)						///
	`grlow'						///
	`grmsp'						///
	|| `plot' || `addplot'				///
	// blank
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -