# NOT RUN {
######### Generate matrices in the training data ################
X = list()
for(i in 1:10){
X[[i]] = matrix(runif(4,-1,1),nrow = 2,ncol = 2)
}
######### Generate coefficient matrix ###########################
B = runif(2,-1,1)%*%t(runif(2,-1,1))
######### Generate response variables ###########################
y = NULL;signal = NULL
for(i in 1:10){
signal = c(signal,sum(X[[i]]*B))
y = c(y,sum(X[[i]]*B)+rnorm(1,sd = 0.1))
}
######### Run ASSIST ############################################
res =TraceAssist(X,y,r = 1,sparse_r = 0,sparse_c = 0,min = min(y),max = max(y))
mean(abs(res$fitted-signal))
######### Generate new matrices in the test data ################
X_new = list()
for(i in 1:10){
X_new[[i]] = matrix(runif(4,-1,1),nrow = 2,ncol = 2)
}
######### Generate response variables from X_new ################
y_new = NULL
for(i in 1:10){
y_new = c(y_new,sum(X_new[[i]]*B))
}
######### Run ASSIST #############################################
res =TraceAssist(X,y,X_new,r = 1,sparse_r = 0,sparse_c = 0,min = min(y),max = max(y))
mean(abs(res$fitted-y_new))
# }
Run the code above in your browser using DataLab