<p>I am not sure this will answer your question, but let's me try with a concrete example using Stata and its 1978 Automobile Data in order to regress car's price on mileage (mpg).</p>

<pre><code>sysuse auto, clear    
reg price mpg, robust
</code></pre>

<p>This gives a price estimate of -238.9, with a standard error (s.e) of 57.5. Then, if I run the same regression after duplicating the observations three times.</p>

<pre><code>expand 3
reg price mpg, robust
</code></pre>

<p>I get as expected a much lower s.e. of 32.9. Finally, clustering the s.e. by make (a Car Id) </p>

<pre><code>reg price mpg, cluster(make)
</code></pre>

<p>gives a s.e. of 57.2 and makes the trick. </p>

<p>However, if you expand twice some observations and thrice others (as in your example). Then, you will get a larger s.e but also a different estimate. But, again, clustering by make reduces the s.e. Here is the code:</p>

<pre><code>sysuse auto, clear
expand 3 if price&gt;4000 &amp; price&lt;=6000
expand 2 if price&gt;6000
reg price mpg, robust
reg price mpg, cluster(make)
</code></pre>

<p>Note that the price and mpg variables have been expanded <strong>without any change</strong> for each car. In your example, if the ones who have taken their temperature multiple times have each time a different temperature, then you may consider introduction an <strong>individual fixed effect</strong>.</p>

CC BY-SA 3.0
2017-10-13T09:32:41.893Z
This is an interesting exercise. However, your expanded sample **is not random** since you have expanded the sample based on an `if` condition. If the individuals with multiple temperatures are a random sample of the population, your example is not equivalent. I suggest you try a random expansion, e.g. by creating a variable with a random draw from a uniform between 1 and 3 and then using that variable as `fweight`. I am looking forward to the see results of that!
luchonacho
CC BY-SA 3.0
2017-09-01T21:59:17.867Z
2017-09-01T21:59:17.867Z
emeryville
<p>I think you are overcomplicating the issue. There is no good reason to believe that the measurement of temperature for the same individual in different times are to be <strong>dependent</strong>. If the thermometer (or the instrument used to measure temperature) is of good quality, then observations, both over time and across the sample are independent. 
Therefore, you can treat multiple observations of the same individual as if they were from other individuals. There is no need to cluster. In other words, your sample is $iid$, under which OLS estimates are unbiased and consistent.</p>

<p>If you still believe there is dependence of measurement over time (but you need to argue why), you can indeed use clustering. Comparing the two models would give you an idea of whether the clustering is in fact needed.</p>

CC BY-SA 3.0
2017-10-02T09:41:59.890Z
2017-10-02T09:41:59.890Z
luchonacho
<p>If you want to stick to OLS, your suggestion (clustering) seems fine. If you want to pursue efficiency, you may want to use the random effects FGLS (<code>xtreg bodytemperature, i(person)</code>) estimation.</p>

<p>If you believe that all body temperatures are identical on average, it is alright to use any of them. But if they are heterogenous (due to genes or whatever), none is satisfactory. I would rather think more about what "average body temperature" means.</p>

<p>Let us take an example. When your population is three people (101, 102, and 103) and your sample is</p>

<pre><code>i      person         x      /* x = measured temp */
1       101         36.5
2       102         36.8
3       102         37.8
4       103         37.5
</code></pre>

<p>(note that person 102 is measured twice), I guess what you want is $A=(1/3) \times [E(temp_{101}) + E(temp_{102}) + E(temp_{103}) ]$. OLS (the unweighted average), however, equals $(1/4) \times (x_1 + x_2 + x_3 + x_4)$, which is an unbiased estimator of $B=(1/4) \times [ E(temp_{101}) + E(temp_{102}) + E(temp_{102}) + E(temp_{103}) ]$. If $A = B$, that's fine, but $A$ and $B$ can be different.</p>

<p>When you want $A$, what you want to calculate is $A_{be} = (1/3) \times [x_1 + (x_2 + x_3)/2 + x_4]$, while OLS puts too much weight on person 102. $A_{be}$ is called the panel "between group (BE) estimator". You can get it by <code>xtreg bodytemperature, be i(person)</code>.</p>

<p>For the above data set, the BE estimate (of $A$) is 37.1, while the OLS estimate (of $B$) is 37.15. Try the following in Stata (copy &amp; paste).</p>

<pre><code>* Copy &amp; paste into Stata
clear all
input person temp
101 36.5
102 36.8
102 37.8
103 37.5
end
gen temp37 = temp-37
reg temp37, vce(cluster person)
xtreg temp37, be i(person)
</code></pre>

<p>(I deliberately subtracted 37 in order to test your null hypothesis.)</p>

CC BY-SA 3.0
2017-09-02T01:50:12.613Z
2017-09-02T02:00:55.583Z
2017-09-02T02:00:55.583Z
chan1142
<p>(My research question is economics based, but for simplicity, I'm using a non-economics example)</p>

<p>Suppose I'm trying to find out whether average body temperature of a population is equal to 37 degrees Celsius. I take a random sample of people and take their body temperature. </p>

<p>The problem is, some people have taken their body temperature once, but others have taken their temperature multiple times (twice, thrice, or even ten times).</p>

<p>Ordinarily I would regress body temperature on a constant, and do hypothesis testing with $H_0: \beta_0 = 37$. However, I am worried about serial correlation. </p>

<p>Would clustering the standard errors by person be sufficient to correct for this serial correlation? (e.g. using <code>reg bodytemperature, cluster(person)</code> in Stata)</p>

CC BY-SA 3.0
2017-09-01T19:26:44.447Z
Clustering does not in general take care of serial correlation. Furthermore, the way you are suggesting to cluster would imply N clusters with one observation each, which is generally not a good idea. Also, why are you worried about serial correlation in this case? I don't see how the serial correlation in your sample is affected by whether people in the past have ever measured they're temperature and you don't have a panel from what I understand. For questions about clustering, I can highly recommend Cameron and Miller's paper "A Practitioner’s Guide to Cluster-Robust Inference".
BB King
CC BY-SA 3.0
2017-09-01T20:16:04.803Z
Oops, sorry, I didn't explain clearly. What I meant was that some people have taken their temperature multiple times, and this is recorded in their dataset. For example, if I have my temperature taken five times, then it will be recorded in the dataset as five observations, but with my name next to it.
wwl
<econometrics><statistics>
Clustered standard errors
wwl
# Clustered standard errors

(Asked by: username_0 on 2017-09-01)

(My research question is economics based, but for simplicity, I'm using a non-economics example)

Suppose I'm trying to find out whether average body temperature of a population is equal to 37 degrees Celsius. I take a random sample of people and take their body temperature.

The problem is, some people have taken their body temperature once, but others have taken their temperature multiple times (twice, thrice, or even ten times).

Ordinarily I would regress body temperature on a constant, and do hypothesis testing with $H\_0: \beta\_0 = 37$. However, I am worried about serial correlation.

Would clustering the standard errors by person be sufficient to correct for this serial correlation? (e.g. using `reg bodytemperature, cluster(person)` in Stata)

**Tags:** econometrics, statistics

> **Comments:**
> **username_1**: Clustering does not in general take care of serial correlation. Furthermore, the way you are suggesting to cluster would imply N clusters with one observation each, which is generally not a good idea. Also, why are you worried about serial correlation in this case? I don't see how the serial correlation in your sample is affected by whether people in the past have ever measured they're temperature and you don't have a panel from what I understand. For questions about clustering, I can highly recommend Cameron and Miller's paper "A Practitioner’s Guide to Cluster-Robust Inference".  
> **username_0**: Oops, sorry, I didn't explain clearly. What I meant was that some people have taken their temperature multiple times, and this is recorded in their dataset. For example, if I have my temperature taken five times, then it will be recorded in the dataset as five observations, but with my name next to it.  

---

## 3 answers

### Answer by username_2 on 2017-09-01. Score: 1

I am not sure this will answer your question, but let's me try with a concrete example using Stata and its 1978 Automobile Data in order to regress car's price on mileage (mpg).
sysuse auto, clear    
reg price mpg, robust

This gives a price estimate of -238.9, with a standard error (s.e) of 57.5. Then, if I run the same regression after duplicating the observations three times.
expand 3
reg price mpg, robust

I get as expected a much lower s.e. of 32.9. Finally, clustering the s.e. by make (a Car Id) 
reg price mpg, cluster(make)

gives a s.e. of 57.2 and makes the trick. 
However, if you expand twice some observations and thrice others (as in your example). Then, you will get a larger s.e but also a different estimate. But, again, clustering by make reduces the s.e. Here is the code:
sysuse auto, clear
expand 3 if price>4000 & price<=6000
expand 2 if price>6000
reg price mpg, robust
reg price mpg, cluster(make)

Note that the price and mpg variables have been expanded without any change for each car. In your example, if the ones who have taken their temperature multiple times have each time a different temperature, then you may consider introduction an individual fixed effect.

> **Comments:**
> **username_3**: This is an interesting exercise. However, your expanded sample **is not random** since you have expanded the sample based on an `if` condition. If the individuals with multiple temperatures are a random sample of the population, your example is not equivalent. I suggest you try a random expansion, e.g. by creating a variable with a random draw from a uniform between 1 and 3 and then using that variable as `fweight`. I am looking forward to the see results of that!  

---

### Answer by username_3 on 2017-10-02. Score: 0

I think you are overcomplicating the issue. There is no good reason to believe that the measurement of temperature for the same individual in different times are to be **dependent**. If the thermometer (or the instrument used to measure temperature) is of good quality, then observations, both over time and across the sample are independent.
Therefore, you can treat multiple observations of the same individual as if they were from other individuals. There is no need to cluster. In other words, your sample is $iid$, under which OLS estimates are unbiased and consistent.

If you still believe there is dependence of measurement over time (but you need to argue why), you can indeed use clustering. Comparing the two models would give you an idea of whether the clustering is in fact needed.


---

### Answer by username_4 on 2017-09-02. Score: 0

If you want to stick to OLS, your suggestion (clustering) seems fine. If you want to pursue efficiency, you may want to use the random effects FGLS (xtreg bodytemperature, i(person)) estimation.
If you believe that all body temperatures are identical on average, it is alright to use any of them. But if they are heterogenous (due to genes or whatever), none is satisfactory. I would rather think more about what "average body temperature" means.
Let us take an example. When your population is three people (101, 102, and 103) and your sample is
i      person         x      /* x = measured temp */
1       101         36.5
2       102         36.8
3       102         37.8
4       103         37.5

(note that person 102 is measured twice), I guess what you want is $A=(1/3) \times [E(temp_{101}) + E(temp_{102}) + E(temp_{103}) ]$. OLS (the unweighted average), however, equals $(1/4) \times (x_1 + x_2 + x_3 + x_4)$, which is an unbiased estimator of $B=(1/4) \times [ E(temp_{101}) + E(temp_{102}) + E(temp_{102}) + E(temp_{103}) ]$. If $A = B$, that's fine, but $A$ and $B$ can be different.
When you want $A$, what you want to calculate is $A_{be} = (1/3) \times [x_1 + (x_2 + x_3)/2 + x_4]$, while OLS puts too much weight on person 102. $A_{be}$ is called the panel "between group (BE) estimator". You can get it by xtreg bodytemperature, be i(person).
For the above data set, the BE estimate (of $A$) is 37.1, while the OLS estimate (of $B$) is 37.15. Try the following in Stata (copy & paste).
* Copy & paste into Stata
clear all
input person temp
101 36.5
102 36.8
102 37.8
103 37.5
end
gen temp37 = temp-37
reg temp37, vce(cluster person)
xtreg temp37, be i(person)

(I deliberately subtracted 37 in order to test your null hypothesis.)


---

