three.RV.2<-function(X,Y,kappa){
if(length(kappa)==1){
kappa[2]=kappa[1]
}
###########################################################
cm=calc_med(X,Y)
###########################################################
n=dim(cm$mu)[2] # number of dimentions/attributes of X
## linear coeficient
bb=-cbind(c(-1,numeric(n+1)))
## Linear constraint
Dt=rbind(diag(x=1,nrow=n+1,ncol=n+2),cbind(0, -diag(x=1,nrow=n,ncol=n+1)))
f=cbind(c(0,rep(x=1,2*n)))
## %% Building the 2nd and 3rd constraint
## Building the 2nd and 3rd constraint
At2=matrix(0, nrow=cm$npos+1, ncol=n+2)
At2[1,]=c(-1,cm$mu[1,],1)
At2[2:(cm$npos+1),2:(n+1)]=kappa[1]*t(cm$mchol1)
At3=matrix(0, nrow=cm$nneg+1, ncol=n+2)
At3[1,]=c(-1, -cm$mu[2,] , -1)
At3[2:(cm$nneg+1),2:(n+1)]=kappa[2]*t(cm$mchol2)
c2=cbind(numeric(cm$npos+1))
c3=cbind(numeric(cm$nneg+1))
## Solve the SOC-problem with SCS
At=-rbind(Dt,At2,At3) #
ct=rbind(f,c2,c3) ## f,c1,c2
K.q=c(cm$npos+1,cm$nneg+1) #dimension of cone
cone=list( q = K.q , l=(2*n+1))
scs=scs(At,ct,-bb,cone)
w=cbind(scs$x[2:(n+1)])
b=scs$x[(n+2)]
return(list(w=w,b=b))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.