Help in getting the correct values in the sequential tests of hypothesis in ANOVA in R

Say, I wanted to compare the effect of $t=3$ (8 hours, 12 hours, 16 hours) lengths of exposures to sun on plant growth. I randomly applied these 3 lengths of exposures to $r=3$ pots but let us say that it is too costly or tedious to measure plant growth for all plants in the entire pot, so I randomly selected $s=4$ plants within each pot for my measurement. The variables would be: treatment (a factor of 3 different hours of exposure to sunlight at which each measurement of growth is taken), pot (a factor of three per treatment), plant (a factor of four plants per pot), growth (dependent variable). The following are the null hypotheses to be tested in order (according to our manual): (1) The mean plant growth within pots are the same. (2) There are no differences in mean plant growth among the different treatments.

The linear model for the experiment is

$$Y_{ijk}=\mu+\tau_i+\delta_{ij}+\varepsilon_{ijk}$$

where $Y_{ijk}$ is the $k$th response on the $j$th pot applied with the $i$th treatment, $\tau_i$ is the effect of the length of exposure to sunlight on plant growth, $\delta_{ij}$ is the error associated to the $j$th pot in the $i$th treatment on the growth of the plant, and $\varepsilon_{ijk}$ is the error attributed to the $k$th plant on the $j$th pot applied with treatment $i$.

In the corresponding ANOVA table, I have $SSTot=SSTrt+SSPE+SSSSE$, where SSTot is Total Sum of Squares, SSTrt is Treatment Sum of Square, SSPE is Sum of Squares for the Pots, and SSSSE is the sum of squares for the subsamples, with degrees of freedom, $t-1$, $t(r-1)$, $tr(s-1)$, respectively, where $t=$ number of treatments, $r=$ number of experimental units and $s=$ number of sampling units,

Our school manual suggests a sequential tests of hypotheses. For tests of variability of the experimental units, it says to test

$$\frac{MSPE}{MSSSE}\sim F_{(\alpha,t(r-1),tr(s-1))}$$

Then it suggests to consider the following cases for the test of differences among treatment means

• When $H_0:\sigma^2_\varepsilon=0$ is rejected

$$\frac{MSTrt}{MSPE}\sim F_{(t-1,t(r-1))}$$

• When $H_0: \sigma^2_{\varepsilon}=0$ is accepted

$$\frac{MSTrt}{MSE_{pooled}}\sim F_{(t-1,tr(s-1))}$$

where

$$MSE_{pooled}=\frac{SSPE+SSSSE}{t(rs-1)}$$.

Here, MS stands for mean squares for the corresponding sum of squares previously defined.

Question: How do I perform this sequential tests of hypotheses in R?

model <- lm(response ~ trt/pot, data)
anova(model)


I can't get it to display the correct $F$ for the treatment differences in both cases. Below is an example when $H_0:\sigma^2_\varepsilon=0$ is rejected.

I actually don't know if all of these even make sense. I did not come from a stats background and I finally decided to start learning it after a while. My school uses SAS and this procedure seems to be built-in. I know of the University Edition of SAS but I couldn't run it on my old laptop. So I am trying to find a way to get the same output in R.

Example

Here is a the data set for the following.

example <- read.csv("example.csv", header=T)
example$pot <- factor(example$pot)
example$hours <- factor(example$hours)
model <- lm(growth ~ hours/pot, example)
anova(model)


which gives the following output

## Analysis of Variance Table
##
## Response: growth
##           Df  Sum Sq Mean Sq F value    Pr(>F)
## hours      2 15.0417  7.5208 15.3255 3.569e-05 ***
## hours:pot  6  8.2083  1.3681  2.7877   0.03054 *
## Residuals 27 13.2500  0.4907
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


In this particular example where there is significant variance among experimental units, our school manual prescribes that the F value for hours should be anova(model)$"Sum Sq"[1]/anova(model)$"Sum Sq"[2]. Is there a way to compute it automatically? In this case, the $F$ for the test of treatment differences should be 5.4973.

This is based on the example given in our manual. I don't know if the manual is even correct in its prescribed procedures.

• It might be easier to understand your question if you explain what SSTot, SSTrt, SSPE, SSSSE, MSPE, MSSSE and so on means, and also if you explained a bit more about your experiment. At present, it's difficult to grasp what you're trying to do and what your question is. – JonB Oct 12 '15 at 14:01
• Edited, @JonB. I don't knw if it makes more sense now though. – hpesoj626 Oct 12 '15 at 14:39
• Slightly better, but I still can't understand it. What are the sum of squares? What is squared and summed and why? In your first formula of the linear model, you use the notations i, j, and k, but you don't explain what they are. Do you think you can describe your experiment, your variables (including the dependent/outcome variable), and your different hypotheses in plain english? – JonB Oct 12 '15 at 15:04
• If I understand you correctly, you have 3 irrigation methods that you use on 1 plot of soil each. You then have three sites per plot from which you take your measurements, and the measurement is growth. So the variables you have are: treatment (a factor of three different treatments), site (a factor of three per treatment/plot), growth (your dependent variable), and hours (the time at which each measurement of growth is taken). Is this correct? What are then your different hypotheses that you want to compare? – JonB Oct 12 '15 at 15:08
• I am sorry @JonB. I did not see that my edit at the beginning of my post did not jive with my edit at the end. Please see my latest (and hopefully last) edit. I used the exact example given in our manual. I don't know if the manual is even correct in its prescribed procedures. The variables would be: treatment (a factor of 3 different hours of exposure to sunlight at which each measurement of growth is taken), pot (a factor of three per treatment), plant (a factor of of four per pot), growth (dependent) variable. – hpesoj626 Oct 12 '15 at 15:24