library(lqs) g <- ltsreg(involact ~ race+fire+theft+age+log(income),chicago) help(ltsreg) g g <- ltsreg(involact ~ race+fire+theft+age+log(income),chicago,nsamp="best") g g <- ltsreg(involact ~ race+fire+theft+age+log(income),chicago,nsamp="best") g <- ltsreg(involact ~ race+fire+theft+age+log(income),chicago,nsamp="best") g g <- ltsreg(involact ~ race+fire+theft+age+log(income),chicago,nsamp="exact") g$res sample(c("A","B","C"),10,rep=T) sample(c("A","B","C"),10,rep=T) sample(c("A","B","C"),10,rep=T) x <- model.matrix(g)[,-1] x <- model.matrix(~race+fire+theft+age+log(income),chicago) x <- x[,-1] newy <- g$fit+g$res[sample(47,rep=T)] newy <- g$fit+sample(g$res,47,rep=T) nbeta <- ltsreg(x,newy,nsamp="best") nbeta bcoef <- matrix(0,100,6) for(i in 1:100){ newy <- g$fit+sample(g$res,47,rep=T) nbeta <- ltsreg(x,newy,nsamp="best") bcoef[i,] <- nbeta$coef } bcoef <- matrix(0,1000,6) for(i in 1:1000){ newy <- g$fit+sample(g$res,47,rep=T) nbeta <- ltsreg(x,newy,nsamp="best") bcoef[i,] <- nbeta$coef} bcoef hist(bcoef[,2]) plot(density(bcoef[,2])) abline(v=0) length(bcoef[bcoef[,2]<0,2]) quantile(bcoef[,2],c(0.025,0.975))