I have some data for 5 different batches of bacteria counts with 5 observations each -
- Batch 1: 3.890, 4.675, 7.345, 2.950, 5.675
- Batch 2: 4.345, 5.875, 3.665, 2.935, 5.455
- Batch 3: 7.145, 5.550, 6.445, 6.890, 4.985
- Batch 4: 2.675, 3.450, 4.125, 3.875, 5.125
- Batch 5: 3.350, 7.155, 6.255, 6.440, 4.960
I am trying to find the variance within each of the 5 batches, as well as the variance between the 5 batches collectively (will be using R for ease of calculations).
I'm not entirely sure how to go about doing this. Using R isn't a problem, I just don't fully understand how to actually calculate the variance parameters.
b1=c(3.890, 4.675, 7.345, 2.950, 5.675)
b2=c(4.345, 5.875, 3.665, 2.935, 5.455)
b3=c(7.145, 5.550, 6.445, 6.890, 4.985)
b4=c(2.675, 3.450, 4.125, 3.875, 5.125)
b5=c(3.350, 7.155, 6.255, 6.440, 4.960)
var_within_batches = c(var(b1),var(b2),var(b3),var(b4),var(b5))
for (k in 1:5){
print(var_within_batches[k])}
This gives a result of
[1] 2.862907
[1] 1.49075
[1] 0.8319575
[1] 0.810625
[1] 2.254908
This should be the variance within each individual batch, and then we do
mean(var_within_batches)
[1] 1.650229
and this should be the parameter estimate for variance within batches, right?
The calculation for variance between batches is also confusing me. Is it either of these? I'm a bit lost. Thanks for any help!
between_batch_var_guess1 = var(var_within_batches)
[1] 0.8090405
between_batch_var_guess2 = sum(var_within_batches)/5
[1] 1.65023