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

📄 heckpr_p.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 3.0.4  24sep2004
program define heckpr_p
	version 6, missing

	syntax [anything] [if] [in] [, SCores * ]
	if `"`scores'"' != "" {
		ml_score `0'
		exit
	}

		/* Step 1:
			place command-unique options in local myopts
			Note that standard options are
			LR:
				Index XB Cooksd Hat 
				REsiduals RSTAndard RSTUdent
				STDF STDP STDR noOFFset
			SE:
				Index XB STDP noOFFset
		*/

	local myopts P11 P01 P10 P00 PMargin PSel PCond XB STDP XBSel STDPSel


		/* Step 2:
			call _propts, exit if done, 
			else collect what was returned.
		*/
			/* takes advantage that -myopts- produces error
			 * if -eq()- specified w/ other that xb and stdp */

	_pred_se "`myopts'" `0'
	if `s(done)' { exit }
	local vtyp  `s(typ)'
	local varn `s(varn)'
	local 0 `"`s(rest)'"'


		/* Step 3:
			Parse your syntax.
		*/

	syntax [if] [in] [, `myopts' CONstant(varname numeric) noOFFset]


		/* Step 4:
			Concatenate switch options together
		*/

	local type  `p11'`p01'`p10'`p00'`pmargin'`pcond'`xb'`psel'
	local type  `type'`xbsel'`stdp'`stdpsel'
	local args


		/* Step 5:
			quickly process default case if you can 
			Do not forget -nooffset- option.
		*/


	tokenize `e(depvar)'
	local depname `1'
	local selname = cond("`2'"=="", "select", "`2'")
	if "`constan'" != "" { local constan "constant(`constan')" }
	if "`selcons'" != "" { local selcons "constant(`selcons')" }

	tempvar xb zg
	tempname r
	qui _predict double `xb' `if' `in', eq(#1) `offset' `constan'
	qui _predict double `zg' `if' `in', eq(#2) `offset' `selcons'
	scalar `r' = [athrho]_b[_cons]
	scalar `r' = (exp(2*`r')-1)/(exp(2*`r')+1)
	

	if ("`type'"=="" | "`type'" == "pmargin") & `"`args'"'=="" {
		if "`type'" == "" {
			di in gr "(option pmargin assumed; Pr(`depname'=1))"
		}
		gen `vtyp' `varn' = normprob(`xb')
		label var `varn' "Pr(`depname'=1)"
		exit
	}

		/* Step 6:
			mark sample (this is not e(sample)).
		*/
	marksample touse


		/* Step 7:
			handle options that take argument one at a time.
			Comment if restricted to e(sample).
			Be careful in coding that number of missing values
			created is shown.
			Do all intermediate calculations in double.
		*/



		/* Step 8:
			handle switch options that can be used in-sample or 
			out-of-sample one at a time.
			Be careful in coding that number of missing values
			created is shown.
			Do all intermediate calculations in double.
		*/


				/* P11 */
	if "`type'"=="p11" {
		gen `vtyp' `varn' = binorm(`xb',`zg',`r')
		label var `varn' "Pr(`depname'=1,`selname'=1)"
		exit
	}
				/* P01 */
	if "`type'"=="p01" {
		gen `vtyp' `varn' = binorm(-`xb',`zg',-`r')
		label var `varn' "Pr(`depname'=0,`selname'=1)"
		exit
	}
				/* P10 */
	if "`type'"=="p10" {
		gen `vtyp' `varn' = binorm(`xb',-`zg',-`r')
		label var `varn' "Pr(`depname'=1,`selname'=0)"
		exit
	}
				/* P00 */
	if "`type'"=="p00" {
		gen `vtyp' `varn' = binorm(-`xb',-`zg',`r')
		label var `varn' "Pr(`depname'=0,`selname'=0)"
		exit
	}
				/* PCOND */
	if "`type'"=="pcond" {
		gen `vtyp' `varn' = binorm(`xb',`zg',`r')/normprob(`zg')
		label var `varn' "Pr(`depname'=1|`selname'=1)"
		exit
	}
				/* linear predictor for equation 1 */
	if "`type'" == "xb" {	
		gen `vtyp' `varn' = `xb'
		label var `varn' "linear prediction of `depname'"
		exit
	}
				/* Probit index standard error */
	if "`type'" == "stdp" { 
		_predict `vtyp' `varn', stdp eq(#1) `offset' `constan', /*
			*/ if `touse'
		label var `varn' "S.E. of prediction of `depname'"
		exit
	}
				/* Selection index standard error */
	if "`type'" == "stdpsel" { 
		_predict `vtyp' `varn', stdp eq(#2) `offset' `selcons', /*
			*/ if `touse'
		label var `varn' "S.E. of prediction of `selname'"
		exit
	}

				/* Selection index */
	if "`type'" == "xbsel" { 
		gen `vtyp' `varn' = `zg'
		label var `varn' "Linear prediction of `selname'"
		exit
	}
				/* Probability observed, from selection 
				 * equation */
	if "`type'" == "psel" {
		gen `vtyp' `varn' = normprob(`zg')
		label var `varn' "Pr(`selname')"
		exit
	}

		/* Step 9:
			handle switch options that can be used in-sample only.
			Same comments as for step 8.
		*/


			/* Step 10.
				Issue r(198), syntax error.
				The user specified more than one option
			*/
	error 198
end

⌨️ 快捷键说明

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