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

📄 stcurve.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*!version 6.3.1  22nov2004
program define stcurve
	version 6
	if _caller() < 8 {
		stcurve_7 `0'
		exit
	}

	if "`e(cmd2)'" != "streg" & "`e(cmd2)'" != "stcox"{  
		error 301
	}
	
	st_is 2 analysis
	syntax [, CUMHaz SURvival HAZard AT1(string) AT2(string) /*
		*/ AT3(string) AT4(string) AT5(string) AT6(string) /*
                */ AT7(string) AT8(string) AT9(string) AT10(string) /*
		*/ Range(numlist ascending min=2 max=2 ) OUTfile(string) /*
		*/ Kernel(passthru) width(real -1) ALPHA1 UNCONDitional * ]

	_get_gropts , graphopts(`options') getallowed(plot addplot)
	local options `"`s(graphopts)'"'
	local plot `"`s(plot)'"'
	local addplot `"`s(addplot)'"'

	if "`e(cmd2)'" == "stcox" {
		if "`cumhaz'`surviva'" != "" {
			local step connect(J ...)
		}
	}

	if `"`e(fr_title)'"'=="" | "`e(cmd2)'" == "stcox" {
		if "`alpha1'"!="" {
di as err "`alpha1' only allowed with parametric frailty models"
			exit 198
		}
		if "`uncondi'"!="" {
di as err "`uncondi' only allowed with parametric frailty models"
			exit 198
		}
	}
	else {   /* frailty model: tell user what they are getting */
		if "`alpha1'`uncondi'"=="" {
			if "`e(shared)'"!="" {
				local alpha1 alpha1
			}
			else {
				local uncondi unconditional
			}
			di as txt "(option `alpha1'`uncondi' assumed)"
		}
	}

	if "`e(cmd)'"=="stcox_fr" {
		di as txt "note: all plots evaluated at frailty equal to one"
	}

	if `"`range'"'~="" {
		local ranopt range(`range')
	}
	else {      // rgg wants evenly spaced grids here for streg
		if "`e(cmd2)'"=="streg" {
			qui summ _t if e(sample), meanonly
			local ranopt range(`r(min)' `r(max)')
		}
	}
	preserve
	qui keep if e(sample)
	local type = substr("`cumhaz' `survival' `hazard'",1,5)
	tempfile tcurve
	tempfile tcurve2
	tempname nt
	if `"`at1'`at2'`at3'`at4'`at5'`at6'`at7'`at8'`at9'`at10'"' ~= "" {
		local saved 0
		local i 1
		while `i'<=10 {
			if "`at`i''"~="" {
			    _stcurv, `cumhaz' `survival' `hazard' /*
				*/ `uncondi' `alpha1' /*
				*/ at(`at`i'') `kernel' width(`width') /*
				*/ save(`"`tcurve'"') `ranopt'
				qui use `"`tcurve'"', clear
				tokenize `r(myvars)'
				local prim _`type'`i'
				rename `1' `prim'
				local yvars `"`yvars' `prim'"'
				local tmplbl: variable label `prim'
				label var `prim' "`at`i''"
				rename `2' `nt'
				qui compress
				sort `nt'
				if `saved' {
					qui merge `nt' using `"`tcurve2'"'
					drop _merge
					sort `nt'
					qui save `"`tcurve2'"',replace
				}
				else {
					qui save `"`tcurve2'"',replace
					local saved 1
				}
			restore, preserve
			}
			local ++i
		}
		qui use `"`tcurve2'"', clear
	}
	else {
		_stcurv, `cumhaz' `survival' `hazard'  /*
			*/ `uncondi' `alpha1' `kernel' width(`width') /*
			*/ save(`"`tcurve'"') `ranopt'
			qui use `"`tcurve'"', clear
			tokenize `r(myvars)'
			rename `1' _`type'1
			local yvars _`type'1
			rename `2' `nt'
	}
	if `"`r(bb)'"' != "" {
		local ttl title(`"`r(bb)'"')
	}
	if `"`tmplbl'"' != "" {
		local yttl `"ytitle("`tmplbl'")"'
	}
	local xttl "analysis time"
	if `"`plot'`addplot'"' == "" {
		if  0`:word count `yvars'' == 1 {
			local legend legend(nodraw)
		}
	}
	else	local draw nodraw
	version 8: graph twoway		///
	(line `yvars' `nt',		///
		sort			///
		`yttl'			///
		xtitle(`"`xttl'"')	///
		`ttl'			///
		`legend'		///
		`draw'			///
		`step'                  ///
		`options'		///
	)				///
	// blank

	if "`outfile'"~="" {
		keep `yvars' `nt'
		order `yvars' `nt'
		// remove the underscore "_"
		foreach var of local yvars {
			local vn = substr(`"`var'"',2,.)
			rename `var' `vn'
		}
		cap rename `nt' _t
		tokenize "`outfile'", parse(",")
		// trim any trailing spaces in the filename
		local 1 `1'
		qui save "`1'" `2' `3'
        }
	if `"`plot'`addplot'"' != "" {
		restore
		version 8: graph addplot `plot' || `addplot' || , norescaling
	}
end
exit

⌨️ 快捷键说明

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