# Problem fitting a State-space model with matrices in RxInfer.jl

**URL:** <https://discourse.julialang.org/t/problem-fitting-a-state-space-model-with-matrices-in-rxinfer-jl/104400>\
**Category:** Specific Domains\
**Tags:** question, rxinfer\
**Created:** [September 29, 2023, 2:17pm UTC](https://discourse.julialang.org/t/problem-fitting-a-state-space-model-with-matrices-in-rxinfer-jl/104400 "2023-09-29T14:17:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grafaelw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grafaelw/32/50505_2.png) [@grafaelw](https://discourse.julialang.org/u/grafaelw)\
**Post date:** [September 29, 2023, 2:17pm UTC](https://discourse.julialang.org/t/problem-fitting-a-state-space-model-with-matrices-in-rxinfer-jl/104400/1 "2023-09-29T14:17:49Z")

</div>

Hi everyone,

I am trying to recreate a paper from J. Luttinen as follows [https://users.ics.aalto.fi/jluttine/ecml2013/](https://users.ics.aalto.fi/jluttine/ecml2013/) . However, I am having some difficulties to infer A and C matrices due to following reason:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/e/bee92cc500f4acc53aeaddc3155dd592432e0c0d.png)

It comes from a model that is specified as such:

@model function lssm(N, D, M)

```
x = randomvar(N)
y = datavar(Vector{Float64}, N)

x_prior ~ MvNormalMeanCovariance(zeros(D), 0.01*diageye(D))
x_prev = x_prior

α ~ InverseWishart(D^2, 1.0e-5*diageye(D))
γ ~ InverseWishart(M*D, 1.0e-5*diageye(M))
τ ~ InverseWishart(M^2, 1.0e-5*diageye(M))

A ~ MatrixNormal(zeros(D, D), α, diageye(D))
C ~ MatrixNormal(zeros(M, D), γ, diageye(D))

for i in 1:N
    x[i] ~ MvNormalMeanCovariance(A * x_prev, diageye(D))
    y[i] ~ MvNormalMeanCovariance(C * x[i], τ) 
    x_prev = x[i]
end

```

end

Is there any possible alternative that I could try? Thank you.
