Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Conduct Web experiments using PHP, Part 2

By Paul Meagher
2005-03-18


Model fitting with chi-square

Applying the chi-square test procedure to contingency table data involves computing a goodness-of-fit score by summing over the differences between the observed cell counts and expected cell counts for each cell in the contingency table.

Following are the formulas that compute the chi-square score for one-, two- and three-dimensional contingency tables. The r, c, and l subscripts denote the number of levels associated with the row, column, and layer factors. The second formula is the one I will use in this article.

Figure 2a. Chi-square model-fitting formula, one factor


Figure 2b. Chi-square model-fitting formula, two factors


Figure 2c. Chi-square model-fitting formula, three factors


Use these three model-fitting formulas to analyze the contingency table data resulting from 1-, 2-, or 3-factor Web experiments. (Implementations of the chi-square test procedure for the analysis of 1-, 2-, and 3-dimensional contingency tables are contained in the Chi1D.php, Chi2D.php, and Chi3D.php classes bundled in the downloadable CHI Package accompanying this article. See Resources.)

Generalizations of the chi-square formula to more than three dimensions are possible (for example, add a summation and subscript to the formula for each additional factor), but not used in practice. See logistic and loglinear analysis if you want to analyze experiments having three or more categorical variables. Chi3D.php is still a work in progress.

In all the formulas, the difference score for each cell (such as, E - O ) is squared and rescaled by dividing by the expected value E for that cell. These normalized difference scores are then summed to arrive at an overall goodness-of-fit score.

The fundamental question you need to ask when using the chi-square test procedure is how to compute the expected values to use in this model-fitting procedure.

Tutorial Pages:
» Categorical data analysis
» 2x2 contingency tables
» Sampling model
» Discrete probability distributions
» Binomial sampling model
» Poisson sampling model
» Envisioning your results
» Eliciting your prior distribution
» Model fitting with chi-square
» Null effects model
» Independence model
» Prior model
» DOE explorer
» Explorer output
» Conclusions
» Resources


First published by IBM developerWorks


 | Bookmark
Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1

Ask A Question
characters left.