Module 13 Two-Way Summary

Specific parts of a full Two-Way ANOVA analysis were described in Module 12. In this module, a workflow for a full analysis is offered and that workflow is demonstrated with several examples.

13.1 Suggested Workflow

The following is a process for fitting a Two-Way ANOVA model. Consider this process as you learn to fit Two-Way ANOVA models, but don’t consider this to be a concrete process for all models.

  1. Briefly introduce the study (i.e., provide some background for why this study is being conducted).
  2. State the hypotheses to be tested.
  3. Show the sample size per group using xtabs() and comment on whether the study was balanced (i.e., same sample size per group) or not.
  4. Address the independence assumption.
    • If this assumption is not met then other analysis methods must be used.64
  5. Fit the untransformed ultimate full model (i.e., both main effects and the interaction effect) model with lm().
  6. Check the other three assumptions for the untransformed model with assumptionCheck().
    • Check equality of variances with a Levene’s test and residual plot.
    • Check normality of residuals with a Anderson-Darling test and histogram of residuals.
    • Check for outliers with an outlier test, residual plot, and histogram of residuals.
  7. If an assumption or assumptions are violated, then attempt to find a transformation where the assumptions are met.
    • Use the trial-and-error method with assumptionCheck(), theory, or experience to identify a possible transformation. Always try the log transformation first.
    • If only an outlier exists (i.e., there are equal variances and normal residuals) and no transformation corrects the outlier then consider removing the outlier from the data set.
    • Fit the ultimate full model with the transformed response or reduced data set.
  8. Construct an ANOVA table for the full model with anova().
    • If a significant interaction exists then do NOT interpret the main effects!!
    • If a significant interaction does NOT exist then interpret the main effects.
      • Fit a new model without the insignificant interaction term.
  9. If an effect exists, then use a multiple comparison technique with emmeans() and summary() to identify specific differences. Describe specific differences using confidence intervals.
    • If a significant interaction exists then perform multiple comparisons on the interaction term using the model that contained an interaction term.
    • If a significant interaction does not exist then perform multiple comparisons for each factor for which a main effect exists using the model without an interaction term.
  10. Create a summary graphic of treatment means (i.e., an interaction plot) on the original scale with 95% confidence intervals using ggplot() and results from emmeans() using the model with an interaction term.
  11. Write a succinct conclusion of your findings.

 

13.2 Expected Prices (No Transformation)

Managers of a retail store felt that the price that consumers expect to pay for a product would be influenced by how much the product was promoted and the advertised amount of discount. To examine this, they gathered 160 volunteers (from different households) who would receive information about the store’s products for a 10-week period. Each volunteer was randomly chosen to receive promotions about one particular product 1, 3, 5, or 7 times during that period and with an advertised discount of 10, 20, 30, or 40%. At the end of the 10-week period the researchers asked each participant to report the price they expected to pay for the product.65

The statistical hypotheses to be examined are

\[ \begin{split} H_{0}&: ``\text{no interaction effect''} \\ H_{A}&: ``\text{interaction effect''} \end{split} \]

\[ \begin{split} H_{0}&: ``\text{no promotions effect''}: \mu_{1} = \mu_{3} = \mu_{5} = \mu_{7} \\ H_{A}&: ``\text{promotions effect''}: \text{At least one pair of level means is different} \end{split} \]

\[ \begin{split} H_{0}&: ``\text{no discount effect''}: \mu_{10} = \mu_{20} = \mu_{30} = \mu_{40} \\ H_{A}&: ``\text{discount effect''}: \text{At least one pair of level means is different} \end{split} \]

where \(\mu\) is the mean expected price and the subscripts identify the levels of each factor as defined above.

This study was “balanced” as the number of participants was the same in each combination of number of promotions and amount of discount (Table 13.1).

Table 13.1: Number of participants in each combination of number of promotions and amount of discount.
Discounts
10 20 30 40
Promotions
1 10 10 10 10
3 10 10 10 10
5 10 10 10 10
7 10 10 10 10

 

Variances among the treatments appear to be constant (Levene’s p=0.4162) and the boxplots of residuals appear fairly similar given the small group sample size (Figure 13.1-Right); the residuals appear to be approximately normally distributed (Anderson-Darling p=0.6255; Figure 13.1-Left); and there are no significant outliers (outlier test p=0.6285), though some residuals appear somewhat larger in some treatments (Figure 13.1-Right).

 

Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of expected price for each combination of number of promotions and discount rate.

Figure 13.1: Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of expected price for each combination of number of promotions and discount rate.

 

The participants were not randomly selected for the study but they were specifically not from the same household and they were randomly allocated to the combination of number of promotions and discount amount. Thus, there is no reason to believe that individuals are connected either within or among treatments. Thus, the independence assumption appears to have been met. These data will be examined with a Two-Way ANOVA without transformation because all assumptions have been adequately met.

There does not appear to be a significant interaction effect (p=0.9121; Table 13.2). There does however appear to be main effects for both the number of promotions (p<0.00005) and amount of discount (p<0.00005).

Table 13.2: Two-way ANOVA results for expected price among different numbers of promotions and amounts of discount.
Df Sum Sq Mean Sq F value Pr(>F)
Promo 3 6.024 2.008 34.385 0.0000
Discount 3 7.824 2.608 44.661 0.0000
Promo:Discount 9 0.231 0.026 0.439 0.9121
Residuals 144 8.409 0.058

 

Tukey’s multiple comparison results suggest that the mean expected price does not differ between when one and three promotions are used (p=0.9476) but does decline from three to five promotions (p<0.00005) and from five to seven promotions (p=0.0079; Table 13.3). For example, the mean expected price drops between 0.13 and 0.41 dollars from three to five promotions and between 0.03 and 0.31 dollars from five to seven promotions.

Table 13.3: Tukey’s multiple comparisons of differences in mean expected price among all pairs of numbers of promotions.
contrast estimate lower.CL upper.CL p.value
1 - 3 0.03 -0.11 0.17 0.9476
1 - 5 0.30 0.16 0.43 0.0000
1 - 7 0.47 0.33 0.61 0.0000
3 - 5 0.27 0.13 0.41 0.0000
3 - 7 0.44 0.30 0.58 0.0000
5 - 7 0.17 0.03 0.31 0.0079

 

Tukey’s multiple comparison results suggest that the mean expected price differed between all pairs of amounts of discount (p≤0.0021; Table 13.4). The mean expected price declined between 0.06 and 0.33 dollars from a discount rate of 10% to 20% (p=0.0019) and between 0.26 and 0.53 dollars from a discount rate of 20% to 30% (p<0.00005), but increased between 0.06 and 0.33 dollars from a discount rate of 30% to 40% (p=0.0021).

Table 13.4: Tukey’s multiple comparisons of differences in mean expected price among all pairs of amounts of discount.
contrast estimate lower.CL upper.CL p.value
10 - 20 0.19 0.06 0.33 0.0019
10 - 30 0.59 0.45 0.73 0.0000
10 - 40 0.40 0.26 0.54 0.0000
20 - 30 0.40 0.26 0.53 0.0000
20 - 40 0.20 0.07 0.34 0.0011
30 - 40 -0.19 -0.33 -0.06 0.0021

 

From these results it appears that if there is no difference in mean expected price for three or less promotions, but after that the mean expected price drops with increasing numbers of promotions, regardless of the amount of discount offered. Regardless of the number of promotions, consumers expect to pay less with increasing amount of discount up to 30%, but the mean expected price increased when the discount was increased to 40% (Figure 13.2).

 

Mean expected price for each combination of number of promotions and discount amount.

Figure 13.2: Mean expected price for each combination of number of promotions and discount amount.

R Code and Results

d <- read.csv("http://derekogle.com/Book207/data/Discount.csv")
d$Promo <- factor(d$Promo)        # because recorded as numbers
d$Discount <- factor(d$Discount)  # because recorded as numbers
lm1.d <- lm(Eprice~Promo+Discount+Promo:Discount,data=d)
xtabs(~Promo+Discount,data=d)
assumptionCheck(lm1.d)
anova(lm1.d)
lm1.d.noint <- lm(Eprice~Promo+Discount,data=d)
mc1.d.promo <- emmeans(lm1.d.noint,specs=pairwise~Promo)
( mc1sum.d.promo <- summary(mc1.d.promo,infer=TRUE) )
mc1.d.discount <- emmeans(lm1.d.noint,specs=pairwise~Discount)
( mc1sum.d.discount <- summary(mc1.d.discount,infer=TRUE) )
mc1.d <- emmeans(lm1.d,specs=pairwise~Promo:Discount)
mc1sum.d <- summary(mc1.d,infer=TRUE)
pd <- position_dodge(width=0.1)
ggplot(data=mc1sum.d$emmeans,
       mapping=aes(x=Promo,group=Discount,color=Discount,
                   y=emmean,ymin=lower.CL,ymax=upper.CL)) +
  geom_line(position=pd,size=1.1,alpha=0.25) +
  geom_errorbar(position=pd,size=2,width=0) +
  geom_point(position=pd,size=2,pch=21,fill="white") +
  labs(y="Mean Expected Price",x="Number of Promotions") +
  theme_NCStats()

 

13.3 Blood Pressure (No Transformation)

Sodium (Na) plays an important role in the genesis of high blood pressure, and the kidney is the principal organ that regulates the amount of sodium in the body. The kidney contains the Na-K-ATPase enzyme, which is essential for maintaining proper sodium levels. If the enzyme does not function properly, then high blood pressure may result. The activity of this enzyme has been studied in whole kidneys, even though the kidney is known to contain many functionally distinct sites. To see whether any particular site of Na-K-ATPase activity was abnormal with hypertension, Garg et al. (1985) studied Na-K-ATPase activity at different sites along the nephrons of normal rats and specially-bred rats which spontaneously develop hypertension. The sites in the kidney examined were the distal collecting tubule (DCT), cortical collecting duct (CCD), and outer medullary collecting duct (OMCD).

The researchers hypothesized that the level of Na-K-ATPase would be depressed at all sites in the rats with hypertension. This translates to expecting a rat strain effect but not an interaction effect. The authors were also interested in determining if there was a significant difference in the level of Na-K-ATPase activity at the different sites. Thus, the statistical hypotheses to be examined were

\[ \begin{split} H_{0}&: ``\text{no interaction effect''} \\ H_{A}&: ``\text{interaction effect''} \end{split} \]

\[ \begin{split} H_{0}&: ``\text{no rat strain effect''}: \mu_{Normal} = \mu_{Hyper} \\ H_{A}&: ``\text{rat strain effect''}: \mu_{Normal} \neq \mu_{Hyper} \end{split} \]

\[ \begin{split} H_{0}&: ``\text{no site effect''}: \mu_{DCT} = \mu_{CCD} = \mu_{OMCD} \\ H_{A}&: ``\text{site effect''}: \text{At least one pair of level means is different} \end{split} \]

where \(\mu\) is the mean Na-K-ATPase activity and the subscripts identify the levels of each factor as defined above.

Twelve rats were randomly selected for each strain of rat (i.e., normal rats and rats with hypertension) from all rats available in the author’s laboratory. The site of the kidney (DCT, CCD, or OMCD) where the Na-K-ATPase activity (\(pmol\cdot(min\cdot mm)^{-1}\)) was recorded on a rat was also randomly selected so that measurements at each location were recorded from four rats.66

Table 13.5: Number of rats in each combination of rat strain and kidney site.
Kidney Site
CCD DCT OMCD
Strain
Hyper 4 4 4
Normal 4 4 4

 

Variances among treatments appear to be constant (Levene’s p=0.4033) though the boxplots of residuals appear somewhat divergent (Figure 13.3-Right), likely due to the small number of rats per treatment; the residuals appear to be approximately normally distributed (Anderson-Darling p=0.5203; Figure 13.3-Left); and there are no significant outliers (outlier test p=0.1527).

 

Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of Na-K-ATPase activity for each combination of rat type and measurement location.

Figure 13.3: Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of Na-K-ATPase activity for each combination of rat type and measurement location.

 

The rats are probably independent among strains as there is no evidence that “normal” and “hypertensive” rats are in any way related or that a rat could be in both groups. Independence of rats within strains is suspect given that the rats came from the same “pool” of normal and hypertensive rats bred in the lab. This may be acceptable for this experiment, but drawing conclusions to a larger population of rats may be suspect. Finally, rats are likely independent among kidney site groups as a different site was examined for each individual rat (i.e., all three sites were not examined on the same rat). All-in-all, independence is likely met enough to continue with this analysis. Thus, these data will be examined with a two-way ANOVA without transformation because the assumptions have been adequately met.

There appears to be a (weakly) significant interaction effect (p=0.0404; Table 13.6); thus, the main effects cannot be interpreted directly from these results.

 

Table 13.6: Two-way ANOVA results for Na-K-ATPase activity levels among two strains of rats and three sites in the kidney.
Df Sum Sq Mean Sq F value Pr(>F)
strain 1 459.4 459.4 7.139 0.0156
site 2 8287.0 4143.5 64.393 0.0000
strain:site 2 496.0 248.0 3.854 0.0404
Residuals 18 1158.2 64.3

 

Tukey’s method was performed on the interaction effect to more specifically describe the differences among group means (Table 13.7). The mean level of Na-K-ATPase activity was significantly lower for the hypertensive rats then for the normal rats at the DCT site (p=0.0189), but not at the other two sites (p≥0.8359). For example, the mean level of Na-K-ATPase activity was between 2.7 and 38.8 units lower in hypertensive than normal rats at the DCT site. In addition, the mean level of Na-K-ATPase activity was significantly greater at the DCT site than at the CCD and OMCD sites within both strains (p≤0.0029), and Na-K-ATPase activity did not differ between the CCD and OMCD sites for either strain (p≥0.1367). For example, the mean level of Na-K-ATPase activity was between 36.7 and 72.8 units higher at the DCT than at the OMCD site for normal rats.

 

Table 13.7: Tukey’s multiple comparisons of differences in means among all pairs of combinations of rat strain and kidney measurement site.
contrast estimate lower.CL upper.CL p.value
CCD Hyper - DCT Hyper -25.75 -43.78 -7.72 0.0029
CCD Hyper - OMCD Hyper 7.00 -11.03 25.03 0.8148
CCD Hyper - CCD Normal -6.75 -24.78 11.28 0.8359
CCD Hyper - DCT Normal -46.50 -64.53 -28.47 0.0000
CCD Hyper - OMCD Normal 8.25 -9.78 26.28 0.6953
DCT Hyper - OMCD Hyper 32.75 14.72 50.78 0.0002
DCT Hyper - CCD Normal 19.00 0.97 37.03 0.0355
DCT Hyper - DCT Normal -20.75 -38.78 -2.72 0.0189
DCT Hyper - OMCD Normal 34.00 15.97 52.03 0.0001
OMCD Hyper - CCD Normal -13.75 -31.78 4.28 0.1997
OMCD Hyper - DCT Normal -53.50 -71.53 -35.47 0.0000
OMCD Hyper - OMCD Normal 1.25 -16.78 19.28 0.9999
CCD Normal - DCT Normal -39.75 -57.78 -21.72 0.0000
CCD Normal - OMCD Normal 15.00 -3.03 33.03 0.1367
DCT Normal - OMCD Normal 54.75 36.72 72.78 0.0000

It can be difficult to interpret multiple comparisons when an interaction exists, especially if there are many differences among treatment means. A strategy to handle this is to describe how one factor differs among levels of the other factor (e.g., how strain differed among sites) and then vice-versa (e.g., how sites differed among strains).

There is some support for the researcher’s hypothesis that Na-K-ATPase activity levels would be lower in rats with hypertension (Figure 13.4). However, this support was found only for the distal collecting tubule (DCT) site. At all other sites, no difference between hypertensive and normal rats was observed. Furthermore, Na-K-ATPase activity was higher at the DCT site then either of the other two sites for both normal and hypertensive rats.

Mean Na-K-ATPase activity for each combination of rat strain and kidnety measurement site.

Figure 13.4: Mean Na-K-ATPase activity for each combination of rat strain and kidnety measurement site.

R Code and Results

nak <- read.csv("http://derekogle.com/Book207/data/NAKATPase.csv")
lm1.nak <- lm(activity~strain+site+strain:site,data=nak)
xtabs(~strain+site,data=nak)
assumptionCheck(lm1.nak)
anova(lm1.nak)
mc1.nak <- emmeans(lm1.nak,specs=pairwise~site:strain)
( mc1sum.nak <- summary(mc1.nak,infer=TRUE) )
pd <- position_dodge(width=0.1)
ggplot(data=mc1sum.nak$emmeans,
       mapping=aes(x=site,group=strain,color=strain,
                   y=emmean,ymin=lower.CL,ymax=upper.CL)) +
  geom_line(position=pd,size=1.1,alpha=0.25) +
  geom_errorbar(position=pd,size=2,width=0) +
  geom_point(position=pd,size=2,pch=21,fill="white") +
  labs(y="Mean Na-K-ATPase Activity",x="Kidney Measurement Site") +
  theme_NCStats()

 

13.4 Crayfish Foraging (Transformation)

Nystrom and Graneli (1996) examined the importance of intraspecific competition for food as a factor regulating survival, growth, and fecundity in Noble Crayfish (Astacus astacus). In one aspect of their research they examined factors that increased the risk of predation. In this part of their study, the authors assumed that the number of active crayfish (i.e., not in shelters) was an indicator of predation risk (i.e., the crayfish are out of their shelters and are thus more vulnerable). The authors hypothesized that the crayfish’s willingness to risk predation would be greater if competition for food was greater. Thus, the authors created two levels of “competition” by regulating how much food the crayfish received (with the assumption that competition is greater with lesser food). The two feeding regimes were that crayfish were fed ad libitum and that they were fed slightly less than a maintenance ration (called “unfed”). In addition, there is ample evidence that crayfish are more active near dusk and at night as darkness provides some protection from predatory fish. To test for this, the authors included a time of day factor in their study, that had three levels: 1200 (noon), 1700, and 1900.

The authors had a large number of crayfish collected from a local lake that were available to them for this experiment. They randomly placed the crayfish into groups of 50 crayfish that were then “stocked” into plastic tubs that had been filled with sand, small pebbles, and artificial shelters. The tubs were placed haphazardly around an outside area exposed to natural light. Each tub was then assigned a “treatment” that consisted of a combination of feeding level and time of day when the number of active crayfish (out of 50) that were active (i.e., not in a shelter) would be recorded.

The statistical hypotheses to be examined were

\[ \begin{split} H_{0}&: ``\text{no interaction effect''} \\ H_{A}&: ``\text{interaction effect''} \end{split} \]

\[ \begin{split} H_{0}&: ``\text{no competition effect''}: \mu_{Fed} = \mu_{Unfed} \\ H_{A}&: ``\text{competition effect''}: \mu_{Fed} \neq \mu_{Unfed} \end{split} \]

\[ \begin{split} H_{0}&: ``\text{no time effect''}: \mu_{1200} = \mu_{1700} = \mu_{1900} \\ H_{A}&: ``\text{time effect''}: \text{At least one pair of level means is different} \end{split} \]

where \(\mu\) is the mean number of active crayfish and the subscripts identify the levels of each factor as defined above.

This study is not balanced (Table 13.8) as the authors chose to record more groups of crayfish at 1700 (i.e., dusk).

Table 13.8: Number of groups of crayfish in each combination of feeding regime and time of day when the number of active crayfish were recorded.
Time of Day
12 17 19
‘Competition’
Fed 6 12 6
Unfed 6 12 6

 

The authors appeared to take steps to meet the independence assumption. There appears to be independence across all treatments as they used a different set of 50 crayfish for each treatment. In addition, the tubs were placed haphazardly around the area so there should not be any spatial effect such as all unfed treatments being in the same area. Furthermore, they only recorded the number of active crayfish at one time for each tub of crayfish. It would have been much easier to record all three times for each tub of crayfish but this would have violated the independence assumption and required a different analytical method.

Variances among the treatments appear not to be constant (Levene’s p=0.0201) and the boxplots of residuals are quite divergent (Figure 13.5-Right); the residuals do not appear to be approximately normally distributed and are quite left-skwed (Anderson-Darling p<0.00005; Figure 13.5-Left); and there are significant outliers (outlier test p=0.0002), especially in the “Unfed:17” and “Unfed:19” groups (Figure 13.5). Clearly the assumptions are not met and a transformation should be considered.

 

Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of the number of active crayfish (out of 50) activity for each combination of feeding level and time of day.

Figure 13.5: Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of the number of active crayfish (out of 50) activity for each combination of feeding level and time of day.

 

No transformation worked perfectly for these data. However, a log transformation resulted in equal variances (Levene’s p=0.6259), with boxplots of residuals that are not wildly divergent (Figure 13.6-Right); residuals that are note approximately normally distributed (p=0.0004) but are not too strongly skewed (Figure 13.6-Left); and in the continue presence of significant outliers (outlier test p=0.0104; Figure 13.6), mostly in the “Unfed-17” group but also in the “Unfed-19” groups. I did not remove outliers as the sample size is already quite small. The assumptions are most closely met on the log scale, so I will continue to analyze the data with this transformation.

 

Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of the number of active crayfish (out of 50) activity for each combination of feeding level and time of day.

Figure 13.6: Histogram of residuals (Left) and residual plot (Right) for a Two-way ANOVA of the number of active crayfish (out of 50) activity for each combination of feeding level and time of day.

 

There appears to be a significant interaction effect (p=0.0006; Table 13.9); thus, the main effects cannot be interpreted directly from these results.

 

Table 13.9: Two-way ANOVA results for number of active crayfish for two feeding levels and three times of day.
Df Sum Sq Mean Sq F value Pr(>F)
feed 1 42.12 42.12 236.46 0.00000
time 2 7.73 3.86 21.69 0.00000
feed:time 2 3.14 1.57 8.81 0.00064
Residuals 42 7.48 0.18

 

Tukey’s multiple comparisons (Table 13.10) show that mean number of active crayfish did not differ by time of day when the crayfish were fed ad libitum (p≥0.5042). In contrast, in the unfed treatments, the mean number of active crayfish increased from 1200 to 1700 (p<0.00005), but not from 1700 to 1900 (p=0.3489). Additionally, the mean number of active fish was greater in the unfed than in the fed treatments for each time of day (p≤0.0013). For example, the mean number of active crayfish in the unfed treatment was between 5.63 and 24.12 times greater than the mean number of active crayfish in the fed treatment at 1900.

 

Table 13.10: Tukey’s multiple comparisons for ratios of means among all pairs of combinations of feeding levels and times of day. Results were back-transformed from the log scale.
contrast ratio lower.CL upper.CL t.ratio
Fed 12 / Unfed 12 0.35 0.17 0.72 -4.3087
Fed 12 / Fed 17 0.69 0.37 1.30 -1.7559
Fed 12 / Unfed 17 0.09 0.05 0.18 -11.2069
Fed 12 / Fed 19 0.71 0.35 1.48 -1.3781
Fed 12 / Unfed 19 0.06 0.03 0.13 -11.4543
Unfed 12 / Fed 17 1.97 1.05 3.70 3.2194
Unfed 12 / Unfed 17 0.27 0.14 0.50 -6.2316
Unfed 12 / Fed 19 2.04 0.99 4.23 2.9306
Unfed 12 / Unfed 19 0.18 0.08 0.36 -7.1456
Fed 17 / Unfed 17 0.14 0.08 0.23 -11.5751
Fed 17 / Fed 19 1.04 0.55 1.94 0.1646
Fed 17 / Unfed 19 0.09 0.05 0.17 -11.4705
Unfed 17 / Fed 19 7.61 4.05 14.29 9.6156
Unfed 17 / Unfed 19 0.65 0.35 1.23 -2.0194
Fed 19 / Unfed 19 0.09 0.04 0.18 -10.0762

 

The researcher’s primary hypotheses was supported by this study – crayfish in a high competition situation (i.e., unfed) were more willing to take on predation risk by being active outside their shelters (Figure 13.7). Their thought that crayfish would be more active near dusk or at night was partially supported as this was only evident when crayfish were in the high competition scenario.

 

Mean number of active crayfish for each combination of feeding rate and time of day. Means and confidence intervals are back-transformed from the log scale.

Figure 13.7: Mean number of active crayfish for each combination of feeding rate and time of day. Means and confidence intervals are back-transformed from the log scale.

R Code and Results

cray <- read.csv("http://derekogle.com/Book207/data/CrayfishCompetition.csv")
cray$time <- factor(cray$time)   ## because recorded as a number
lm1.cc <- lm(active~feed+time+feed:time,data=cray)
xtabs(~feed+time,data=cray)
assumptionCheck(lm1.cc)
cray$logact <- log(cray$active)
lm1.cct <- lm(logact~feed+time+feed:time,data=cray)
assumptionCheck(lm1.cc,lambday=0)
anova(lm1.cct)
mc1.cct <- emmeans(lm1.cct,specs=pairwise~feed:time,tran="log",type="response")
( mc1sum.cct <- summary(mc1.cct,infer=TRUE) )
pd <- position_dodge(width=0.1)
ggplot(data=mc1sum.cct$emmeans,
       mapping=aes(x=time,group=feed,color=feed,
                   y=response,ymin=lower.CL,ymax=upper.CL)) +
  geom_line(position=pd,size=1.1,alpha=0.25) +
  geom_errorbar(position=pd,size=2,width=0) +
  geom_point(position=pd,size=2,pch=21,fill="white") +
  labs(y="Mean Active Crayfish (out of 50)",x="Time of Day") +
  theme_NCStats()

 


  1. This will not be the case in this course.↩︎

  2. This example is modified from Alwyn et al. (2020) who based it on Kalwani and Kim (1992).↩︎

  3. A better design would have measured the Na-K-ATPase activity at all three sites from the same rates. However, this would have violated the independence assumption and required other methods (repeated-measures or mixed-models) to analyze the data.↩︎