stripPlot¶
Analyzes data from strip-plot experiments. Function stripPlot
also
analyzes strip-plot experiments replicated at several locations.
Synopsis¶
stripPlot(nLocations, nStripA, nStripB, block, stripA, stripB, y)
Required Arguments¶
- int
nLocations
(Input) - Number of locations.
nLocations
must be one or greater. IfnLocations
>1 then the optional arraylocations[]
must be included as input tostripPlot
. See optional argumentlocations
. - int
nStripA
(Input) - Number of levels associated with the strip factor A.
nStripA
must be greater than one. - int
nStripB
(Input) - Number of levels associated with the strip factor B.
nStripB
must be greater than one. - int
block[]
(Input) - An array of length
n
containing the block identifiers for each observation iny
. Locations can have different numbers of blocks. Each block at a single location must be assigned a different identifier, but different locations can have the same assignments. - int
stripA[]
(Input) - An array of length
n
containing the factor A strip-plot identifiers for each observation iny
. Each level of this factor must be assigned a different integer. This function verifies that the number of unique factor A strip-plot identifiers is equal tonStripA
. - int
stripB[]
(Input) - An array of length
n
containing the factor B strip-plot identifiers for each observation iny
. Each level of this factor must be assigned a different integer. This function verifies that the number of unique factor B strip-plot identifiers is equal tonStripB
. - float
y[]
(Input) - An array of length
n
containing the experimental observations and any missing values. Missing values cannot be omitted. They are indicated by placing a NaN (not a number) iny
. The NaN value can be set using the functionmachine
(6). The location, strip-plot A, and strip-plot B for each observation iny
are identified by the corresponding values in the argumentslocations, stripA,
andstripB
.
Return Value¶
A two dimensional, 12 by 6 array containing the ANOVA table. Each row in this array contains values for one of the effects in the ANOVA table. The first value in each row, \(\texttt{anovaTable}_{i,0} = \texttt{anovaTable}[\texttt{i}] \times 6\), identifies the source for the effect associated with values in that row. The remaining values in a row contain the ANOVA table values using the following convention:
j |
\(\texttt{anovaTable}_{i,j} = \texttt{anovaTable}[\texttt{i}*6+\texttt{j}]\) |
---|---|
0 | Source Identifier (values described below) |
1 | Degrees of freedom |
2 | Sum of squares |
3 | Mean squares |
4 | F-statistic |
5 | p-value for this F-statistic |
The Source Identifiers in the first column of
\(\text{anovaTable}_{i,j}\) are the only negative values in
anovaTable
. Note that the p-value for the F-statistic is returned as
0.0 when the value is so small that all significant digits have been lost.
Assignments of identifiers to ANOVA sources use the following coding:
Source Identifier | ANOVA Source |
---|---|
-1 | LOCATION† |
-2 | BLOCK WITHIN LOCATION |
-3 | STRIP-PLOT A |
-4 | LOCATION × STRIP-PLOT A† |
-5 | STRIP-PLOT A ERROR |
-6 | STRIP-PLOT B |
-7 | LOCATION × STRIP-PLOT B† |
-8 | STRIP-PLOT B ERROR |
-9 | STRIP-PLOT A × STRIP-PLOT B |
-10 | LOCATION × STRIP-PLOT A × STRIP-PLOT B † |
-11 | STRIP-PLOT A × STRIP-PLOT B ERROR |
-12 | CORRECTED TOTAL |
Notes: †
If nLocations=1
sources involving location are set to
missing (NaN).
Optional Arguments¶
locations
, int[]
(Input)- An array of length
n
containing the location identifiers for each observation iny
. Unique integers must be assigned to each location in the study. This argument is required whennLocations>
1. nMissing
(Output)- Number of missing values, if any, found in y. Missing values are denoted with a NaN (Not a Number) value.
cv
(Output)- An array of length 3 containing the whole-plot, split-plot and sub-plot
coefficients of variation.
cv[0]
contains the whole-plot C.V.,cv[1]
contains the split-plot C.V., andcv[2]
contains the sub-plot C.V. grandMean
, (Output)- Mean of all the data across every location.
stripPlotAMeans
(Output)- An array of length
nStripA
containing the factor A strip-plot means. stripPlotBMeans
(Output)- An array of length
nStripB
containing the factor B strip-plot means. treatmentMeans
(Output)- An array of length (
nStripA
×nStripB
) containing the treatment means. For \(i>0\) and \(j>0\), \(\text{treatmentMeans}_{i,j}\) =treatmentMeans
[(i‑1)×nStripA
+(j‑1)] contains the mean of the observations, averaged over all locations, blocks and replicates, for the i‑th level of the factor A strip-plot and the j‑th level of the factor B strip-plot. stdErrors
(Output)- An array of length 10 containing five standard errors and their
associated degrees of freedom. The standard errors are in the first five
elements and their associated degrees of freedom are reported in
stdErrors
[5] throughstdErrors
[9].
Element | Standard Error for Comparisons Between Two | Degrees of Freedom |
---|---|---|
stdErrors[0] |
Factor A Strip-Plot Means | stdErrors[5] |
stdErrors[1] |
Factor B Strip-Plot Means | stdErrors[6] |
stdErrors[2] |
Factor A Strip-Plot Means at the same level of Factor B | stdErrors[7] |
stdErrors[3] |
Factor B Strip-Plot Means at the same level of Factor A | stdErrors[8] |
stdErrors[4] |
Treatment Means (same strip-plot A and strip-plot B) | stdErrors[9] |
nBlocks
(Output)- An array of length
nLocations
containing the number of blocks, or replicates, at each location. locationAnovaTable
(Output)- A 3-dimensional array of size
nLocations
by 12 by 6 containing the Anova tables associated with each location. For each location, the 12 by 6 dimensional array corresponds to the Anova table for that location. For example,locationAnovaTable
[(i-1)×72+(j-1)×6 + (k-1)] contains the value in the k‑th column and j‑th row of the returned Anova table for the i‑th location. anovaRowLabels
(Output)- An array containing the labels for each of the
nAnova
rows of the returned ANOVA table. The label for the i-th row of the ANOVA table can be printed withprint anovaRowLabels[i]
.
Description¶
Function stripPlot
is capable of analyzing a wide variety of strip-plot
experiments.
The essential distinction between strip-plot and split-plot experiments is the application of factor B. In a split-plot experiment, levels of Factor B are nested within Factor A, see Table 4.28 below. In strip-plot experiments, Factors A and B are completely crossed, see Table 4.27 below. This occurs, for example, when an agricultural field is used as a block and the levels of factor A are applied in vertical strips across the entire field. Levels of factor B are assigned to horizontal strips across the same block.
Strip Plot Factor A | |||||
A2 | A1 | A4 | A3 | ||
Strip Plot Factor B |
B3 | A2B3 | A1B3 | A4B3 | A3B3 |
B1 | A2B1 | A1B1 | A4B1 | A3B1 | |
B2 | A2B2 | A1B2 | A4B2 | A3B2 |
Whole Factor Plot | |||
A2 | A1 | A4 | A3 |
A2B1 | A1B3 | A4B1 | A3B2 |
A2B3 | A1B1 | A4B3 | A3B1 |
A2B2 | A1B2 | A4B2 | A3B2 |
In some studies, a strip-plot experiment is replicated at several locations.
stripPlot
can analyze strip-plot experiments replicated at multiple
locations, even when the number of blocks or replicates at each location are
different. If only a single replicate or block is used at each location,
then location should be treated as a blocking factor, with nLocations
set equal to one. If nLocations=1
, it is assumed that the experiment was
conducted at a single location with more than one block or replicate at that
location. In this case, the four entries associated with location in the
ANOVA table will contain missing values.
However, if nLocations>1
, it is assumed the experiment was repeated at
multiple locations, with blocking occurring at each location. Although the
number of blocks at each location can be different, the number of levels for
the factor A and B strip-plots must be the same at each location. The
locations associated with each of the observations in y
are specified in
the argument locations[]
, which is a required input argument when
nLocations
>1.
Locations are assumed to be random effects, then tests involving factor A strip-plots use the interaction between factor A strip-plots and locations as the error term for testing whether there are statistically significant differences among the levels of factor A. However, this assumes that the interaction of factor A and locations is not statistically significant. A test of this assumption is included in the ANOVA table. If the interaction between factor A strip-plots and locations is statistically significant, then the nature of that interaction should be explored since it impacts the interpretation of the significance of the factor A.
Similarly, when locations are assumed to be random effects, tests involving factor B do not use the strip-plot B errors pooled across locations. Instead, the error term for factor B is the interaction between locations and factor B.
Example¶
This example uses data from a strip-plot design with two levels for the first strip and four for the last strip.
from __future__ import print_function
import sys
from numpy import *
from pyimsl.stat.page import page, SET_PAGE_WIDTH
from pyimsl.stat.multipleComparisons import multipleComparisons
from pyimsl.stat.stripPlot import stripPlot
from pyimsl.stat.writeMatrix import writeMatrix
col_labels = [" ", "\nID", "\nDF", "\nSSQ",
"Mean\nsquares", "\nF", "\np-value"]
page_width = 132
n = 24 # Total number of observations
n_locations = 1 # Number of locations
n_strip_a = 2 # Number of factor A strip-plots
n_strip_b = 4 # Number of factor B strip-plots
block = [1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3]
strip_a = [1, 1, 1, 1, 2, 2, 2, 2,
1, 1, 1, 1, 2, 2, 2, 2,
1, 1, 1, 1, 2, 2, 2, 2]
strip_b = [1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 1, 2, 3, 4]
y = [30.0, 40.0, 38.9, 38.2,
41.8, 52.2, 54.8, 58.2,
20.5, 26.9, 21.4, 25.1,
26.4, 36.7, 28.9, 35.9,
21.0, 25.4, 24.0, 23.3,
34.4, 41.0, 33.0, 34.9]
grand_mean = []
anova_row_labels = []
cv = []
treatment_means = []
strip_plot_a_means = []
strip_plot_b_means = []
std_err = []
n_missing = []
equal_means = []
aov = stripPlot(n_locations, n_strip_a, n_strip_b,
block, strip_a, strip_b, y,
grandMean=grand_mean, cv=cv,
nMissing=n_missing,
stripPlotAMeans=strip_plot_a_means,
stripPlotBMeans=strip_plot_b_means,
treatmentMeans=treatment_means,
stdErrors=std_err,
anovaRowLabels=anova_row_labels)
# Output results
page(SET_PAGE_WIDTH, page_width)
# Print ANOVA table
writeMatrix(" *** ANALYSIS OF VARIANCE TABLE ***",
aov, writeFormat="%3.0f%3.0f%8.2f%7.2f%7.2f%7.3f",
rowLabels=anova_row_labels,
colLabels=col_labels)
print("\nGrand mean: ", grand_mean[0])
# Print treatment means
writeMatrix("Treatment Means", treatment_means)
print("\n\nStandard Error for Comparing Two Treatment Means:")
print(" Same Level of Factor B %f (df=%f)" %
(std_err[2], std_err[7]))
print(" Same Level of Factor A %f (df=%f)" %
(std_err[3], std_err[8]))
print(" Different Factor A and B Levels %f (df=%f)\n" %
(std_err[4], std_err[9]))
# Print factor A means
writeMatrix("Factor A Means", strip_plot_a_means, column=True)
print("\nStandard Error for Comparing Two Factor A Means: \n %f (df=%f)" %
(std_err[0], std_err[5]))
equal_means = multipleComparisons(strip_plot_a_means,
int(std_err[5]), std_err[0] / sqrt(2),
lsd=True, alpha=.05)
# Print multiple comparison results
writeMatrix("LSD Comparison : Size of Groups of Means",
equal_means)
# Print factor B means
writeMatrix("Factor B Means", strip_plot_b_means, column=True)
print("\nStandard Error for Comparing Two Factor B Means: \n %f (df=%f)" %
(std_err[1], std_err[6]))
equal_means = multipleComparisons(strip_plot_b_means,
int(std_err[6]), std_err[1] / sqrt(2),
lsd=True, alpha=.05)
# Multiple comparison results
writeMatrix("LSD Comparison : Size of Groups of Means",
equal_means)
Output¶
Grand mean: 33.87083333333333
Standard Error for Comparing Two Treatment Means:
Same Level of Factor B 2.417643 (df=4.772558)
Same Level of Factor A 2.639322 (df=9.140634)
Different Factor A and B Levels 3.121075 (df=8.405351)
Standard Error for Comparing Two Factor A Means:
1.882171 (df=2.000000)
Standard Error for Comparing Two Factor B Means:
2.330465 (df=6.000000)
*** ANALYSIS OF VARIANCE TABLE ***
Mean
ID DF SSQ squares F p-value
Location -1 ... ........ ....... ....... .......
Block Within Location -2 2 1310.28 655.14 19.89 0.009
Strip-Plot A -3 1 858.01 858.01 40.37 0.024
Location x Strip-Plot A -4 ... ........ ....... ....... .......
Strip-Plot A Error -5 2 42.51 21.26 4.62 0.061
Strip-Plot B -6 3 227.73 75.91 4.66 0.052
Location x Strip-Plot B -7 ... ........ ....... ....... .......
Strip-Plot B Error -8 6 97.76 16.29 3.54 0.075
Strip-Plot A x Strip-Plot B -9 3 13.40 4.47 0.97 0.466
Location x Strip-Plot A -10 ... ........ ....... ....... .......
x Strip-Plot B
Strip-Plot A x Strip-Plot B Error -11 6 27.63 4.60 ....... .......
Corrected Total -12 23 2577.33 ....... ....... .......
Treatment Means
1 2 3 4
1 23.83 30.77 28.10 28.87
2 34.20 43.30 38.90 43.00
Factor A Means
1 27.89
2 39.85
LSD Comparison : Size of Groups of Means
0
Factor B Means
1 29.02
2 37.03
3 33.50
4 35.93
LSD Comparison : Size of Groups of Means
1 2 3
2 3 0