Skip to content

Commit 74b32f6

Browse files
avoid X'y issue (#255)
* Update fit.jl * Update predict.jl * Update Project.toml * Update fit.jl * Update fit.jl
1 parent 8f11f6e commit 74b32f6

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FixedEffectModels"
22
uuid = "9d5cd8c9-2029-5cab-9928-427838db53e3"
3-
version = "1.10.0"
3+
version = "1.10.1"
44

55
[deps]
66
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

src/fit.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ function StatsAPI.fit(::Type{FixedEffectModel},
424424
## Do the regression
425425
##
426426
##############################################################################
427-
Xy = Symmetric(hvcat(2, XhatXhat, Xhat'y,
427+
# use X'Y instead of X'y because of https://github.com/FixedEffects/FixedEffectModels.jl/issues/249
428+
Xy = Symmetric(hvcat(2, XhatXhat, Xhat'reshape(y, length(y), 1),
428429
zeros(size(Xhat, 2))', [0.0]))
429430
invsym!(Xy; diagonal = 1:size(Xhat, 2))
430431
invXhatXhat = Symmetric(.- Xy[1:(end-1),1:(end-1)])

test/predict.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666
pred = predict(m, df)
6767
@test pred isa Vector{Union{Missing, Float64}}
6868
@test ismissing(pred[1])
69-
@test pred[2:end] df.y[2:end]
69+
@test norm(pred[2:end] .- df.y[2:end]) < 1e-6
7070

7171
# Two groups + missing observation of non-FE
7272
df = DataFrame(x = [missing; rand(99)], g = rand(["a", "b"], 100))

0 commit comments

Comments
 (0)