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

📄 lfit_p.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 1.2.7  15feb2005
program define lfit_p, sclass
	version 6.0, missing
/*
    This is a driver program for lfit, lroc, lstat, and lsens
    which parses and computes predicted probabilities.

    Input:   `1'  = tempvar name for mark/markout
	     `2'  = tempvar name for p (predicted probabilities)
	     `3'  = tempvar name for w (weights)
	     `4'+ = stuff to be parsed

    Output:   `1' = touse filled in
	      `2' = p filled in (missing if `touse'==0) 
	      `3' = w filled in (missing if `touse'==0) 
	      s(N)       = number of observations
	      s(depvar)  = y (dependent variable name)
	      s(beta)    = beta (vector) if beta() option specified
	      s(rules)   = `"rules"' if rules option specified
	      s(options) = macro holding other options
*/
	sret clear 
	gettoken touse 0: 0
	gettoken p     0: 0
	gettoken w     0: 0

	/* Parse. */

	syntax [varname(default=none)] [if] [in] [fweight] [, /*
		*/ ALL ASIF RULEs BETA(string) * ]

if "`asif'"!="" | "`rules'"!="" {
	if "`asif'"!="" { 
		di in red "option asif invalid"
	}
	else	di in red "option rules invalid"
	exit 198
}

	

	if `"`beta'"' == `""' { /* this is a post-logistic [probit] call */
		if `"`e(cmd)'"' != `"logistic"' & "`e(cmd)'"!="logit" & /*
		*/ `"`e(cmd)'"' != "probit" & `"`e(cmd)'"' != "dprobit" { 
			error 301
		}
		local y `"`e(depvar)'"'
		if `"`varlist'"' != `""' & `"`varlist'"' != `"`y'"' {
			di in red /*
			*/ `"varlist not allowed (except with beta() option)"'
			error 198
		}
		if `"`asif'"' != `""' & `"`rules'"' != `""' {
			di in red `"both asif and rules cannot be specified"'
			error 198
		}
        	if `"`if'`in'`all'"' == `""' {
			local if "if e(sample)"
        	}
		else if `"`all'"' != `""' & `"`if'`in'"' != `""' {
			di in red `"all option not allowed with if or in"'
			error 198
		}
        	if `"`weight'"' == `""' {
                	local weight `"`e(wtype)'"'
                	local exp    `"`e(wexp)'"'
        	}
	}
	else {	/* this is a call with vector of coefficients `beta' */
		/* assumed to be logit vector */

		if `"`asif'"' != `""' {
			di in red `"asif option not allowed with beta() option"'
			error 198
		}
		if `"`rules'"' != `""' {
			di in red `"rules option not allowed with beta() option"'
			error 198
		}
		capture di matrix(`beta'[1, 1])
		if _rc {
			di in red `"matrix `beta' not found"'
			exit 111
		}
		if `"`varlist'"' == `""' {
			di in red /*
			*/ `"dependent variable required with beta() option"'
			error 198
		}
		local y `"`varlist'"'
	}

       	mark `touse' `if' `in' [`weight'`exp']

        quietly {
		if `"`beta'"' == `""' {
			_predict double `p' if `touse', `asif' `rules'
		}
		else {
			matrix score double `p' = `beta' if `touse'
			replace `p' = exp(`p')/(1 + exp(`p')) if `touse'
		}

		markout `touse' `y' `p'

		replace `p' = . if `touse'==0

                if `"`weight'"' != `""' {
			gen double `w' `exp' if `touse'
		}
		else    gen byte   `w' = 1   if `touse'

		summarize `touse' [`weight'`exp'] if `touse'
	}

	if r(N) == 0 { error 2000 }

	sret local N = round(r(N),1)		/* number of obs */
	sret local depvar "`y'"			/* dependent variable name */
	sret local beta "`beta'"		/* `beta' if specified  */
	sret local rules "`rules'"		/* `rules' if specified	*/
	sret local options "`options'"		/* other options 	*/
end

⌨️ 快捷键说明

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