# Lasso Regression of Matrix of Vectors

**URL:** <https://discourse.julialang.org/t/lasso-regression-of-matrix-of-vectors/81470>\
**Category:** Optimization (Mathematical)\
**Created:** [May 22, 2022, 6:30pm UTC](https://discourse.julialang.org/t/lasso-regression-of-matrix-of-vectors/81470 "2022-05-22T18:30:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Scott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander_scott/32/31470_2.png) [@Alexander\_Scott](https://discourse.julialang.org/u/Alexander_Scott)\
**Post date:** [May 22, 2022, 6:30pm UTC](https://discourse.julialang.org/t/lasso-regression-of-matrix-of-vectors/81470/1 "2022-05-22T18:30:49Z")

</div>

Hi all, I’m currently using Convex.jl as one of the packages to solve an optimisation problem. I was wondering if anyone may able to offer any insight into the issue I’m facing.

Currently, I am trying to perform a Lasso regression on a Matrix of vectors for example:  
|[a,b] [c,d]|  
|[e,f] [g,h]|

I am currently following the example function of LassoEN found in the documentation of the package and it does work perfectly fine for a standard matrix of scalars.  
|a b|  
|c d|

Upon running on a matrix of vectors I obtain the following error:

Element type mismatch. Tried to create an `Adjoint{Adjoint}` from an object with eltype `Array`, but the element type of the adjoint of an object with eltype `Array` must be `Adjoint{_A, _B} where {_A, _B}`.  
Stacktrace:  
[1] error(s::String)  
@ Base .\error.jl:33  
[2] checkeltype\_adjoint(#unused#::Type{Adjoint}, #unused#::Type{Array})  
@ LinearAlgebra C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\adjtrans.jl:76  
[3] Adjoint{Adjoint, Vector{Array}}(A::Vector{Array})  
@ LinearAlgebra C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\adjtrans.jl:38  
[4] Adjoint(A::Vector{Array})  
@ LinearAlgebra C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\adjtrans.jl:95  
[5] adjoint(A::Vector{Array})  
@ LinearAlgebra C:\buildbot\worker\package\_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\adjtrans.jl:136  
[6] top-level scope  
@ REPL[102]:1

If anyone has any insight into my issue any help would be greatly appreciated, Thank you in advance for your help! Also please let me know if my problem needs a better explanation, I tried my best to show what I meant by a matrix of vectors as opposed to a matrix of scalars. I can elaborate more if needed!

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [May 22, 2022, 7:41pm UTC](https://discourse.julialang.org/t/lasso-regression-of-matrix-of-vectors/81470/2 "2022-05-22T19:41:06Z")

</div>

I’m probably responsible for the `LassoEN()` function. It is indeed designed to handle standard vectors/matrices. I suggest that you either convert your data to that format, or extend the existing function.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 22, 2022, 8:30pm UTC](https://discourse.julialang.org/t/lasso-regression-of-matrix-of-vectors/81470/3 "2022-05-22T20:30:02Z")

</div>

Hi @Alexander_Scott,

What does Lasso regression on a matrix of vectors mean in terms of math? Since this is your first post, take a read of [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757). It’s easier to help if you can provide a reproducible example.
