The package is intended to perform a Wald test for (non)linear restrictions on a model's coefficients in several cases: 1) For (almost) any user-specified model which outputs coefficients and their covariance matrix *). 2) For limited dependent variable models to test restrictions in terms of marginal effects. It is possible when _mfx function outputs covariance matrix for marginal effects, e.g. tobit_mfx function from tobit_mfx.fgn package. 3) For gretl native models to test multiple nonlinear restrictions. Also it provides functions to compute confidence intervals for linear and nonlinear functions of model coefficients. These can be used after the native and user-specified models. Also it provides functions to test 1 restriction with one-sided alternatives. The package has 9 public functions: nlwaldtest, nlwaldtestx, nlwaldtestm, nlconfint, nlconfintx, nlconfintm, s_ztest, s_ztestx and s_ztestm. -------------------------- function matrix nlwaldtest (string restr "restriction(s)", matrix beta "model coefficients", matrix vcov "coeff. covariance matrix", list xlist[null] "model indepvars", int df[0] "denom. degrees of freedom", int prn[0:1:1] "allows/suppress printing") Output is 1x2 matrix with statistic and p-value xlist: optional; if given, allows to input named, rather them numbered coefficients, e.g, b[IDE]; usual value is $xlist df: zero default for the denominator degree of freedom means that Chi-squared statistic is used prn: default is to print results; to suppress input any scalar See also sample script. -------------------------- function matrix nlwaldtestx (string restr "restriction(s)", matrix beta "model coefficients", matrix vcov "coeff. covariance matrix", list xlist[null] "model indepvars", matrix x "num. coeffs. in restr.", int df[0] "denom. degrees of freedom", int prn[0:1:1] "allows/suppress printing") The same as nlwaldtest; allows to input "cumbersome" numeric coefficients via x argument, see nlconfintx. -------------------------- function matrix nlwaldtestm (string restr "restriction(s)", bundle *b "model results bundle", matrix x[null] "num. coeffs. in restr.", int prn[0:1:1] "allows/suppress printing") The same as nlwaldtestx; has much more convenient syntax; bundle b can be $model after native estimation command, or any user-specified bundle b provided it has b.coeff, b.vcv, and b.xlist. Among other, the function is applicable to output bundles after mfx() and eyex() from a_eff.gfn to test restrictions which are expressed dyrectly in terms of marginal effects and elasticities. --------------------------- function matrix nlconfint (string fun "function of coeffs.", matrix beta "model coeff.", matrix vcov "vcv of mod. coeff.", list xlist[null] "model indepvars", scalar cl[NA] "conf. lvl. NA=0.95", scalar df[0] "model df") Output is 1x4 matrix: value of coeff. function, s.e., left bound, right bound See also sample script. -------------------------- function matrix nlconfintx (string fun "function of coeffs.", matrix beta "model coeff.", matrix vcov "vcv of mod. coeff.", matrix x "cumbersome coeffs", list xlist[null] "model indepvars", scalar cl[NA] "conf. lvl. NA=0.95", scalar df[0] "model df") Sometimes numeric coefficients could be general real numbers: ...b[2]*mean[2]/mean[y]... In such cases it could be something like this: fun = "b[2]+b[3]*x[1]", then, say x={mean(LRM)/mean(LRY)} See also sample script. -------------------------- function matrix nlconfintm (string restr "restriction(s)", bundle *b "model results bundle", matrix x[null] "num. coeffs. in restr.", scalar cl[NA] "conf. lvl. NA=0.95") The same as nlconfintx, but has more convenient syntax. The applicability of all m-series functions is the same. -------------------------- function matrix s_ztest (string restr "restriction(s)", matrix beta "model coefficients", matrix vcov "coeff. covariance matrix", int df[0] "denom. degrees of freedom", string side[null] "{2-sided,left, right}, null=2-sided", list xlist[null] "xlist") Test only one restriction with z-test (no df given), or with t-test. Alternative can be one of "2-sided" (the default) "left", or "right". Shortcuts "l", "<", "less", "r", ">", "greater", and "2" are allowed. The output is 1 by 2 matrix containing test statistic and p-value. -------------------------- function matrix s_ztestx (string restr "restriction(s)", matrix beta "model coefficients", matrix vcov "coeff. covariance matrix", matrix x "num. coeffs. in restr.", int df[0] "denom. degrees of freedom", string side[null] "{2-sided,left, right}, null=2-sided", list xlist[null] "xlist") The same as s_ztest. Intended for the 'cumbersome' numbers case. -------------------------- function matrix s_ztestm (string restr "restriction", bundle *b "model results bundle", string side[null] "{2-sided,left, right}, null=2-sided", matrix x[null] "num. coeffs. in restr.") The same as s_ztestx, but has more convenient syntax. This version is intended for script use. *) Accessibility of coefficients and their covariance matrix are the only technical requirements. Ensuring econometric correctness is up to user. ================= Changelog =================== News: v.0.3: functions for confidence intervals added v.0.42: bug fixes v.0.5: s_ztest() added for 1 restriction; alternatives can be one or two sided v.0.6: - a parsing bug fixed for the case of variables names with underscore in b[...] - improved handling of long restrictions v.0.7: a shameful x'Inv(A)*x substituted by "right division" v.0.8: s_ztestx() added; an *x analogue of s_ztest() v.1.0: m-series added with &b syntax where b is of $model-type. v.1.1: -a bug in output printing of s_ztest* functions corrected: they used to print negative z/t statistics for two-sided alternative (abs value and p-value were correct -some imroving of printing for the case of non-default matrix x argument of all *x and *m functions -sample script is rewritten to show explicitly unique functionality (i.e. non-overlapping with that of restrict command) v.1.2: (by the gretl team) internally clean up some deprecated syntax