Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 4 of 4

Categorical fit and model revision

Compute specified and fitted Pearson discrepancies.

Loading your saved responses…

Try

A synthetic inspection records the number of flagged positions in each of 100 two-position items. The observed counts for 0, 1 and 2 flags are 40, 40 and 20. Treat different items as independent observations with a common distribution. Before calculating, distinguish two questions: does a specified Binomial(2, 0.5) distribution fit, or does some Binomial(2, θ) distribution fit? The second question estimates θ from these same observations.

Flags jObserved OFixed θ=0.5: expectedFixed contributionFitted θ=0.4: expectedFitted contribution
040259364/9
140502484/3
220251161
Total1001001210025/9

Each contribution is (observed−expected)²/expected. Recompute the middle row before adding the columns. A small expected count amplifies a fixed absolute discrepancy. The fitted distribution does not reproduce all three observed frequencies: its deviations are 4, −8 and 4.

Predict

Predict whether the two statistics should use the same reference distribution. Counts already have one constraint: their sum is 100. Fitting θ removes another direction of discrepancy, but we must prove which direction and why this estimator removes it.

The upper-tail asymptotic probabilities are approximately 0.002479 for 12 with two degrees of freedom, and 0.09558 for 25/9 with one degree of freedom. At a prechosen 5% level the specified distribution is rejected; the binomial family is not rejected. These answer different null hypotheses. Neither result proves that flags within an item are independent, that future items follow the same law, or that the fitted family is true.

Write the two null hypotheses in words. Then identify which assumptions come from the collection protocol rather than from this table. Choosing a new model because its probability is larger is exploratory model revision; that larger probability is not independent confirmation.

Experiment

Work on paper with a changed sample: 80 independent items produce counts (24, 32, 24). First fit θ by dividing the total number of flags by 160. Record the expected counts, the three contributions and their sum. Keep the category definitions fixed.

Check the changed calculation

There are 80 flags, so θ̂=1/2. Expected counts are (20, 40, 20), giving contributions 0.8, 1.6 and 0.8. Thus X²=3.2. Under the interior fitted-binomial calibration, the approximate upper-tail probability is 0.07364. This is a failure to reject at 5%, not acceptance of the model as established fact.

Now change the protocol rather than the numbers: suppose every inspected item was entered twice. The apparent sample size doubles and the Pearson statistic doubles, but no independent information was added. Explain why the multinomial reference calculation is then invalid. Finally, try merging categories 0 and 2 only after noticing their deviations. Such a data-dependent decision needs its own calibration; it cannot silently inherit the original test’s reference law.

Understand

A specified categorical distribution

Let n independent, identically distributed observations take values in k fixed categories, with specified probabilities p₁,…,pₖ, each positive and summing to 1. Let Oᵢ be the counts and p̂ᵢ=Oᵢ/n. Pearson’s statistic is X²=Σᵢ (Oᵢ−npᵢ)²/(npᵢ).

Here is the precise theorem dependency: the multivariate central limit theorem applied to the category-indicator vector gives √n(p̂−p) converging in distribution to a centered Gaussian vector with covariance diag(p)−ppᵀ. Its off-diagonal entries are −pᵢpⱼ because one observation cannot belong to two different categories. This lesson uses that central limit theorem, not a finite-sample normal identity.

Put s=(√p₁,…,√pₖ) and Z=diag(p)⁻¹ᐟ²√n(p̂−p). Its limiting covariance is P=I−ssᵀ. Since sᵀs=1, P is the orthogonal projection onto the (k−1)-dimensional space perpendicular to s. Indeed sᵀZ=0 exactly because the frequencies sum to 1. In an orthonormal basis of that space the limiting Gaussian has k−1 independent standard normal coordinates. By continuity of squared norm, X²=‖Z‖² converges in distribution to χ² with k−1 degrees of freedom.

This is an asymptotic conclusion for fixed positive p and fixed k as n grows. A rule such as expected counts at least 5 is a screening convention, not the proof or a guarantee of a particular approximation error. Sparse cells may require a finite multinomial calculation or simulation of the specified collection protocol. Deliberately combining categories in advance changes the question and the number of support cells.

If pᵢ=0 and Oᵢ>0, the specified null assigns probability zero to the observation. Report that contradiction; do not divide by zero and return an ordinary chi-square probability. If pᵢ=Oᵢ=0, omit that structural-zero category from the support before computing the statistic and its degrees of freedom. One positive-probability category is deterministic, not an ordinary positive-degree chi-square test. Dependence, unequal item distributions or appreciable sampling without replacement require a different covariance analysis.

Fitting the three-cell binomial family

For θ in (0,1), p(θ)=((1−θ)², 2θ(1−θ), θ²). The likelihood, apart from a factor independent of θ, is θˢ(1−θ)^(2n−S), where S=O₁+2O₂. Differentiating its log gives S/θ−(2n−S)/(1−θ). When 0<S<2n, strict concavity gives the unique maximum θ̂=S/(2n). If S=0 or S=2n the maximum is at 0 or 1. The law of large numbers gives θ̂→θ under the model, since each observation has mean 2θ.

We now justify one degree of freedom rather than invoking a parameter-count slogan. Fix the true interior θ, and let s and Z use p(θ). Define vᵢ=pᵢ′(θ)/√pᵢ(θ). Then

v=(−2, √2(1−2θ)/√(θ(1−θ)), 2), sᵀv=0, Iθ=vᵀv=2/[θ(1−θ)].

The score identity pᵢ′/pᵢ=(i−2θ)/[θ(1−θ)] gives the exact relation √n(θ̂−θ)=Iθ⁻¹vᵀZ. The subtraction of 2θ vanishes because Σ√pᵢ Zᵢ=0. Thus fitting removes precisely the component of Z along v.

More explicitly, Taylor expansion of the quadratic vector p(θ̂), together with √n(θ̂−θ) bounded in probability, shows that the standardized fitted residual vector equals (I−vvᵀ/Iθ)Z plus a vector converging to zero in probability. Replacing √pᵢ(θ) by √pᵢ(θ̂) in the denominators has the same vanishing effect because the true probabilities are positive. The limiting covariance is therefore I−ssᵀ−vvᵀ/Iθ, an orthogonal projection of rank 1. Its squared norm has the χ²₁ law. This uses Taylor expansion, the multivariate CLT and the usual continuous-mapping/Slutsky rules.

For a concrete check, the surviving unit direction is w=(θ, −√(2θ(1−θ)), 1−θ): w is perpendicular to both s and v. For any interior fitted sample put δ=p̂₂−θ̂². Its residual probability vector is exactly (δ,−2δ,δ), and direct substitution gives X²=nδ²/[θ̂²(1−θ̂)²]. The fit tests a remaining shape constraint, not simply whether the sample mean is close to its fitted mean.

At θ=0 or 1 the positive-cell and tangent assumptions fail. The model is deterministic; the interior χ²₁ proof does not apply. Even an interior model can produce a finite sample whose MLE is on the boundary. Report that regular calibration is unavailable for that sample. Estimating a parameter by an arbitrary rule, selecting a family after inspection, or having redundant parameters does not justify subtracting the number of displayed parameters.

Apply

A proposed report says: “All distributions have three cells, so every test has two degrees of freedom. We tried several families, kept the one with the largest probability, and confirmed it on the same counts.” Repair each sentence. State the design assumptions, the exact null, whether its parameters were specified or fitted, the statistic, the reference justification and the uncertainty in the conclusion.

Compare a defensible revision

Three fixed positive cells give two degrees of freedom under iid sampling. This particular interior binomial MLE gives one, by the tangent projection proved above. Searching among families makes the selected result exploratory. A useful next step is to specify the candidate family and a fresh validation protocol before collecting more data. One may refit this prechosen family on the independent validation counts and use its justified fitted reference. Alternatively calibrate an explicitly specified whole selection procedure. Merely treating a noisy training estimate as the unknown true parameter on new data does not remove its estimation uncertainty.

For a separate structural-zero example, use p=(0,0.4,0.6) and counts (0,18,32). The support has two categories, so the statistic is 4/20+4/30=1/3 and its regular asymptotic reference has one degree of freedom. Changing the first count to a positive number contradicts that null outright. A zero observed count in a positive-probability category is different from a structural zero.

Continue

Return to statistical models to state the observation law, and maximum likelihood and boundaries to separate interior fitting from boundary optimization. The asymptotic likelihood lesson supplies broader estimation context; the projection proof here establishes the specific categorical calibration used in this investigation.

Keep the original count table, your prechosen category definitions and the revised collection plan together. A test result is evidence about a stated probability model under a stated observation protocol, not a certificate that every mechanism behind the data has been identified.

Apply · explain · revise

Practice and reasoning

Drafts save locally as you type. Reveal worked solutions when useful; the site remembers that exposure. Automatic matches check the requested answer, while written arguments require review against the rubric.

Independent observations in four predeclared categories have specified probabilities (0.1,0.2,0.3,0.4). Counts are (12,12,20,36). Calculate Pearson contributions and the statistic. Justify the degrees of freedom, state a 5% decision using a calculated upper-tail probability, and explain what would change if every record had been copied once.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

For k≥2 fixed positive category probabilities p, prove the specified Pearson statistic converges to χ² with k−1 degrees of freedom. You may use the multivariate iid CLT and continuous mapping. Derive the indicator covariance and identify the projection, not just the number of constraints. Explain why finite sparse counts do not contradict this asymptotic theorem.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

For 100 iid Binomial(2,θ) observations with counts (18,44,38), derive the MLE from the likelihood, compute expected counts and Pearson statistic, and give the interior fitted upper-tail probability. Prove the exact residual identity (δ,−2δ,δ), where δ=p̂₂−θ̂².

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Assume the true Binomial(2,θ) parameter is interior. Starting from the multinomial CLT, prove that fitting θ by its MLE leaves a rank-one limiting residual covariance. Define the score direction, verify its norm, and justify the fitted denominators. Why is this not a theorem that every fitted parameter costs one degree of freedom?

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Audit three proposed Pearson analyses: (a) p=(0,0.4,0.6), counts (0,18,32); (b) the same p but counts (1,18,31); (c) positive specified probabilities with several expected counts below 1 and observations clustered in repeated measurements of the same item. State what can be calculated, which reference claims are justified, and what repair needs actual design information.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

A sample of n two-position items contains no flags. A report fits θ=0, omits two zero expected cells and announces a fitted χ²₁ probability of 1. It then searches several alternative families on the same sample and calls the best-fitting one independently validated. Repair both claims. Propose a fresh-data procedure, carefully distinguishing a known probability vector from an estimated one.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Reflect and continue

Before marking this lesson complete, explain one key idea without the worked solution and identify a condition that matters. Marking complete records participation, not independent mastery.