0

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?

ChiPhi85
  • 115
  • 1
  • 5
  • 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: https://stats.stackexchange.com/questions/7513/how-to-use-weights-in-function-lm-in-r – bee guy May 23 '17 at 13:05
  • 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? – ChiPhi85 May 23 '17 at 13:19
  • 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? – EdM May 23 '17 at 14:37

0 Answers0