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

📄 estat_programming.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 21feb2005}{...}
{cmd:help estat programming}
{hline}

{title:Title}

{p2colset 5 30 32 2}{...}
{p2col :{hi:[P] estat programming} {hline 2}}Controlling estat for a
	user-written estimation command{p_end}
{p2colreset}{...}


{title:Description}

{pstd}
Programmers of estimation commands can customize the way {helpb estat} works
after their commands.  If you only want the standard {helpb estat} subcommands
{cmd:ic}, {cmd:summarize}, and {cmd:vce}, you do not need to do anything.
Stata will automatically handle those cases.


{title:Remarks}

{pstd}
Remarks are presented under the headings

{phang2}{help estat_programming##add:Adding subcommands to estat}{p_end}
{phang2}{help estat_programming##override:Overriding standard behavior of a subcommand}


{marker add}{...}
{title:Adding subcommands to estat}

{pstd}
An {cmd:estat} {it:handler} function defines the command-specific actions that
{cmd:estat} is to perform after an estimation command.  We strongly recommend
naming the handler {it:cmd}{cmd:_estat}, where {it:cmd} is the name of the
estimation command.  In order for {cmd:estat} to work, {it:cmd} must be
implemented as an e-class program and must store the name of the {cmd:estat}
handler function in the macro {cmd:e(estat_cmd)}.  For example, the {cmd:pca}
command includes the statement

	{cmd:ereturn local estat_cmd "pca_estat"}

{pstd}
For more information on returning estimation results, see {helpb ereturn}.

{pstd}
The command {it:cmd}{cmd:_estat} should check whether a subcommand typed by
the user is a valid subcommand abbreviation that the handler implements.  If
it does not recognize the subcommand, it should pass control to the handler
{cmd:estat_default}, which checks for one of the standard subcommands and
issues an error message if it does not recognize the subcommand.

{pstd}
The following code fragment illustrates the structure of
an {cmd:estat} handler command {it:cmd}{cmd:_estat} with two specific
subcommands {cmdab:fit} and {cmdab:se:ns}.

	{hline 10} <begin {it:cmd}{cmd:_estat.ado}> {hline -2}

	{cmd}*! version 1.0.0  {ccl current_date}
	program {it:cmd}{cmd:_estat}, rclass
		version {ccl stata_version}

		if "`e(cmd)'" != "{it:cmd}" {
			error 301
		}

		gettoken key rest : 0, parse(", ")
		local lkey = length(`"`key'"')
	
		if `"`key'"' == "fit" {
			Fit `0'
		}
		else if `"`key'"' == substr("sens", 1, max(2,`lkey')) {
			Sens `0'
		}
		else {
			estat_default `0'
		}

		return add
	end

	program Fit, rclass
		syntax ...
		...
	end

	program Sens, rclass
		syntax ...
		...
	end{reset}

	{hline 10} <end {it:cmd}{cmd:_estat.ado}> {hline -2}


{marker override}{...}
{title:Overruling standard behavior of a subcommand}

{pstd}
Occasionally, you may want to overrule the behavior of a subcommand normally
handled by {cmd:estat_default}.  This is simply accomplished by providing a
local handler.  Consider, for example, {cmd:summarize} after {cmd:pca}.  The
standard way of invoking {cmd:estat summarize} is not appropriate
here{hline 2}{cmd:estat summarize} extracts the list of variables to be
summarized from {cmd:e(b)}.  This does not work after {cmd:pca}. In this case,
the {it:varlist} has to be extracted from the column names of the correlation
or covariance matrix {cmd:e(C)}.  This {it:varlist} is transferred to
{cmd:estat summarize} (or more directly to {cmd:estat_summ}) as the argument
of the option {cmd:varlist()}.

	{cmd}program Summarize, rclass
		tempname C
		matrix `C' = e(C)
		estat_summ, `0' varlist(`:colnames `C'')
	end{reset}

{pstd}
You add the local handler by inserting an additional switch in 
{it:cmd}{cmd:_estat} to ensure that the {cmd:summarize} subcommand is 
not handled by the default handler {cmd:estat_default}.  As a detail, 
we have to make sure that the minimal abbreviation is {cmdab:su:mmarize},

	{cmd}else if `"`key'"' == substr("summarize", 1, max(2,`lkey')) {
		Summarize `0'
	}{reset}


{title:Also see}

{psee}
Manual:  {hi:[P] estat programming}
{p_end}

{psee}
Online:  {helpb estat}
{p_end}

⌨️ 快捷键说明

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