## Use the method on a simulated data set
set.seed(79)
n <- 100; p <- 50
## Simulate design matrix and response
x <- matrix(runif(n * p, min = -2.5, max = 2.5), nrow = n, ncol = p)
y <- scale(3 * (x[,1]> 0), scale=FALSE) + x[,2]^3 + rnorm(n)
## Adaptive liso
initialfit = liso.backfit(x,y, 4)
secondfit = liso.backfit(x,y, 4, covweights = liso.covweights(initialfit))
## Compare sparsity
which(dim(initialfit) != 0)
which(dim(secondfit) != 0)
set.seed(79)
y2 <- scale(3 * (x[,1]> 0), scale=FALSE) + x[,2]^3-6*(abs(x[,2] - 1)< 0.1) + rnorm(n)
## Sign finding
initialfit = liso.backfit(x,y2, 2, monotone=FALSE)
secondfit = liso.backfit(x,y2, 2, monotone=FALSE, covweights = liso.covweights(initialfit, signfind=TRUE))
## Compare monotonicity. Note near x=1
plot(secondfit, dim=2)
plot(initialfit, dim=2, add=TRUE, col=2)
Run the code above in your browser using DataLab