Open dwinkler1 opened 3 years ago
Thanks for the detailed report. Would you make a (draft) PR to show what you suggest to change exactly?
Sure. It'll take me a while unfortunately. Swamped at work ATM.
Sorry it took so long. My PR seems to work correctly against a naive implementation:
using LinearAlgebra, GLM, Random
Random.seed!(1)
n = 100
x = rand(n, 2)
x = hcat(x,x)
y = x * [1;2;0;0] + randn(n)
wts = 10 .*rand(n)
xi = x[:,1:2];
dwt = Diagonal(wts);
coef_naive = (xi'dwt*xi)\xi'dwt*y
coef(lm(x, y, wts = wts))
coef(lm(x, y, wts = wts))[1:2] ≈ coef_naive # true
I hit this too and came to the same diagnosis; I'll give your fix a try and see if it works in my case as well.
I am having a problem fitting an OLS model with weights and collinearity using GLM.jl. Here is a simple example
I further narrowed this down to the following function call:
using
I get
and
Here is a naive implementation that seems to work: