Hi dear all, The code like this; e <- rnorm(n=50, mean=0, sd=sqrt(0.5625)) x0 <- c(rep(1,50)) x1 <- rnorm(n=50,mean=2,sd=1) x2 <- rnorm(n=50,mean=2,sd=1) x3 <- rnorm(n=50,mean=2,sd=1) x4 <- rnorm(n=50,mean=2,sd=1) y <- 1+ 2*x1+4*x2+3*x3+2*x4+e x2[1] = 10 #influential observarion y[1] = 10 #influential observarion X <- matrix(c(x0,x1,x2,x3,x4),ncol=5) Y <- matrix(y,ncol=1) Design.data <- cbind(X, Y) result <- list () for( i in 1: 3100) { data <- Design.data[sample(50,50,replace=TRUE),] dataX <- data[,1:5] dataY <- data[,6] B.cap.simulation <- solve(crossprod(dataX)) %*% crossprod(dataX, dataY) P.simulation <- dataX %*% solve(crossprod(dataX)) %*% t(dataX) Y.cap.simulation <- P.simulation %*% dataY e.simulation <- dataY - Y.cap.simulation dX.simulation <- nrow(dataX) - ncol(dataX) var.cap.simulation <- crossprod(e.simulation) / (dX.simulation) ei.simulation <- as.vector(dataY - dataX %*% B.cap.simulation) pi.simulation <- diag(P.simulation) var.cap.i.simulation <- (((dX.simulation) * var.cap.simulation)/(dX.simulation - 1)) - (ei.simulation^2/((dX.simulation - 1) * (1 - pi.simulation))) ti.simulation <- ei.simulation / sqrt(var.cap.simulation * (1 - pi.simulation)) ti.star.simulation <- ei.simulation / sqrt(var.cap.i.simulation * (1 - pi.simulation)) pi.star.simulation <- pi.simulation + ei.simulation^2 / crossprod(e.simulation) WKi.simulation <- (ti.star.simulation)*sqrt(pi.simulation/(1-pi.simulation)) result<- c(result,list(WKi.simulation)) } Finally i get the result which contains 3100 WKi.simulation. I'm trying to get a subset for those subset do not contain any Y[1,] that is point 10. Can anyone help me about how to be? Thanks for any idea... -- View this message in context: http://r.789695.n4.nabble.com/selection-of-a-subset-from-a-loop-tp3329057p3329057.html Sent from the R help mailing list archive at Nabble.com.