0
$\begingroup$

I'm trying to perform Weighted Linear Regression in R but I'm not sure how to assign the weights. I know from historical data that the standard deviation for the dependent variable is proportional to its (i.e. a constant %CV)

How do I use this information to create the weights for lm() in R?

$\endgroup$
  • $\begingroup$ I am not sure I understand the question. The lm function has a weights argument. So you specify your weights argument within the function call, e.g. model1 = lm(y ~ x, weights = 1/std_dev, data = yourdata). see also: stats.stackexchange.com/questions/7513/… $\endgroup$ – bee guy May 23 '17 at 13:05
  • $\begingroup$ The standard deviations have been calculated from historical datasets but it generally holds that it is proportional across the measurement range. Because the SD has been calculated from other data, I was wondering how to translate this to a new dataset. Should I perhaps 'predict' what the SD should be at each value of the new dataset? $\endgroup$ – ChiPhi85 May 23 '17 at 13:19
  • $\begingroup$ With a constant %CV, working with a log transformation of the dependent variable might help. Then in the log-transformed scale, errors are independent of values. Have you considered that? Or is there some reason why that's not possible? $\endgroup$ – EdM May 23 '17 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.