# Matrix \* Vector randomvar in RxInfer model

**URL:** https://discourse.julialang.org/t/matrix-vector-randomvar-in-rxinfer-model/104945
**Category:** Probabilistic Programming
**Tags:** question, distributions, rxinfer
**Created:** [October 14, 2023, 3:24am UTC](https://discourse.julialang.org/t/matrix-vector-randomvar-in-rxinfer-model/104945 "2023-10-14T03:24:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gvdr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gvdr/32/6387_2.png) [@gvdr](https://discourse.julialang.org/u/gvdr)
#### Post date: [October 14, 2023, 3:24am UTC](https://discourse.julialang.org/t/matrix-vector-randomvar-in-rxinfer-model/104945/1 "2023-10-14T03:24:58Z")

</div>

Hello. I’m trying to extend one of the examples in RxInfer but hitting a wall.

I’m working starting from the [Gaussian Linear Dynamical System](https://biaslab.github.io/RxInfer.jl/stable/examples/basic_examples/Kalman%20filtering%20and%20smoothing/#Gaussian-Linear-Dynamical-System-a-id%22gaussian-linear-dynamical-system%22/a) example.

In particular I’m trying to generalise it so that we don’t assume to know the transition matrix A a priori. In the example A is passed as an input to the model function, and then converted to a `constantvar` to be used in the model. I would like it to be given a prior in the model, and then inferred together with the remaining of the parameters.

I tried a couple of things, but I can’t make it work. A minimum reproducible example is consist in redefining model and inference as follows:

```julia
@model function rotate_ssm(n, x0, B, Q, P)
    
    # We create constvar references for better efficiency
    cB = constvar(B)
    cQ = constvar(Q)
    cP = constvar(P)
    
    # `x` is a sequence of hidden states
    x = randomvar(n)
    # THIS IS WHERE I DIVERGE FROM EXAMPLE:
    A = randomvar(2,2)
    # `y` is a sequence of "clamped" observations
    y = datavar(Vector{Float64}, n)
    
    x_prior ~ MvNormalMeanCovariance(mean(x0), cov(x0))
    x_prev = x_prior
    
    α ~ Uniform(0.0,3.0)
    β ~ Uniform(0.0,3.0)

    A .~ Gamma(α,β)
    
    for i in 1:n
        x[i] ~ MvNormalMeanCovariance(A*x_prev, cQ)
        y[i] ~ MvNormalMeanCovariance(cB * x[i], cP)
        x_prev = x[i]
    end

end

result = inference(
    model = rotate_ssm(length(y), x0, B, Q, P), 
    data = (y = y,),
    free_energy = true
)

```

When I try to run it, I get the following error:

```julia
ERROR: MethodError: no method matching make_node(::typeof(*), ::FactorNodeCreationOptions{FullFactorisation, Nothing, Nothing}, ::RandomVariable, ::Matrix{RandomVariable}, ::RandomVariable)

```
