-
Contents
-
Introduction
- This is a short user manual for the Two-by-two software. Feel free
to send questions or comments to this e-mail address: mortenfa at ifi.uio.no.
The software calculates exact, mid-p values and asymptotic p-values in
2x2 contingency tables. Both unconditional and conditional test statistics
are available.
Download and installation instructions can be found here.
Start the program by running the "main.py" file. A window similar to
the snapshot below should appear. The interface consists of five different
pages and a row of buttons. The pages are accessed by clicking on the tabs
labeled "P-value", "Power", etc. A description of the use and purpose of
each page can be found under their respective headers.
These buttons are available for all pages and do the following:
- Stop - Stop current calculations.
- Save - Save options (calculation options, startup values and
user options) to the file "options.txt". If this file should be lost,
corrupted or otherwise unreadable, a new file will be created the next
time the program is started.
- Restore - Restore all options to default values and save the "options.txt" file.
- Help - Launch the user manual (this page).
- Exit - Quit the application.
-
P-value
- Use this page to calculate p-values (and mid
p-values) for 2x2 tables. The top three buttons on the right represent
the three different ways to do this:
During and after the calculations a report will be written in the "Report" window.
The report includes which options were used, some intermediary values,
the elapsed computing time, and the resulting p-value(s). The options controlling
the calculations (like the hypothesis and the test statistic) may be set
in the options page. The contents of the report
window may be saved as a text file by using the "Save report" button. (Some
of the text may be selected and copied into the copy-buffer or saved directly
to file. Use the right mouse button to access this feature.)
Details
Calculation details from the last test will be displayed by pressing
the "Details" button. This feature is only available for conditional and
unconditional tests. Some properties of the figures (like the colours of
the acceptance region and the rejection region) may be changed by using
the buttons in the top of the windows. The windows are also resizable and
the contents may be saved to file (more on this here).
- Conditional test details A window showing the distribution of
the test statistic values
will appear. In general, the test statistic, T(n), is a
function of all possible tables. But in a conditional test, the row and
column sums are fixed, so that the table is given as a function of x11 only.
The observed table is the one tagged with an "X". Position the mouse
above a column to see the actual T-value of this table.
- Unconditional test details Three windows will appear: one showing
the distribution of the test statistic values
and two showing the p-value and mid p-value as functions of the nuisance
parameter (π). The test statistic window will now show a two-dimensional
function T(n) as no conditions are set on the n+1 or n+2 values.
(If a rather large table was computed, the test statistic window may
take some time being created.)
Below is an example of the window showing the p-value
as a function of π. This is a visualisation of how the maximum p(π)-value
is found: First the π-interval, (0,1) if no confidence interval is
used, is partitioned into a number of discreet values and their p-value
is calculated. The greatest of these values are then picked. A finer
dicretization is then made around each of these π-values and new p-values
are evaluated. The final p-value is chosen as the greatest of all calculated
p-values. The number of discreet values in the first partition ("First
sweep"), the number of top values selected ("Tops"), and the number of
values in the second partition ("Second sweep") may be set in the options
page. Clicking the "Create curve" button will produce a window with
a curve representation of the column chart shown in the "First Sweep" page.
The coordinates (pi, p) may be saved to an ordinary text file by using
the "Save data" button.
-
Power
- This page can be used to calculate power for different test types:
- Conditional p - Calculate power for a conditional
test, the p-value version.
- Conditional mid p - Calculate power for a conditional
test, the mid p-value version.
- Conditional both - Calculate power for a conditional
test, both for the p-value version and the mid p-value version.
- Unconditional p - Calculate power for an unconditional
test, the p-value version.
- Unconditional mid p - Calculate power for an unconditional
test, the mid p-value version.
- Unconditional both - Calculate power for an unconditional
test, both for the p-value version and the mid p-value version.
- Asymptotic p - Calculate p-value-power using an asymptotic
test
A report will be written in the "Report" window during and after calculations.
The report includes which options were used, the elapsed computing time,
and the resulting power-value(s). The options controlling the calculations
(like the hypothesis and the test statistic) may be set in the options
page. The contents of the report window may be saved as a text file
by using the "Save report" button. (Some of the text may be selected and
copied into the copy-buffer or saved directly to file. Use the right mouse
button to access this feature.)
Two checkbuttons influence the way the power-values are calculated (but
not the results):
- "Calculate border only" - If this button is on, only the stricktly
necessary p-values (and/or mid p-values) will be calculated, i.e. the
p-values defining the border of the rejection region. Otherwise all p-values
(as defined by the "Pop.1 total" and "Pop.2 total" parameters) will be
calculated. This is, of course, more computer time demanding. If a conditional
test or asymptotic test is selected, all p-values will be calculated
regardless of the checkbutton's state. Note that this option is unavailable
if the Odds ratio test statistic is selected.
- "Visualise while comp." - If on, the p-values will be visualised (more
on this below) in a separate window during calculations.
Details
Pressing the "Details" button will display a window showing the p-values
(and/or mid p-values) used in the power calculation algorithm. Only the
elements with p-values less than the significance level (α) contribute
to the power value. Position the mouse above an element to see the actual
p-value of this element. The colours distinguishing the acceptance region
and the rejection region may be changed by using the buttons in the top
of the window. The window is resizable and the contents may be saved to
file (more on this here).
-
Multipower
- Use this page to calculate several power-values in succession. The bottom
group can be used to decide an interval for one parameter (or two, for example "Pop.1
= Pop.2"). The other available parameter values may be set and different
test statistics chosen. This feature is available for conditional, unconditional
and asymptotic tests. The test statistic chosen in the options
page will now have no effect, but the hypothesis, the "First sweep", "Second
sweep" and "Tops" values, and the confidence interval will function as normal.
Once calculations have started, a window displaying the results will
appear. If the checkbutton "Show remaining computing time [...]" in the user
options page is on, a second popup window will appear to estimate the
remaining computer time. The calculations can be stopped by pressing the "Stop" button.
The two buttons labeled "Save table" and "Save full report" will create
a file containing a text representation of the results. The "Save table" button
will save only the actual calculated values and the headers (more on this
below), while the "Save full report" button will print information on the
parameters and display the table in a more readable format.
-
How to export table to Excel
- Press the button "Save table" and select a file. The table will be
saved as plain text with one line for each row (headers included). The
entries in each row will be separated by a semicolon (;). In Excel, find
the menu "Data" and select the "Get External Data -> Import Text File..." command.
Open the text file saved above. (You may also use the command "Open..." found
in the "File" menu.) In the "Text Import Wizard - Step 1", select "Delimeted" and
press "Next >". In step 2, select the checkbutton labeled "Semicolon" and
deselect all other checkbuttons. Press the "Next >" button. Apply data
formatting (if any) in step 3 and press "Finished". Finally, choose where
you want to put the data and press "OK".
-
Calculation options & startup values
- In this page calculation options and startup values can be changed. The
values selected here may be saved to a file called "options.txt" by using
the "Save" button in the bottom row. The "Restore" button will set all options
to their default state and save the "options.txt" file. The options are:
- Hypothesis - Set the alternative hypothesis (and thereby the
null hypothesis). This will affect all conditional, unconditional and
asymptotic tests performed in the "P-value", "Power" and "Multipower" pages.
- Test statistic - Decide which test
statistic to use. This will affect all conditional, unconditional
and asymptotic tests performed in the "P-value" and "Power" pages (but
not the "Multipower" page).
- How to maximize p(pi) - These values are used in all unconditional
tests to find the maximum value of the function p(π). More
on this here.
- Use confidence interval - A confidence interval for Berger
and Boos correction may be applied instead of the interval (0,
1). The "from", "to" and "gamma" values have to be inserted manually,
but an Excel-program ("Clopper-Pearson.xls") calculating the values
can be found in the main folder (more on this here).
- Table values at startup - The startup values of the table in
the "P-value" page.
- Power (multipower) values at startup - The startup values of
the parameters used to calculate power in the "Power" and "Multipower" pages.
-
User options
- This page provides the user with options that control the use of the program,
not the actual calculations. The values selected here may be saved to a file
called "options.txt" by using the "Save" button in the bottom row. The "Restore" button
will set all options to their default state and save the "options.txt" file.
The options do pretty much what they say they do, so the only thing mentioned
here is that the "Floating-point precision" affects only displayed numbers,
not calculation accuracy.
-
Saving and reusing figures
- All of the figures and charts created by the Two-by-two software
may be saved to file by pressing the "Save figure" button. The only file
format available is postscript. If you intend to use a figure in a non-postscript
environment, you need some kind of graphics-converting software to do this.
Word, for instance, can convert postscript files to a number of different
file formats by itself. Use the "Insert -> Picture -> From File..." menu.
Choose the postcript(ps) file. A window displaying different file formats
should now appear. Try "Encapsulated PostScript" (eps), "Graphics Interchange
Format"(gif) or any other format.
-
Keyboard bindings
-
- Escape - Stop current calculations
- Control + c - Stop current calculations
- Control + s - Save options to file
- Control + r - Restore options to default values and save to file
- Control + h - Display the user manual (this page)
- Control + q - Quit application
- F1 - F5 - Go to page 1 - 5