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

📄 pchart.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 2.3.1  02mar2005
program define pchart, sort
	version 6
	if _caller() < 8 {
		pchart_7 `0'
		exit
	}
	syntax varlist(min=3 max=3) [, STAbilized * ]

	_get_gropts , graphopts(`options') getallowed(CLOPts plot addplot)
	local options `"`s(graphopts)'"'
	local clopts `"`s(clopts)'"'
	local plot `"`s(plot)'"'
	local addplot `"`s(addplot)'"'
	_check4gropts clopts, opt(`clopts')

	tokenize `varlist'
	local REJECTS "`1'"
	local UNIT "`2'"
	local xttl : var label `UNIT'
	if `"`xttl'"' == "" {
		local xttl `UNIT'
	}
	local SAMPLE "`3'"

	// the # of rejects and sample sizes must all be non-negative or
	// missing
	cap assert `REJECTS' >= 0
	if _rc {
		di in red "negative values encountered in `REJECTS'"
		exit
	}
	cap assert `SAMPLE' >= 0
	if _rc {
		di in red "negative values encountered in `SAMPLE'"
		exit
	}

	tempvar NTOTAL P

	sum `SAMPLE', mean
	if r(max) == 0 {
		di in red "All samples are missing or zero"
		exit
	}
	// constant sample size
	local constant = (r(min)==r(max))
	if r(min)==r(max) {
		local SAMPLE = r(min)
		local icons 1
	}
	else	local icons 0

	gen `P' = `REJECTS'/`SAMPLE'
	local yttl "Fraction defective"
	label variable `P' "`yttl'"
	sum `P', mean
	local pbar = r(mean)
	if `pbar' <= 0 {
		di in red "No units were ever rejected"
		exit
	}
	format `P' %9.4f
	tempvar LCL UCL
	if `icons' {		// constant sample size
		local ucl=`pbar' + 3*sqrt(`pbar'*(1-`pbar')/(`SAMPLE'))
		local lcl=max(0,2*`pbar'-`ucl')
		gen `LCL' = `lcl'
		gen `UCL' = `ucl'
		qui count if `P'<`lcl' | `P'>`ucl'
		local note ///
		"`r(N)' unit`=cond(r(N)==1," is","s are")' out of control"
	}
	else {			// varying sample size
		gen float `UCL' = 3*sqrt(`pbar'*(1-`pbar')/(`SAMPLE'))
		gen float `LCL' = `pbar'-`UCL'
		quietly replace `LCL' = 0 if `LCL' < 0
		quietly replace `UCL' = `pbar' + `UCL'
		label variable `UCL' " "
		label variable `LCL' " "

		qui count if `P'<`LCL' | `P'>`UCL'
		local note ///
		"`r(N)' unit`=cond(r(N)==1," is","s are")' out of control"
		if "`stabili'" != "" {
			format `P' %9.2f
			quietly replace `UCL' = (`UCL'-`pbar')/3
			quietly replace `P' = (`P'-`pbar')/`UCL'
			label variable `P' "`yttl' (Standard Deviation units)"
			local yttl `""`yttl'" "(Standard Deviation units)""'
			local pbar = int(`pbar'*10000+.5)/10000
			local lcl -3
			local ucl 3
			quietly replace `LCL' = `lcl'
			quietly replace `UCL' = `ucl'
			local note2 ///
"Stabilized p Chart, average number of defects = `pbar'"
			local pbar 0
		}
	}
	if `"`plot'`addplot'"' == "" {
		local legend legend(nodraw)
	}
	label var `LCL' "Control limit"
	label var `UCL' "Control limit"
	version 8: graph twoway			///
	(rline `LCL' `UCL' `UNIT',		///
		sort				///
		pstyle(ci)			///
		yaxis(1 2)			///
		ylabels(, nogrid)		///
		xlabels(, nogrid)		///
		ytitle(`yttl', axis(1))		///
		ylabels(`lcl' `pbar' `ucl',	///
			axis(2))		///
		yticks(`pbar',			///
			grid gmin gmax		///
			axis(2)			///
		)				///
		ytitle("", axis(2))		///
		xtitle(`"`xttl'"')		///
		note(`"`note'"' `"`note2'"')	///
		`legend'			///
		`clopts'			///
	)					///
	(connected `P' `UNIT',			///
		sort				///
		pstyle(p1)			///
		`options'			///
	)					///
	|| `plot' || `addplot'			///
	// blank
end

⌨️ 快捷键说明

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