document.write( "Question 1163084: 1. Three supermarket chains in Quezon City each claim to have the lowest overall prices. As part of an investigative study on supermarket advertising, a particular news company selected nine available grocery items on a particular day. Then, the price of each selected item was checked at each of the three chains as shown in the table. Use  = 0.05 to compare the prices.\r
\n" ); document.write( "\n" ); document.write( "Item Supermarket 1 Supermarket 2 Supermarket 3
\n" ); document.write( "1 55.00 50.10 52.57
\n" ); document.write( "2 56.00 54.05 59.45
\n" ); document.write( "3 84.50 93.85 102.20
\n" ); document.write( "4 109.80 102.65 114.00
\n" ); document.write( "5 117.90 103.15 113.00
\n" ); document.write( "6 198.50 212.25 203.90
\n" ); document.write( "7 248.10 243.20 248.10
\n" ); document.write( "8 229.95 202.95 229.45
\n" ); document.write( "9 271.20 268.25 287.90
\n" ); document.write( "
\n" ); document.write( "

Algebra.Com's Answer #854393 by CPhill(2264)\"\" \"About 
You can put this solution on YOUR website!
```python?code_reference&code_event_index=1
\n" ); document.write( "import pandas as pd
\n" ); document.write( "import scipy.stats as stats\r
\n" ); document.write( "\n" ); document.write( "data = {
\n" ); document.write( " 'S1': [55.00, 56.00, 84.50, 109.80, 117.90, 198.50, 248.10, 229.95, 271.20],
\n" ); document.write( " 'S2': [50.10, 54.05, 93.85, 102.65, 103.15, 212.25, 243.20, 202.95, 268.25],
\n" ); document.write( " 'S3': [52.57, 59.45, 102.20, 114.00, 113.00, 203.90, 248.10, 229.45, 287.90]
\n" ); document.write( "}\r
\n" ); document.write( "\n" ); document.write( "df = pd.DataFrame(data)\r
\n" ); document.write( "\n" ); document.write( "# Randomized Complete Block Design (RCBD)
\n" ); document.write( "# We treat \"Items\" as blocks because the price variance between a bag of rice and a candy bar
\n" ); document.write( "# is huge, but the variance across supermarkets for the SAME item is what matters.\r
\n" ); document.write( "\n" ); document.write( "# Calculate means
\n" ); document.write( "means = df.mean()\r
\n" ); document.write( "\n" ); document.write( "# Perform Two-Way ANOVA without replication (since each item is a block)
\n" ); document.write( "f_stat, p_val = stats.f_oneway(df['S1'], df['S2'], df['S3'])\r
\n" ); document.write( "\n" ); document.write( "# However, standard f_oneway is for Independent groups.
\n" ); document.write( "# For RCBD we need to extract the block effect.
\n" ); document.write( "# SS_total = SS_between_supermarkets + SS_between_items + SS_error\r
\n" ); document.write( "\n" ); document.write( "# Total Mean
\n" ); document.write( "grand_mean = df.values.mean()\r
\n" ); document.write( "\n" ); document.write( "# SS Total
\n" ); document.write( "ss_total = ((df.values - grand_mean)**2).sum()\r
\n" ); document.write( "\n" ); document.write( "# SS Blocks (Items)
\n" ); document.write( "ss_blocks = 3 * ((df.mean(axis=1) - grand_mean)**2).sum()\r
\n" ); document.write( "\n" ); document.write( "# SS Treatments (Supermarkets)
\n" ); document.write( "ss_treatments = 9 * ((df.mean(axis=0) - grand_mean)**2).sum()\r
\n" ); document.write( "\n" ); document.write( "# SS Error
\n" ); document.write( "ss_error = ss_total - ss_blocks - ss_treatments\r
\n" ); document.write( "\n" ); document.write( "# Degrees of Freedom
\n" ); document.write( "df_blocks = 8
\n" ); document.write( "df_treatments = 2
\n" ); document.write( "df_error = df_blocks * df_treatments\r
\n" ); document.write( "\n" ); document.write( "# Mean Squares
\n" ); document.write( "ms_treatments = ss_treatments / df_treatments
\n" ); document.write( "ms_error = ss_error / df_error\r
\n" ); document.write( "\n" ); document.write( "# F-statistic for Supermarkets
\n" ); document.write( "f_calc = ms_treatments / ms_error
\n" ); document.write( "p_value_final = 1 - stats.f.cdf(f_calc, df_treatments, df_error)\r
\n" ); document.write( "\n" ); document.write( "print(f\"{means=}\")
\n" ); document.write( "print(f\"{ss_total=}\")
\n" ); document.write( "print(f\"{ss_blocks=}\")
\n" ); document.write( "print(f\"{ss_treatments=}\")
\n" ); document.write( "print(f\"{ss_error=}\")
\n" ); document.write( "print(f\"{f_calc=}\")
\n" ); document.write( "print(f\"{p_value_final=}\")\r
\n" ); document.write( "\n" ); document.write( "```
\n" ); document.write( "```text?code_stdout&code_event_index=1
\n" ); document.write( "means=S1 152.327778
\n" ); document.write( "S2 147.827778
\n" ); document.write( "S3 156.730000
\n" ); document.write( "dtype: float64
\n" ); document.write( "ss_total=174336.29727407405
\n" ); document.write( "ss_blocks=173160.07200740743
\n" ); document.write( "ss_treatments=356.63736296296634
\n" ); document.write( "ss_error=819.5879037036509
\n" ); document.write( "f_calc=3.4811383755309335
\n" ); document.write( "p_value_final=0.05556998578932093\r
\n" ); document.write( "\n" ); document.write( "```
\n" ); document.write( "To compare the prices across the three supermarket chains, we use a **Randomized Complete Block Design (RCBD)**. In this study, the **Items** act as \"Blocks\" because the price difference between items (e.g., item 1 vs item 9) is much larger than the price difference between supermarkets.\r
\n" ); document.write( "\n" ); document.write( "### 1. Hypotheses
\n" ); document.write( "* **$H_0$ (Null Hypothesis):** There is no significant difference in the mean prices across the three supermarkets ($\mu_1 = \mu_2 = \mu_3$).
\n" ); document.write( "* **$H_A$ (Alternative Hypothesis):** At least one supermarket has a significantly different mean price.\r
\n" ); document.write( "\n" ); document.write( "### 2. Summary Statistics
\n" ); document.write( "* **Supermarket 1 Mean:** 152.33
\n" ); document.write( "* **Supermarket 2 Mean:** 147.83
\n" ); document.write( "* **Supermarket 3 Mean:** 156.73\r
\n" ); document.write( "\n" ); document.write( "### 3. ANOVA Table (RCBD)
\n" ); document.write( "Using the data provided, we calculate the Sum of Squares ($SS$), Degrees of Freedom ($df$), and Mean Squares ($MS$).\r
\n" ); document.write( "\n" ); document.write( "| Source of Variation | Sum of Squares ($SS$) | $df$ | Mean Square ($MS$) | $F$-calc |
\n" ); document.write( "| :--- | :--- | :--- | :--- | :--- |
\n" ); document.write( "| **Supermarkets (Treatments)** | 356.64 | 2 | 178.32 | **3.48** |
\n" ); document.write( "| **Items (Blocks)** | 173,160.07 | 8 | 21,645.01 | - |
\n" ); document.write( "| **Error** | 819.59 | 16 | 51.22 | - |
\n" ); document.write( "| **Total** | 174,336.30 | 26 | - | - |\r
\n" ); document.write( "\n" ); document.write( "### 4. Decision Rule
\n" ); document.write( "* **Significance Level ($\alpha$):** 0.05
\n" ); document.write( "* **Degrees of Freedom:** $df_1 = 2$, $df_2 = 16$
\n" ); document.write( "* **Critical Value ($F_{crit}$):** Using an F-table for $F(2, 16)$ at $\alpha = 0.05$, the critical value is **3.63**.
\n" ); document.write( "* **p-value:** 0.0556\r
\n" ); document.write( "\n" ); document.write( "### 5. Conclusion
\n" ); document.write( "Since the calculated $F$-value (**3.48**) is **less than** the critical value (**3.63**), and the $p$-value (**0.0556**) is **greater than** $\alpha = 0.05$, we **fail to reject the null hypothesis**.\r
\n" ); document.write( "\n" ); document.write( "**Final Interpretation:** At the 5% level of significance, there is **not enough evidence** to conclude that there is a significant difference in the overall prices among the three supermarket chains in Quezon City. While Supermarket 2 has a lower numerical average in this sample, the variation is not statistically significant.\r
\n" ); document.write( "\n" ); document.write( "Does this result surprise you, or does it align with what you'd expect from \"lowest price\" advertising wars?
\n" ); document.write( "
\n" );