Last chance! 50% off unlimited learning
Sale ends in
Fit sparse variational Bayesian proportional hazards models.
svb.fit(
Y,
delta,
X,
lambda = 1,
a0 = 1,
b0 = ncol(X),
mu.init = NULL,
s.init = rep(0.05, ncol(X)),
g.init = rep(0.5, ncol(X)),
maxiter = 1000,
tol = 0.001,
alpha = 1,
center = TRUE,
verbose = TRUE
)
Failure times.
Censoring indicator, 0: censored, 1: uncensored.
Design matrix.
Penalisation parameter, default: lambda=1
.
Beta distribution parameter, default: a0=1
.
Beta distribution parameter, default: b0=ncol(X)
.
Initial value for the mean of the Gaussian component of
the variational family (
Initial value for the standard deviations of the Gaussian
component of the variational family (rep(0.05, ncol(X))
.
Initial value for the inclusion probability (rep(0.5, ncol(X))
.
Maximum number of iterations, default: 1000
.
Convergence tolerance, default: 0.001
.
The elastic-net mixing parameter used for initialising mu.init
.
When alpha=1
the lasso penalty is used and alpha=0
the ridge
penalty, values between 0 and 1 give a mixture of the two penalties, default:
1
.
Center X prior to fitting, increases numerical stability,
default: TRUE
Print additional information: default: TRUE
.
Returns a list containing:
Point estimate for the coefficients
Posterior inclusion probabilities. Used to describe the posterior probability a coefficient is non-zero.
Final value for the means of the Gaussian component of the variational
family
Final value for the standard deviation of the Gaussian component of
the variational family
Final value for the inclusion probability (
Value of lambda used.
Value of
Value of
Describes whether the algorithm converged.
Rather than compute the posterior using MCMC, we turn to approximating it
using variational inference. Within variational inference we re-cast
Bayesian inference as an optimisation problem, where we minimize the
Kullback-Leibler (KL) divergence between a family of tractable distributions
and the posterior,
# NOT RUN {
n <- 125 # number of sample
p <- 250 # number of features
s <- 5 # number of non-zero coefficients
censoring_lvl <- 0.25 # degree of censoring
# generate some test data
set.seed(1)
b <- sample(c(runif(s, -2, 2), rep(0, p-s)))
X <- matrix(rnorm(n * p), nrow=n)
Y <- log(1 - runif(n)) / -exp(X %*% b)
delta <- runif(n) > censoring_lvl # 0: censored, 1: uncensored
Y[!delta] <- Y[!delta] * runif(sum(!delta)) # rescale censored data
# fit the model
f <- survival.svb::svb.fit(Y, delta, X, mu.init=rep(0, p))
# }
# NOT RUN {
## Larger Example
n <- 250 # number of sample
p <- 1000 # number of features
s <- 10 # number of non-zero coefficients
censoring_lvl <- 0.4 # degree of censoring
# generate some test data
set.seed(1)
b <- sample(c(runif(s, -2, 2), rep(0, p-s)))
X <- matrix(rnorm(n * p), nrow=n)
Y <- log(1 - runif(n)) / -exp(X %*% b)
delta <- runif(n) > censoring_lvl # 0: censored, 1: uncensored
Y[!delta] <- Y[!delta] * runif(sum(!delta)) # rescale censored data
# fit the model
f <- survival.svb::svb.fit(Y, delta, X)
# plot the results
plot(b, xlab=expression(beta), main="Coefficient value", pch=8, ylim=c(-2,2))
points(f$beta_hat, pch=20, col=2)
legend("topleft", legend=c(expression(beta), expression(hat(beta))),
pch=c(8, 20), col=c(1, 2))
plot(f$inclusion_prob, main="Inclusion Probabilities", ylab=expression(gamma))
# }
Run the code above in your browser using DataLab