📄 makecns.hlp
字号:
{smcl}
{* 12feb2005}{...}
{cmd:help makecns}
{hline}
{title:Title}
{p2colset 5 20 22 2}{...}
{p2col :{hi:[P] makecns} {hline 2}}Constrained estimation{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 15 2}
{cmd:makecns}
[{it:clist}|{it:matname}]
[{cmd:,} {it:options}]
{p 8 15 2}
{cmd:matcproc} {it:T a C}
{phang}
where {it:clist} is a list of constraint numbers, separated by commas or
dashes; {it:matname} is an existing matrix representing the constraints and
must have one more column than the {hi:e(b)} and {hi:e(V)} matrices.
{phang}
{it:T}, {it:a}, and {it:C} are name of new or existing matrices.
{synoptset 12}{...}
{synopthdr}
{synoptline}
{synopt:{opt nocnsnote:s}}do not display notes when constraints are dropped{p_end}
{synopt:{opt di:splaycns}}display the system-stored constraint matrix{p_end}
{synopt:{opt r}}return the accepted constraints in {hi:r()}; this option overrides {opt displaycns}{p_end}
{synoptline}
{p2colreset}{...}
{title:Description}
{pstd}
{cmd:makecns} is a programmer's command that facilitates adding constraints to
estimation commands.
{pstd}
{cmd:makecns} will create a constraint matrix and displays a note for each
constraint that is dropped due to an error. The constraint matrix can be
obtained by the {cmd:matrix get(Cns)} function (see {helpb get()}).
{pstd}
{cmd:matcproc} returns matrices helpful for performing constrained estimation,
including the constraint matrix.
{pstd}
If your interest is simply in using constraints in a command that supports
constrained estimation, see {helpb constraint}.
{title:Options}
{phang}
{cmd:nocnsnotes} prevents notes from being displayed when constraints are
dropped.
{phang}
{cmd:displaycns} displays the system-stored constraint matrix in readable
form.
{phang}
{cmd:r} returns the accepted constraints in {cmd:r()}. This option overrides
{cmd:displaycns}.
{title:Example}
{pstd}
Here is an outline for programs to perform constrained estimation using
{cmd:makecns}:
{cmd}{...}
program {it:myest}, eclass
version {ccl stata_version}
if replay() { // {it:replay the results}
if ("`e(cmd)'" != "{it:myest}") error 301
syntax [, Level(cilevel) ]
makecns , displaycns
}
else { // {it:fit the model}
syntax {it:whatever} [, ///
{it:whatever} ///
Constraints(string) ///
Level(cilevel) ///
]
// {it:any other parsing of the user's estimate request}
tempname b V C T a bc Vc
local p={it:number of parameters}
// {it:define the model} ({it:set the row and column}
// {it:names}) {it:in `b'}
if "`constraints'" != "" {
matrix `V' = `b''*`b'
ereturn post `b' `V' // {it:a dummy solution}
makecns `constraints', display
matcproc `T' `a' `C'
// {it:obtain solution in `bc' and `Vc'}
matrix `b' = `bc'*`T' + `a'
matrix `V' = `T'*`Vc'*`T'' // {it:note prime}
ereturn post `b' `V' `C', {it:options}
}
else {
// {it:obtain standard solution in `b' and `V'}
ereturn post `b' `V', {it:options}
}
// {it:store whatever else you want in e}()
ereturn local cmd "{it:myest}"
}
// {it:output any header above the coefficient table}
ereturn display, level(`level')
end
{reset}{txt}{...}
{title:Also see}
{psee}
Manual: {bf:[P] makecns}
{psee}
Online:
{helpb constraint};
{helpb cnsreg},
{helpb ereturn},
{helpb get()},
{helpb local},
{helpb matrix},
{helpb ml}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -