# Technical variation versus real signal

I'm testing for difference in a continuous outcome under three different conditions.

Under condition A I take a measurement of the outcome. I do this twice for the same sample. Example values could be 2.2, 2.1. These are "technical" replicates that come from the same biological source

I do the same for four "biological" replicates for condition A:

A1, measure 1: 2.2
A1, measure 2: 2.1
A2, measure 1: 2.0
A2, measure 2: 2.1
A3, measure 1: 1.9
A3, measure 2: 1.8
A4, measure 1: 1.5
A4, measure 2: 1.6


I also have conditions B, C, and D, with two "technical" replicates in each of four "biological" replicates.

How would I test test for mean differences (ANOVA) that best accounts for both the technical and biological variation? I wouldn't want to fit a model counting each measurement as a separate observation, because each pair comes from the same biological sample. I'm assuming there must be a better way than just averaging over the pairs.

Bonus: how do you do this in R?

Assuming I have data that looks like this:

> data
condition sample measurement outcome
1          A      1           1     2.2
2          A      1           2     2.1
3          A      2           1     2.0
4          A      2           2     2.1
5          A      3           1     1.9
6          A      3           2     1.8
7          A      4           1     1.5
8          A      4           2     1.6
9          B      1           1     1.7
10         B      1           2     1.6
11         B      2           1     1.5
12         B      2           2     1.6
13         B      3           1     1.4
14         B      3           2     1.3
15         B      4           1     1.0
16         B      4           2     1.1
17         C      1           1     2.4
18         C      1           2     2.3
19         C      2           1     2.2
20         C      2           2     2.3
21         C      3           1     2.1
22         C      3           2     2.0
23         C      4           1     1.7
24         C      4           2     1.8


I probably wouldn't want to do something like this:

summary(lm(outcome~condition, data=data))


model <- aov(outcome ~ condition + Error(samp + measurement), data=mydata)