################################################################
## Sparse linear regression
## Generate the design matrix and regression coefficient vector
n = 100
d = 400
X = matrix(rnorm(n*d), n, d)
beta = c(3,2,0,1.5,rep(0,d-4))
## Generate response using Gaussian noise, and fit sparse linear models
noise = rnorm(n)
Y = X%*%beta + noise
out.l1.cyclic = picasso(X, Y, nlambda=10)
out.l1.greedy = picasso(X, Y, nlambda=10, alg="greedy")
out.mcp.greedy = picasso(X, Y, nlambda=10, method="mcp")
## Visualize the solution path
plot(out.l1.cyclic)
plot(out.l1.greedy)
plot(out.mcp.greedy)
################################################################
## Sparse logistic regression
## Generate the design matrix and regression coefficient vector
n = 100
d = 400
X = matrix(rnorm(n*d), n, d)
beta = c(3,2,0,1.5,rep(0,d-4))
## Generate response and fit sparse logistic models
p = exp(X%*%beta)/(1+exp(X%*%beta))
Y = rbinom(n,rep(1,n),p)
out.l1.cyclic = picasso(X, Y, nlambda=10, family="binomial")
out.l1.greedy = picasso(X, Y, nlambda=10, family="binomial", alg="greedy")
out.mcp.greedy = picasso(X, Y, nlambda=10, family="binomial", method="mcp")
## Visualize the solution path
plot(out.l1.cyclic)
plot(out.l1.greedy)
plot(out.mcp.greedy)
## Estimate of Bernoulli parameters
p.l1 = out.l1.cyclic$p
################################################################
## Sparse column inverse operator
## generating data
n = 100
d = 200
D = scio.generator(n=n,d=d,graph="band",g=1)
plot(D)
## sparse precision matrix estimation
out1 = picasso(D$data, nlambda=10, family="graph")
plot(out1)
scio.plot(out1$path[[4]])
Run the code above in your browser using DataLab