
@testset "Weighted" begin
    @testset "Known V, Unknown W" begin
        Y = [[0.597, 1.299, 3.27, -1.27, 7.59, -6.89],
             [-1.0, -4.67, 1.88, -1.39, 5.09, 2.4],
             [-5.63, -11.4, -8.56, -4.54, 22.5, 15.2],
             [-19.1, -13.6, -12.0, -17.7, 21.0, 28.5],
             [-25.5, -17.8, -21.8, -20.1, 44.4, 42.6],
             [-34.1, -23.5, -25.6, -22.8, 58.4, 53.8]]
        Y = to_matrix(Y)
        η = [0.45, 0.45, 0.1]

        F = [1. 0. 0.; 0. 1. 0.]
        G = [1. 0. 1.; 0. 1. 1.; 0. 0. 1.]
        V = Symmetric(diagm([12., 12.]))

        # Filter

        a, R, m, C = kfilter(Y, F, G, V, η, 0.8)

        @test a[end,:] ≈ [-18.794803420834505, -18.62873963779488, -4.093136957816489]
        @test R[end][3,3] ≈ 1.0514508656899235
        @test C[end][3,3] ≈ 0.5565127730469597

        # Smoother

        s, S = ksmoother(G, a, R, m, C)

        @test s[1,:] ≈ [1.6363856970098998, 0.6806573714011395, -2.4041282160885644]
        @test diag(S[1]) ≈ [5.401963801663216, 5.401963801663269, 6.64771001788035]

        # Fitted

        f, Q = fitted(F, V, s, S)

        @test f[1,:] ≈ [1.6363856970098998, 0.6806573714011395]
        @test diag(Q[end]) ≈ [17.27516049014339, 17.27516049014339]

        # Forecast

        fh, Qh = forecast(F, G, V, 0.8, m[end,:], C[end], 10)

        @test fh[end,:] ≈ [-59.3151969404975, -57.705730042143614]
        @test diag(Qh[end]) ≈ [479.334143445396, 479.334143445396]
    end


    @testset "Unknown W, Unknown V" begin
        Y = [[0.597, 1.299, 3.27, -1.27, 7.59, -6.89],
             [-1.0, -4.67, 1.88, -1.39, 5.09, 2.4],
             [-5.63, -11.4, -8.56, -4.54, 22.5, 15.2],
             [-19.1, -13.6, -12.0, -17.7, 21.0, 28.5],
             [-25.5, -17.8, -21.8, -20.1, 44.4, 42.6],
             [-34.1, -23.5, -25.6, -22.8, 58.4, 53.8]]
        Y = to_matrix(Y)
        η = [0.7, 0.2, 0.1]

        F = [1. 0. 0.; 0. 1. 0.]
        G = [1. 0. 1.; 0. 1. 1.; 0. 0. 1.]

        # Estimate
        θ, Σ, _ = estimate(Y, F, G, η, 0.8)

        @test θ[end,:] ≈ [-19.05578625907453, -16.79719558628691, -3.266323626397268]
        @test Σ ≈ [245.88141984197944 0; 0 186.51152750423392]

        # Estimate with exclusion
        θ, Σ, _ = estimate(Y, F, G, η, 0.8, exclude_under=0.15)

        @test θ[end,:] ≈ [-27.303258240406077, -23.792801359688326, -4.886906081116004]
        @test Σ ≈ [18.275634284242617 0; 0 2.814105974385866]

        # Evolutional Covariances
        Σₑ = evolutional_covariances(Y, F, G, Σ, η, 0.8)

        @test Σₑ[end][3,3] ≈ 0.05964878602083959

        # Fitted
        f, Q = fitted(F, Σ, θ, Σₑ)

        @test f[end,:] ≈ [-27.303258240406077, -23.792801359688326]
        @test Q[end][1,2] ≈ 0.508856381882239

        # Forecast
        fh, Qh = forecast(F, G, Σ, 0.8, θ[end,:], Σₑ[end], 10)

        @test fh[end,:] ≈ [-76.17231905156612, -72.66186217084837]
        @test Qh[end][1,2] ≈ 57.17048592729376
    end
end
