The following code assumes the expected frequencies were not estimated, but predicted a priori. Notice that, to avoid rounding errors, we calculate the total frequency as sum(x) rather than sum(y).
Gives something like this:
Except where otherwise specified, all text and images on this page are copyright InfluentialPoints, all rights reserved. Images not copyright InfluentialPoints credit their source on web-pages attached via hypertext links from those images.