Skip to content

Commit 0ee241d

Browse files
committed
Split implementation of spatial polynomial
1 parent 3202337 commit 0ee241d

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/types.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,12 @@ spatial(ε::SpatialAutoregression) = ε.ρ
141141
spatial::SpatialMovingAverage) = ε.ρ
142142
weights::SpatialAutoregression) = ε.W
143143
weights::SpatialMovingAverage) = ε.W
144-
function poly::SpatialAutoregression)
145-
if length(spatial(ε)) == 1
146-
return I - spatial(ε) .* weights(ε)
147-
else
148-
return I - Diagonal(spatial(ε)) * weights(ε)
149-
end
150-
end
151-
function poly::SpatialMovingAverage)
152-
if length(spatial(ε)) == 1
153-
return I + spatial(ε) .* weights(ε)
154-
else
155-
return I + Diagonal(spatial(ε)) * weights(ε)
156-
end
144+
poly::SpatialAutoregression) = poly(spatial(ε), weights(ε), :ar)
145+
poly::SpatialMovingAverage) = poly(spatial(ε), weights(ε), :ma)
146+
function poly::AbstractVector, W::AbstractMatrix, type::Symbol)
147+
common = length(ρ) == 1 ? ρ .* W : Diagonal(ρ) * W
148+
149+
return type == :ar ? I - common : I + common
157150
end
158151
Base.copy::Simple) = Simple(copy(cov(Σ)))
159152
function Base.copy::SpatialAutoregression)

0 commit comments

Comments
 (0)