I have the following data set that establishes a relationship between two variables "X" and "Y":
df <- data.frame(X=c(25,25,25,25,25,25,50,50,50,50,50,50,
75,75,75,75,75,75,100,100,100,100,100,100,
125,125,125,125,125,125,150,150,150,150,150,150),
Y=c(2457524,2391693,2450828,2391252,2444638,2360293,
4693194,4844527,4835596,4878092,4809226,4722253,
7142763,7182769,7135550,7173920,7216871,7076359,
9496553,9537788,9405825,9439201,9609870,9707734,
12031958,12027037,11935594,11930086,12154132,
12096462,14298064,14396607,13964716,14221039,
14283992,14042220))
Consider the following problem:
"Adjust a weighted linear model using the" lm "function and, as a weighting factor, the inverse of the" Y "variance for each" X "level. That is, the linear model should be weighted by the inverse of the variance of each level of "X". In this case, how can we specify the weighted functional relation? Is there any specific function to be entered as an argument in " weights "?
Technical detail: It is only worth to adjust by the "lm" function. It is not worth adjusting by any other method (gls, glm, etc.).