# Error in U[, i] : subscript out of bounds

Hi community,
I am using package BGLR and i am encountering the error as mentioned in the subject-
My scripts and error is as below

B=matrix(nrow=ncol(X),ncol=ncol(Y))
dim(X)
[1] 164 10458
dim(Y)
[1] 164 1
ncol(X)
[1] 10458
ncol(Y)
[1] 1
ETA=list(list(X=X,model='BayesB'))
for(i in 1:ncol(X)){

• fm=BGLR(y=U[,i],ETA=ETA,verbose=F) #use more iterations!
• B[,i]=fm\$ETA[[1]]\$b
• }
Error in U[, i] : subscript out of bounds

You do not show where U is defined so it is hard to say what the problem is. Does U have at least 10458 columns?

The U is from

# Singular value decompositions Y=UDV'

SVD=svd(Y)
U=SVD\$u
D=diag(SVD\$d)
V=SVD\$v
Where the dimensions of U is

dim(U)
[1] 164 1

Even if I change the iterations to 1:150 I am having the same error

ETA=list(list(X=X,model='BayesB'))
for(i in 1:ncol(X)){

• fm=BGLR(y=U[,i],ETA=ETA,verbose=F) #use more iterations!
• B[,i]=fm\$ETA[[1]]\$b
• }
Error in U[, i] : subscript out of bounds

for(i in 1:150){

• fm=BGLR(y=U[,i],ETA=ETA,verbose=F) #use more iterations!
• B[,i]=fm\$ETA[[1]]\$b
• }
Error in U[, i] : subscript out of bounds

This result

``````dim(U)
[1] 164 1
``````

shows that U has one column. When your use the subscript i in `U[, i]`, i can only have the value 1.

the U have 164 values attached. for your reference

I agree that U has 164 values but they are all in one column, You can iterate over them by changing the value of i in U[i, 1]. Notice that the i is placed before the comma.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.