title: How to set a weighted least-squares in r for heteroscedastic data?
body: <p>I'm running a regression on census data where my dependent variable is life expectancy and I have eight independent variables. The data is aggregated be cities, so I have many thousand observations. </p>
  
  <p>My model is somewhat heteroscedastic though. I want to run a weighted least-squares where each observation is weighted by the city’s population. In this case, it would mean that I want to weight the observations by the inverse of the square root of the population. It’s unclear to me, however, what would be the best syntax. Currently, I have:</p>
  
  <pre><code>Model=lm(…,weights=(1/population))
  </code></pre>
  
  <p>Is that correct? Or should it be:</p>
  
  <pre><code>Model=lm(…,weights=(1/sqrt(population)))
  </code></pre>
  
  <p>(I found this question here: <a href="https://stackoverflow.com/questions/17408439/weighted-least-squares-r">Weighted Least Squares - R</a> but it does not clarify how R interprets the weights argument.)</p>