.- help for ^jknife^ (STB-24: sg34) .- Jackknife estimation -------------------- ^jknife clear^ ^jknife cmd^ stata_cmd (required) ^jknife stat^ # [newvar ^=^ exp] (required) ^jknife n =^ exp ^jknife^ [^q^uery] ^jknife do^ [^, replace l^evel^(^#^)^ ] (required) Description ----------- ^jknife^ performs jackknife estimation. A problem is first defined using (at a minimum) ^jknife cmd^ and ^jknife stat^ and then executed using ^jknife do^. ^jknife clear^ undefines any previous problem. ^jknife cmd^ defines the Stata command that is to be executed, a command which calculates one or more statistics and saves them so that they can be sub- sequently accessed. (Typically, Stata commands save results in ^_result()^ or ^S_^# macros; see Saved Results in the command's printed documentation.) ^jknife^ assumes that cmd follows standard Stata syntax and, in particular, allows ^if^ exp. ^jknife stat^ defines a statistic to be stored in a new variable. There can be one or more ^jknife stat^ commands for a particular problem. (^jknife stat^ can also be used to edit definitions.) ^jknife n^, which is optional, states where stata_cmd saves the number of observations on which it based the calculated results. This is typically either ^_result(1)^ or the macro ^S_1^; again, see Saved Results under the partic- ular command of interest. If ^jknife n^ is not specified, ^_N^, the number of observations in the data set, will be assumed, and missing values will not be handled correctly. You are strongly advised to define this parameter. ^jknife query^, or ^jknife^ by itself, lists the currently defined problem. ^jknife do^ executes the problem. Options ------- ^replace^ specifies that the variables defined by ^jknife stat^ may already exist and that there contents may be replaced. ^level(^#^)^ specifies the significance level in percent for the confidence intervals; see help @level@. Example: Jackknifed standard deviation --------------------------------------- You wish to obtain the jackknife estimate of the standard deviation of the standard deviation. The Stata command ^summarize^ calculates the mean and standard deviation, and looking under Saved Results in [5s] summarize, you find that the number of observations is saved in ^_result(1)^ and the variance (the square of the standard deviation) in ^_result(4)^. You have the variable mpg in your data for which you want to make the calcu- lation. You type: . ^jknife clear^ . ^jknife cmd summarize mpg^ . ^jknife stat 1 sd = sqrt(_result(4))^ . ^jknife n = _result(1)^ . ^jknife do^ The last step might produce the output: .- . ^jknife do^ cmd: summarize mpg n: _result(1) stat: [1] sd = sqrt(_result(4)) Variable | Obs Statistic Std. Err. [95% Conf. Interval] ---------+------------------------------------------------------------- sd | overall | 74 5.785503 jknife | 5.817374 .6072509 4.607125 7.027624 .- The standard deviation of mpg is 5.78. The average the of pseudovalues -- the jackknife estimate of the standard deviation -- is 5.82. The jackknife estimate of the standard deviation of the standard deviation is .61, and a 95% confidence interval for the standard deviation is [4.61,7.03]. The variable sd containing the pseudovalues is now part of the data. Typing "^ci sd^", for instance, would reproduce the final line of the table; see help @ci@. The pseudovalues can be used to search for overly influential observations. You might begin by typing "^summarize sd, detail^"; see help @summarize@. The pseudovalues could be dropped from the data by typing "^drop sd^"; see help @drop@. Example: multiple statistics ----------------------------- Using ^summarize, detail^, you wish to obtain a the jackknife estimate of the standard deviation and skewness. ^summarize, detail^ saves the square of the standard deviation in ^_result(4)^ and the skewness in ^_result(14)^. . ^jknife clear^ . ^jknife cmd summ mpg, detail^ . ^jknife n = _result(1)^ . ^jknife stat 1 sd = sqrt(_result(4))^ . ^jknife stat 2 skew = _result(14)^ . ^jknife do^ Example: editing ----------------- There is no required order to the ^jknife^ commands except that ^jknife clear^ be used first and ^jknife do^ last. Moreover, between ^clear^ and ^do^ you can define and redefine the elements and you can type ^jknife^ by itself to review where you are. .- . ^jknife^ cmd: summ mpg mpg , detail n: _result(1) stat: [1] sd = sqrt(_result(4)) stat: [2] skew = _result(14) . ^jknife stat 1 mean = _result(3)^ . ^jknife stat 2^ . ^jknife^ cmd: summ mpg mpg , detail n: _result(1) stat: [1] mean = _result(3) .- Example: Accessing S_ macros ----------------------------- Obtain an estimate of the standard deviation of Cronbach's alpha, the scale reliability coefficient. (^alpha^ -- see help @alpha@ -- stores alpha in the global macro S_4; it does not save the number of observations.) . ^jknife clear^ . ^jknife cmd alpha quest1-quest10, std^ . ^jknife stat 1 alpha = S_4^ . ^jknife do^ Note: The ^jknife stat^ command refers to ^S_4^, not ^$S_4^. ^jknife^ assumes that expressions starting with "S_" are macro references; do not type a dollar sign before them. In some other problem, if you need to refer to a global scalar that starts with "S_", such as ^S_1^ to define the statistic whatever, you type . ^jknife stat 1 whatever = scalar(S_1)^ Note on commands and programs that may be used with ^jknife^ ---------------------------------------------------------- Most Stata commands and user-written programs can be used with ^jknife^. The requirement is that the command follow standard Stata syntax and that it allow ^if^ exp. There is nothing more to say, but the following will interest programmers: Assume you have defined . ^jknife cmd^ ^jknife^'s main loop repeatedly executes ^if _n~=j^ or ^, if _n~=j^ for j=1,...,_N. Which form ^jknife^ chooses depends on the number of commas outside parentheses and brackets in . For example, if is "^summarize mpg^", then ^jknife^ executes ^summarize mpg if _n~=j^ If is "^summarize mpg, detail^", then ^jknife^ executes ^summarize mpg, detail, if _n~=j^ Many users do not realize it, but commas do not merely set off options from the standard command syntax; they toggle back-and-forth between options and standard syntax. Saved results ------------- ^jknife^ saves in the global S_# macros values corresponding to the last (which is typically the only) statistic reported: S_1 the number of observations S_2 the overall statistic S_3 bootstrap estimate (mean of pseudovalues) S_4 standard error of the mean S_5 lower confidence bound S_6 upper confidence bound Also see -------- STB: sg34 (STB-24) On-line: help for @bstrap@