## this is a fake data set X <- floor(seq(1,10.8,0.2)) X2 <- X^2 Y <- X2 - 10*X + rnorm(length(X))*X # the "true" slope = 1, intercept = 0 # sigma is proportional to X lm1 <- lm(Y ~ X + X2) summary(lm1) plot(X,Y) lines(X,lm1$fit, col="red", lwd=2) lm2 <- lm(Y ~ X + X2, weights = 1/X2) # weight proportional to inverse variance summary(lm2) lines(X,lm2$fit, col="blue", lwd=2) plot(X, lm1$resid)