Skip to content

Commit

Permalink
Fixed a bug in the level option of sgpv.
Browse files Browse the repository at this point in the history
Fixed minor formatting issues in multiple help files and example files.
  • Loading branch information
Sven-Kristjan Bormann committed Apr 26, 2021
1 parent 1925af5 commit 7afbfe7
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 36 deletions.
19 changes: 10 additions & 9 deletions sgpv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ General remarks if updates come in larger "packages".
* Changed the syntax of the command to match more closely Stata standards, the old syntax still works.
* Option sgpval became one option 'fcr'. The default is to calculate the Fdr.
* Option nullweights became option 'nulltruncnormal'. The former option nullweights("Point") is automatically selected if option nullspace contains only one element. If option nullspace contains two elements then the Uniform distribution is used as the default distribution.
* Option altweights became 'alttruncnormal'. The option altweights("Point") is automatically selected if option altspace contains only one element. If option altspace contains two elements then the Uniform distribution is used as the default distribution. ///
* Options inttype and intlevel became options level(#) and likelihood(#). If no option is set then the confidence interval with the default confidence interval level is used.
* Option altweights became 'alttruncnormal'. The option altweights("Point") is automatically selected if option altspace contains only one element. If option altspace contains two elements then the Uniform distribution is used as the default distribution.
* Options inttype and intlevel became options level(#) and likelihood(#). If no option is set then the confidence interval with the default confidence interval level is used.
* Version 1.04 09.11.2020 : Changed in the dialog the option sgpval (Set Fdr/Fcr) to display "Fdr" or "Fcr" instead of numerical values.
* Version 1.03 24.05.2020 : Added more input checks
* Version 1.02 14.05.2020 : Changed type of returned results from macro to scalar to be more inline with standard practises
Expand Down Expand Up @@ -92,9 +92,10 @@ General remarks if updates come in larger "packages".
* Version 0.90 : Initial Github Release

### sgpv
* Version 1.2a 01.02.2021 : Fixed a bug with the level option. Fixed a bug with regards to leading whitespaces when prefixing sgpv.
* Version 1.2 27.12.2020 :
* Changed the name of the option permament to permdialog to clarify the meaning of the option.
* Fixed the format option in the Dialog box
* Fixed the format option in the Dialog box.
* Added remove option for the menu subcommand to remove the entries in the profile.do created by the option permdialog.
* Renamed the dialog tab "Display" to "Reporting". Moved the options from the dialog tab "Fdrisk" to dialog tab "Reporting".
* Decpreciated the option bonus() and replaced it with the new options "deltagap", "fdrisk" and "all" which have the same effect as the previous bonus() option. This way is more in line with standard Stata praxis. The bonus option still works but is no longer supported.
Expand All @@ -110,7 +111,7 @@ General remarks if updates come in larger "packages".
* Added support for multiple null hypotheses.
* Added a noconstant-option to remove the constant from the list of coefficients.
* Fixed an error in the perm-option of the "sgpv menu"-subcommand.
* Fixed a confusion in the help-file about the nulllo and nullhi options .
* Fixed a confusion in the help-file about the nulllo and nullhi options.
* Added an experimental, undocumented option to enter the null interval -> option "null" with syntax "(lower_bound1,upper_bound2) (lower2,upper2) ... "
* Should allow now to use expressions for options "nulllo" and "nullhi" without having to run the expression parser first.
* Removed unused "altspace" option from the syntax, help file and dialog box -> "altspace" is automatically set with lower and upper bounds of confidence intervals -> fixed remarks related to default values for altspace and nullspace.
Expand All @@ -127,10 +128,10 @@ General remarks if updates come in larger "packages".
* Fixed: the Fdr's are now displayed when using the bonus-option with the values "fdrisk" or "all"
* Version 1.02 03.05.2020 :
* Changed name of option 'perm' to 'permanent' to be inline with Standard Stata names of options
* Removed some inconsistencies between help file and command file (missing abbreviation of pi0-option, format-option was already documented)
* Enforced and fixed the exclusivity of 'matrix', 'estimate' and prefix-command -> take precedence over replaying
* Shortened subcommand menuInstall to menu
* Added parsing of subcommands as a convenience feature
* Removed some inconsistencies between help file and command file (missing abbreviation of pi0-option, format-option was already documented).
* Enforced and fixed the exclusivity of 'matrix', 'estimate' and prefix-command -> take precedence over replaying .
* Shortened subcommand menuInstall to menu.
* Added parsing of subcommands as a convenience feature.
* Allow now more flexible parsing of coefficient names -> make it easier to select coefficients for the same variable across different equations -> only the coefficient name is now required not the equation name anymore -> implemented what is "promised" by the dialog box text
* changed the default behaviour of the bonus option from nobonus to bonus -> bonus statistics only shown when requested
* Version 1.00 : Initial SSC release, no changes compared to the last Github version.
Expand All @@ -142,7 +143,7 @@ General remarks if updates come in larger "packages".
* Version 0.98 : Added a subcommand to install the dialog boxes to the User's menubar. Fixed an incorrect references to the leukemia example in the help file.
* Version 0.97 : Further sanity checks of the input to avoid conflict between different options, added possibility to install dialog box into the User menubar.
* Version 0.96 : Added an example how to calculate all statistics for the leukemia dataset; minor fixes in the documentation of all commands and better handling of the matrix option.
* Version 0.95 : Fixed minor mistakes in the documentation, added more information about SGPVs and more example use cases; minor bugfixes; changed the way the results are presented
* Version 0.95 : Fixed minor mistakes in the documentation, added more information about SGPVs and more example use cases; minor bugfixes; changed the way the results are presented.
* Version 0.90 : Initial Github release

### sgpvalue
Expand Down
7 changes: 6 additions & 1 deletion sgpv/fdrisk-examples.do
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,34 @@ version 12.0
args argument
*False discovery risk with 95% confidence level:
if "`argument'"=="example1"{
noisily disp `"fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(log(1/1.1) log(1.1)) altspace("2-1*invnorm(1-0.05/2)*0.8" "2+1*invnorm(1-0.05/2)*0.8") level(95)"'
noisily fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(log(1/1.1) log(1.1)) ///
altspace("2-1*invnorm(1-0.05/2)*0.8" "2+1*invnorm(1-0.05/2)*0.8") level(95)
}

*False discovery risk with 1/8 likelihood support level:
if "`argument'"=="example2a"{
if "`argument'"=="example2a"{
noisily disp `"fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(0) altspace("2-1*invnorm(1-0.041/2)*0.8" "2+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)"'
noisily fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(0) ///
altspace("2-1*invnorm(1-0.041/2)*0.8" "2+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)
}

*with truncated normal weighting distribution:
if "`argument'"=="example2b"{
noisily disp `"fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(0) alttruncnormal altspace("2-1*invnorm(1-0.041/2)*0.8" "2+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)"'
noisily fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(0) alttruncnormal ///
altspace("2-1*invnorm(1-0.041/2)*0.8" "2+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)
}

*False discovery risk with LSI and wider null hypothesis:
if "`argument'"=="example3"{
noisily disp `"fdrisk, nulllo(log(1/1.5)) nullhi(log(1.5)) stderr(0.8) nullspace(0) altspace("2.5-1*invnorm(1-0.041/2)*0.8" "2.5+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)"'
noisily fdrisk, nulllo(log(1/1.5)) nullhi(log(1.5)) stderr(0.8) nullspace(0) ///
altspace("2.5-1*invnorm(1-0.041/2)*0.8" "2.5+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)
}
*False confirmation risk example:
if "`argument'"=="example4"{
noisily disp `"fdrisk, fcr nulllo(log(1/1.5)) nullhi(log(1.5)) stderr(0.15) nullspace("0.01 - 1*invnorm(1-0.041/2)*0.15" "0.01 + 1*invnorm(1-0.041/2)*0.15") altspace(log(1.5) 1.25*log(1.5)) likelihood(0.125)"'
noisily fdrisk, fcr nulllo(log(1/1.5)) nullhi(log(1.5)) stderr(0.15) ///
nullspace("0.01 - 1*invnorm(1-0.041/2)*0.15" "0.01 + 1*invnorm(1-0.041/2)*0.15") altspace(log(1.5) 1.25*log(1.5)) likelihood(0.125)
}
Expand Down
13 changes: 7 additions & 6 deletions sgpv/fdrisk.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ The default is to calculate the false discovery risk, when the observed second-g
{opt lik:elihood(#)} likelihood support interval with level 1/k was used to calculated the SGPV.

{phang}
{opt nulls:pace(string)} support of the null probability distribution.
The "nullspace" can contain either one or two numbers. These numbers can be also formulas which must enclosed in " ".
{opt nulls:pace(lower_bound upper_bound)} support of the null probability distribution.
The "nullspace" can contain either one or two numbers. These numbers can be also formulas which must enclosed in " ".
If "nullspace" is one number, then no distribution for the null parameter space is used.
If "nullspace" contains two numbers separated by a space, then the distribution for the null parameter space are either the Uniform-distribution or the Truncated-Normal-distribution (option {cmd:nulltruncnormal}).
The Uniform-distribution is used as the default.
Expand All @@ -99,7 +99,7 @@ The Uniform-distribution is used as the default.
{opt nullt:runcnormal} use the Truncated-Normal-distribution as the probability distribution for the null parameter space with the mean being the middlepoint of the nullspace and standard deviation given by option {cmd:stderr}.

{phang}
{opt alts:pace(string)} support for the alternative probability distribution.
{opt alts:pace(lower_bound upper_bound)} support for the alternative probability distribution.
The "altspace" can contain either one or two numbers. These numbers can be also formulas which must enclosed in " ".
If "altspace" is one number, then no distribution for the alternative parameter space is used.
If "altspace" contains two numbers separated by a space, then the distribution for the alternative parameter space are either the Uniform-distribution or the Truncated-Normal-distribution (option {cmd:alttruncnormal}).
Expand All @@ -109,7 +109,8 @@ The Uniform-distribution is used as the default.
{opt altt:runcnormal} use Truncated-Normal-distribution as the probability distribution for the alternative parameter space with the mean being the middlepoint of the altspace and the standard deviation given by option {cmd:stderr}.

{phang}
{opt p:i0(#)} prior probability of the null hypothesis. Default is 0.5. This value can be only between 0 and 1 (exclusive).
{opt p:i0(#)} prior probability of the null hypothesis. Default is 0.5.
This value can be only between 0 and 1 (exclusive).
A prior probability outside of this interval is not sensible.
The default value assumes that both hypotheses are equally likely.

Expand All @@ -122,7 +123,7 @@ To download the file together with the rest of the examples {net "get sgpv.pkg,
. fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(log(1/1.1) log(1.1))
altspace("2-1*invnorm(1-0.05/2)*0.8" "2+1*invnorm(1-0.05/2)*0.8") level(95)

{pstd}{bf:False discovery risk with 1/8 likelihood support level:}(Click to {stata do fdrisk-examples.do example2a:run} the example.){break}
{pstd}{bf:False discovery risk with 1/8 likelihood support level:}(Click to {stata run fdrisk-examples.do example2a:run} the example.){break}
. fdrisk, nulllo(log(1/1.1)) nullhi(log(1.1)) stderr(0.8) nullspace(0)
altspace("2-1*invnorm(1-0.041/2)*0.8" "2+1*invnorm(1-0.041/2)*0.8") likelihood(0.125)

Expand Down Expand Up @@ -157,7 +158,7 @@ Sven-Kristjan Bormann, School of Economics and Business Administration, Universi

{title:Bug Reporting}
{psee}
Please submit bugs, comments and suggestions via email to: {browse "mailto:sven-kristjan@gmx.de":sven-kristjan@gmx.de}{p_end}
Please submit bugs, comments and suggestions via email to: {browse "mailto:sven-kristjan@gmx.de":sven-kristjan@gmx.de}{p_end}
{psee}
Further Stata programs and development versions can be found under {browse "https://github.com/skbormann/stata-tools":https://github.com/skbormann/stata-tools}{p_end}

Expand Down
2 changes: 1 addition & 1 deletion sgpv/sgpower.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ from {browse "https://journals.plos.org/plosone/article/file?id=10.1371/journal.
{opt nullhi(#)} the upper bound for the indifference zone (null interval) upon which the second-generation {it:p}-value is based.

{phang}
{opt l:evel(#)} use a confidence interval with level (1-α)100%. The default is {cmd:level(95)} if option {cmd:likelihood} or another confidence level is not set.
{opt l:evel(#)} use a confidence interval with level (1-α)100%. The default is {cmd:level(95)} or as set by {helpb set level} if option {cmd:likelihood} or another confidence level is not set.

{phang}
{opt lik:elihood(#)} use a likelihood support interval with level 1/k.
Expand Down
21 changes: 16 additions & 5 deletions sgpv/sgpv.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*!Calculate the Second-Generation P-Value(s)(SGPV) and their associated diagnosis statistics after common estimation commands based on Blume et al. 2018,2019
*!Author: Sven-Kristjan Bormann
*!Version 1.2a 01.02.2021: Fixed a bug with the level option. Fixed a bug with regards to leading whitespaces when prefixing sgpv.
*!Version 1.2 27.12.2020 : Changed the name of the option permament to permdialog to clarify the meaning of the option. ///
Fixed the format option in the Dialog box. ///
Added a remove option for the menu subcommand to remove the entries in the profile.do created by the option permdialog. ///
Expand Down Expand Up @@ -326,15 +327,25 @@ if "`bonus'"=="all"| "`all'"=="all"{
}

**Estimation command
local cmd = ustrltrim("`cmd'") // Remove trailing whitespaces which could make the second comparison fail
*Assuming that any estimation command will report a matrix named "r(table)" and a macro named "e(cmd)"
if "`cmd'"!=""{
//Remove any level option set for the estimation command by the one for the sgpv command
gettoken com opt:cmd,parse(,)
local opt:list uniq opt // assuming that options are allowed to appear only once
if ustrregexm("`opt'","level\(\d+\)") disp "The level option of your estimation command is overwritten by the level option of the {cmd:sgpv} command."
local opt = cond(ustrregexm("`opt'","level\(\d+\)"),ustrregexrf("`opt'","level\(\d+\)","level(`level')"),"`opt' level(`level')")
local cmd `com'`opt'
`quietly' `cmd'
if "`com'"!="`cmd'"{
local opt:list uniq opt // assuming that options are allowed to appear only once
if ustrregexm("`opt'","level\(\d+\)"){
disp "The level option of your estimation command is overwritten by the level option of the {cmd:sgpv} command."
}

local opt = cond(ustrregexm("`opt'","level\(\d+\)"),ustrregexrf("`opt'","level\(\d+\)","level(`level')"),"`opt' level(`level')")
local cmd `com' `opt'
`quietly' `cmd'
}
else{
`quietly' `cmd', level(`level')
}

}
else if "`e(cmd)'"!=""{ // Replay previous estimation
quietly `e(cmd)' , level(`level')
Expand Down
24 changes: 11 additions & 13 deletions sgpv/sgpv.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The formulas for the Second-Generation P-Values can be found {help sgpv##formula
This is mostly a convenience feature so that the help-files for the individual commands should be consulted for the options of these commands.
Supported subcommands are: {help sgpvalue:value}, {help sgpower:power}, {help fdrisk:risk}, {help plotsgpv:plot} and {help sgpv##menuInstall:menu}.
Two examples how to use the subcommands are given {help sgpv##subcmds_example:here}.
Using the subcommands directly is comparable to the immediate form of other Stata commands, like {help ttesti:ttesti}.
Using the individual commands directly is comparable to the immediate form of other Stata commands, like {help ttesti:ttesti}.

{marker options}{...}
{title:Options}
Expand Down Expand Up @@ -159,10 +159,10 @@ Multiple coefficients must be separated with a space.
You can also select only an equation by using "eq:" or select a specific equation and variable "eq:var". See{help sgpv##multiple-equations-example: the multiple equations example} for an example and the definition of {it:coeflist} below.
{marker coeflist}{...}
{it:coeflist} is
A {it:coeflist} is:
{it:coef} [{it:coef} ...]
{cmd:[}{it:eq}{cmd:]}{it:coef} [{cmd:[}{it:eq}{cmd:]}{it:coef}...]
{cmd:eq:}
{it:eq:}{it:coef} [{it:eq:}{it:coef} ...]
{cmd:eq:} [{cmd:eq:}]
{phang}
Expand All @@ -186,8 +186,7 @@ The default is 0 (the same bound as for the usually reported p-values). Missing
More than one null-hypothesis is also supported. Each upper bound must be separated with a space.
The number of upper bounds must match the number of arguments set in the {cmd:coefficient}-option.
The number of lower and upper bounds must also match.
See {help sgpv##multiple-null-hypotheses-example:these examples} for a demonstration.
See {help sgpv##multiple-null-hypotheses-example:these examples} for a demonstration. {p_end}
{marker boundlist}{...}
{pstd}A {it:boundlist} is:{p_end}
{phang2} # [# ...]{p_end}
Expand All @@ -200,7 +199,7 @@ Using this default value will always result in having SGPVs of value 0 or 0.5!{p
{dlgtab:Reporting}
{phang}
{opt l:evel(#)} set the level of the confidence interval.
The default is {cmd:level(95)}. See also {helpb estimation options##level():[R] estimation options}.
The default is {cmd:level(95)} or as set by {helpb set level}. See also {helpb estimation options##level():[R] estimation options}.
This option overwrites the same named option of an estimation command.
A warning is displayed in the beginning if this happens.
Expand Down Expand Up @@ -231,22 +230,21 @@ Using both options together has the same effect as using this option alone.
This option is {bf:NOT} identical to the same named option of {cmd:matlist}, but works independently of it.
Setting the format option via {cmd:matlistopt()} overrides the setting here and also changes the format of the column names.
{pstd}The following options are only needed for the calculations of the False Discovery Risk (fdr).
{phang}The following options are only needed for the calculations of the {bf:False Discovery Risk} (fdr).
More information about each option can be found in the help for {help fdrisk}.
{p_end}
{phang}
{phang2}
{opt trunc:normal} use the truncated normal distribution as the probability distribution for the null and alternative parameter space.
The default is to use the uniform distribution as the probability distribution for the null and alternative parameter space.
The mean and standard deviation of the distribution are automatically set based on the estimated coefficient.
{phang}
{phang2}
{opt lik:elihood(#)} use a 1/k likelihood support interval (LSI) instead of a (1-α)100% confidence interval to calculate the Fdr.
This option works only in combination with the option {cmd:matrix()} for a user supplied matrix.
The level should be set equal to the level of the LSI which was used to calculate the lower and upper bound of the estimated coefficients.
No official Stata command reports likelihood support intervals.
{phang}
{phang2}
{opt p:i0(#)} prior probability of the null hypothesis. Default is 0.5. This value can be only between 0 and 1 (exclusive).
A prior probability outside of this interval is not sensible.
The default value assumes that both hypotheses are equally likely.
Expand Down
2 changes: 1 addition & 1 deletion sgpv/sgpvalue.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ If multiple bounds are used, the number of upper bounds must match the number of
The number of lower bounds must always match the number of upper bounds in option {it:nulllo}.

{marker boundlist}{...}
{it:boundlist} is:
A {it:boundlist} is:
# [# ...]
{help exp} [{help exp}]

Expand Down

0 comments on commit 7afbfe7

Please sign in to comment.