predict.droplasso: Make predictions from a droplasso object.

Description Usage Arguments Value See Also Examples

Description

Similar to other predict methods, this function predicts fitted values or coefficients from a fitted "droplasso" object

Usage

1
2
3
## S3 method for class 'droplasso'
predict(object, newx, s = NULL, type = c("link",
  "coefficients"), ...)

Arguments

object

Fitted "droplasso" model object

newx

Matrix of new values for x at which predictions are to be made. This argument is not used for type="coefficients".

s

Value(s) of the penalty parameter lambda at which predictions are required. Can be either omitted, or a vector of numeric values. If omitted (or equal to NULL), default is the entire sequence used to create the model.

type

Type of prediction required. Type "link" (default) gives the linear predictor. Type "coefficients" computes the coefficients at the requested values of s. If newx is not provided, then type="coefficients" automatically.

...

Other parameters.

Value

If type="link", returns a matrix of prediction scores, one row per sample of newx, one column per value of lambda. If type="coefficients", returns a matrix of weights of the model, one row per feature, one column per value of lambda.

See Also

droplasso, coef methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#create data:
nobs = 100
nvars = 5
x = matrix(rnorm(nobs*nvars),nrow=nobs)
b = c(1,1,0,0,0)
p = 1/(1+exp(-x%*%b))
y = p>0.5
# Fit a dropout lasso model
m <- droplasso(x, y, family="binomial", nlambda=50, decay=5)
# Plot is
plot(m)
# Plot the weights for lambda=0.01
plot(predict(m,s=0.01), xlab="Features", ylab="Weight", main="Lambda=0.01")
# Plot prediction score
plot(predict(m, x, s=0.01), xlab="Sample", ylab="Score", main="Lambda=0.01")

jpvert/droplasso documentation built on May 6, 2019, 7:17 a.m.