public class ChiSquareGUI
extends javax.swing.JFrame
implements java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener
ChiSquare - GUI Version |
In the examples above, "age" and "e-mails sent per day" are nominal-scale variables only insofar as the indicated categories are relevant to the research. These variables are normally considered on a ratio-scale.
The frequencies are counts of the number of occurrences or observations in the category. The chi-square test investigates whether the observed frequencies and the expected frequencies are the same in each category. The null hypothesis is "no difference."
The chi-square test is commonly used for two types of comparisons:
The chi-square test of association examines the relationship between the observed frequencies over the levels of two variables. The chi-square test for goodness-of-fit examines the observed frequencies over the levels of a single variable. Both uses are supported in this utility.
Launch ChiSquareGUI from GoStats as follows:
Gender Scrolling Method Totals MW CD KB Males 28 15 13 56 Females 21 9 15 45 Totals 49 24 28 101
The data above are in the GoStatsExamples folder in the file chisquare-ex1.txt. The chi-square test for significant differences across categories is performed by selecting the data file and clicking "Analyse": (click to enlarge)
StatView (now JMP) provides the following output for the data set above:
The test statistic is χ2 = 1.462, which follows the chi-square distribution with df = 2. Since the p-value is above .05, the customary threshold for significance is not achieved. The conclusion is that there is no difference in the scrolling methods used by males or females.
The ChiSquareGUI utility also includes a verbose option to output additional information:
Let's work through another example, where the outcome is statistically significant and where post hoc comparisons are used to determine which conditions differ significantly from one another.
Opinion Group Totals Student Teacher Parent Agree 10 12 98 120 Disagree 30 48 102 180 Totals 40 60 200 300
The 2 × 3 contingency table for the data above are stored in chisquare-ex2.txt. To test whether there is a difference in opinion by group, ChiSquareGUI is used as follows:
StatView (now JMP) provides the following output for the data set above:
The test statistic is χ2 = 20.5, which follows the chi-square distribution with df = 2. Since p < .05, the customary threshold for statistical significance is exceeded. The null hypothesis is rejected. The conclusion is that there is a difference between students, teachers, and parents in their response to the question about mobile phone usage in the classroom.
The data in this example are from a chi-square test described by Glass and Hopkins (Statistical Methods in Education and Psychology, 2nd ed., Prentice Hall, 1984, p. 286). Glass and Hopkins' example pertained to the attitude of school superintendents, teachers, and principals toward collective bargaining.
The calculations are detailed in the Glass and Hopkins' reference on page 392. For paired comparisons, the null hypothesis of no difference is rejected if p < .05. As seen above, this occurred for pairs 1:3 and 2:3. This implies that the responses to the question were different between the students and the parents and between the teachers and the parents. However, the null hypothesis remains tenable for the 1:2 comparison; thus, the students and teachers are not deemed to have responded differently to the question. Note that a majority in each group disagreed with the assertion that mobile phone usage should be allowed in the classroom.
16968 1722The first row are the assessments generated by WOT, the second row are the assessments generated by MSA. The first column is the number of sites considered "good", the second column is the number of sites considered "bad". Thankfully, most of the sites were deemed good, or safe. WOT rated 9.21% of the sites bad, or not trustworthy. The figure was 3.36% for MSA. That seems like a substantial difference. The research question is this: Do the results for good vs. bad differ between the two tools? A chi-square test is used to answer the question. The analysis using GoStats is shown below.
18062 628
The result was χ2 = 543.5, df = 1, p < .0001. The answer is "yes". The tools differ in their assessments of web sites as trustworthy.
If df = 1, the calculation of the chi-square statistic may include a "correction for continuity" (see D. J. Sheskin, Handbook of Parametric and Nonparametric Statistical Procedures, 5th ed., CRC Press, 2011, pp. 285-286). The correction is based on the premise that if a continuous distribution, such as the chi-square distribution, is used to estimate a discrete distribution (counts), the Type-I error rate is inflated. The problem is more pronounced for df = 1. The correction downgrades the chi-square statistic slightly to bring it more in line with the desired alpha.
Since df = 1 in this example, a second set of statistics is provided that includes a correction for continuity. The test is a bit more conservative with the correction for continuity; however, the outcome is the same: There was a statistically significant difference between the assessments provided by the two tools (χ2 = 542.5, df = 1, p < .0001).
Again, since df = 1, a second set of statistics is provided that includes the correction for continuity. The test is a bit more conservative; however, the outcome is the same. The null hypothesis remains tenable (χ2 = 0.438, df = 1, p > .05).
The data in this example are from a chi-square test described by Wetherill (Elementary Statistical Methods, London: Methuen, 1969, p. 204). Wetherill's example — from 1969! — was not about mobile phones. The example pertained to the occurrence of a certain disease in a random sample of 112 children.
The null hypothesis is that the number of e-mails received each day is the same. Since p = .2439, the null hypothesis remains tenable (χ2 = 6.7, df = 5, p > .05).
The data for this example are from a chi-square test described by Sheskin (Handbook of Parametric and Nonparametric Statistical Procedures, 5th ed., CRC Press, 2011, p. 279). The data in Sheskin's example pertain to the number of books signed out of a library each day of the week.
Since the two examples above use a single variable, they are examples of the chi-square test for goodness-of-fit. The distribution against which the observed values are compared is the set of expected values. The expected values are computed under the assumption that the categories are equally probable.
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent ae) |
void |
focusGained(java.awt.event.FocusEvent fe) |
void |
focusLost(java.awt.event.FocusEvent fe) |
void |
itemStateChanged(java.awt.event.ItemEvent ie) |
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public void actionPerformed(java.awt.event.ActionEvent ae)
actionPerformed
in interface java.awt.event.ActionListener
public void focusGained(java.awt.event.FocusEvent fe)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent fe)
focusLost
in interface java.awt.event.FocusListener
public void itemStateChanged(java.awt.event.ItemEvent ie)
itemStateChanged
in interface java.awt.event.ItemListener