# ParetoSmooth.jl psis\_loo crashes with ERROR: The number of lines in \`row\_names\` must match the number of lines in the matrix

**URL:** <https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489>\
**Category:** Probabilistic Programming\
**Tags:** question\
**Created:** [November 19, 2022, 8:10am UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489 "2022-11-19T08:10:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SebastianCallh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastiancallh/32/16102_2.png) [@SebastianCallh](https://discourse.julialang.org/u/SebastianCallh)\
**Post date:** [November 19, 2022, 8:10am UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489/1 "2022-11-19T08:10:00Z")

</div>

Hi!

I found an example use of ParetoSmooth.jl `psis_loo` [here](https://discourse.julialang.org/t/how-to-use-paretosmooth-jl/79493/2), but when I try to run the example it crashes with

```julia
[ Info: No source provided for samples; variables are assumed to be from a Markov Chain. If the samples are independent, specify this with keyword argument `source=:other`.
┌ Warning: Some Pareto k values are extremely high (>1). PSIS will not produce consistent estimates.
└ @ ParetoSmooth ~/.julia/packages/ParetoSmooth/A6x5U/src/InternalHelpers.jl:43
Results of PSIS-LOO-CV with 1000 Monte Carlo samples and 1 data points. Total Monte Carlo SE of 0.29.
Error showing value of type PsisLoo{Float64, Array{Float64, 3}, Vector{Float64}}:
ERROR: The number of lines in `row_names` must match the number of lines in the matrix.

```

Has something changed? I am running ParetoSmooth v0.7.1 and Turing 0.22.0.  
I also tried the new/other(?) Turing syntax where I wrote to model to condition on the observations `psis_loo(test(Xₜ, 1) | (;Yₜ), ch)` but it gave the same error. @ParadaCarleton

> **full stack trace**
>
> ERROR: The number of lines in `row_names` must match the number of lines in the matrix.  
> Stacktrace:  
> [1] error(s::String)  
> @ Base ./error.jl:35  
> [2] \_print\_info(data::PrettyTables.ColumnTable; alignment::Symbol, cell\_alignment::Nothing, cell\_first\_line\_only::Bool, compact\_printing::Bool, filters\_row::Nothing, filters\_col::Nothing, formatters::PrettyTables.var"#52#54"{Vector{String}}, header::Tuple{Vector{Symbol}}, header\_alignment::Symbol, header\_cell\_alignment::Nothing, limit\_printing::Bool, renderer::Symbol, row\_names::Vector{Symbol}, row\_name\_alignment::Symbol, row\_name\_column\_title::String, row\_number\_column\_title::String, show\_row\_number::Bool, title::String, title\_alignment::Symbol)  
> @ PrettyTables ~/.julia/packages/PrettyTables/nQZHQ/src/private.jl:220  
> [3] #\_pt#81  
> @ ~/.julia/packages/PrettyTables/nQZHQ/src/private.jl:458 [inlined]  
> [4] #\_pretty\_table#80  
> @ ~/.julia/packages/PrettyTables/nQZHQ/src/private.jl:378 [inlined]  
> [5] #pretty\_table#68  
> @ ~/.julia/packages/PrettyTables/nQZHQ/src/print.jl:706 [inlined]  
> [6] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol(“text/plain”)}, loo\_object::PsisLoo{Float64, Array{Float64, 3}, Vector{Float64}})  
> @ ParetoSmooth ~/.julia/packages/ParetoSmooth/A6x5U/src/LeaveOneOut.jl:57  
> [7] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol(“text/plain”)}, Base.RefValue{Any}})(io::Any)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:267  
> [8] with\_repl\_linfo(f::Any, repl::REPL.LineEditREPL)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521  
> [9] display(d::REPL.REPLDisplay, mime::MIME{Symbol(“text/plain”)}, x::Any)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:260  
> [10] display(d::REPL.REPLDisplay, x::Any)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:272  
> [11] display(x::Any)  
> @ Base.Multimedia ./multimedia.jl:328  
> [12] #invokelatest#2  
> @ ./essentials.jl:729 [inlined]  
> [13] invokelatest  
> @ ./essentials.jl:726 [inlined]  
> [14] print\_response(errio::IO, response::Any, show\_value::Bool, have\_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:296  
> [15] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:278  
> [16] with\_repl\_linfo(f::Any, repl::REPL.LineEditREPL)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521  
> [17] print\_response(repl::REPL.AbstractREPL, response::Any, show\_value::Bool, have\_color::Bool)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:276  
> [18] (::REPL.var"#do\_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:857  
> [19] #invokelatest#2  
> @ ./essentials.jl:729 [inlined]  
> [20] invokelatest  
> @ ./essentials.jl:726 [inlined]  
> [21] run\_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)  
> @ REPL.LineEdit ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2510  
> [22] run\_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)  
> @ REPL ~/software/julia/1.8.2/share/julia/stdlib/v1.8/REPL/src/REPL.jl:1248  
> [23] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()  
> @ REPL ./task.jl:484

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [November 21, 2022, 7:42pm UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489/2 "2022-11-21T19:42:42Z")

</div>

This error usually crops up when you describe your entire dataset as being drawn from a single multivariate normal. However, the multivariate normal is supposed to represent a single observation of multiple variables (e.g. you might model height and weight as jointly multivariate normal), rather than multiple observations of a single variable (e.g. modeling the heights of many participants as independent draws from a Normal distribution).

---

<div class="post-metadata">

**Author:** ![SebastianCallh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastiancallh/32/16102_2.png) [@SebastianCallh](https://discourse.julialang.org/u/SebastianCallh)\
**Post date:** [November 22, 2022, 7:02am UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489/3 "2022-11-22T07:02:59Z")

</div>

Thank you for explaining! That would not have been easy for me to debug.

I absolutely understand the distinction between an N dim MvNormal and N Normal distributions, the reason I use it in Turing for the observations is that the alternative, loops, are slow. Are you saying that ParetoSmooth.jl will only work if one loops over the observed variable?

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [November 24, 2022, 12:54am UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489/4 "2022-11-24T00:54:19Z")

</div>

You can either loop or broadcast, but basically yes. Unfortunately, ParetoSmooth.jl uses Turing itself to figure out what counts as an observation. Future versions should fix this, though! This was quite difficult with the older interface, but I think now that Turing’s switching over to using `SimpleVarInfo` for everything it should be a lot easier.

Thanks for letting me know the error message is unclear! I’ll edit it when I have time.

---

<div class="post-metadata">

**Author:** ![SebastianCallh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastiancallh/32/16102_2.png) [@SebastianCallh](https://discourse.julialang.org/u/SebastianCallh)\
**Post date:** [November 24, 2022, 7:23am UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489/5 "2022-11-24T07:23:18Z")

</div>

That makes sense. Thank you for your work on Bayesian inference tools in Julia 🙂  
I know this is off topic but will the `SimpleVarInfo` refactoring have any implications for end users of Turing? I see it mentioned here and there in discussions and issues and it sounds like a big deal.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [November 24, 2022, 6:34pm UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489/6 "2022-11-24T18:34:53Z")

</div>

It’s a very big deal internally, but not so much for users, except insofar as it means “Turing will be faster and development for it will be easier.”
