0

I am trying to solve the following problem in CVXR. Here y is an n by m matrix, x is n by G by m and b is m by G.

b<- Variable(m,G)
b_transpose <- t(b)

expr<-sapply(1:m, function(i) x[,,i] %*% b_transpose[,i])

obj<- sum_squares(y-expr)
prob<- Problem(Minimize(obj))

I get the following error: Error in y - expr : non-numeric argument to binary operator.

I believe I am not passing the n by m matrix expr in a way that CVXR expects. Any help will be deeply appreciated. Thanks!

TBC
  • 1

1 Answers1

0

I believe, this works.

expr<-lapply(1:m, function(i) sum_squares(y[,i]-x[,,i] %*% b_transpose[,i]))
exp<-Reduce(f = '+', x = expr)
obj<- exp
prob<- Problem(Minimize(obj))
TBC
  • 1