I have been having some trouble with a certain function and getting the message ''subscript out of bounds''. The problem is that in the below function, the first entry is not defined b/c it is singular and the tstat cannot be calculated (it is defined as ''NA''). R though will not put an ''NA'' in tstat[1,1] as I would like it to. Is there any way I can make this happen and therefore allow R to calculate the next entry in tstat? Yi<-c(23,54,67,34,56,78) x1<-c(1,1,1,1,1,1) x2<-c(1,0,1,1,0,0) x<-rbind(x1,x2) kn<-2 #number of rows in x tstat<-matrix(0,kn,1) for (k in 1:kn){ lm1<-lm(Yi~x[k,]) cof<-t(as.matrix(lm1$coefficients)) b5<-summary.lm(lm1) se<-t(as.matrix(b5$coefficient[,2])) se1<-se[,2] cof1<-t(as.matrix(cbind(cof[,2],se1))) cof2a<-t(cof1) b1<-as.matrix(cof2a[,1]) se11<-cof2a[,2] se11<-as.matrix(se11) tstat[k,]<-b1/se11 } --------------------------------- [[alternative HTML version deleted]]