predict.fwelnet: Make predictions from a "fwelnet" object

Description Usage Arguments Value See Also Examples

View source: R/predict.fwelnet.R

Description

This function returns the predictions from a "fwelnet" object for a new data matrix.

Usage

1
2
## S3 method for class 'fwelnet'
predict(object, xnew, type = c("link", "response"), ...)

Arguments

object

Fitted "fwelnet" object.

xnew

Matrix of new values for x at which predictions are to be made.

type

Type of prediction required. Type "link" (default) gives the linear predictors. Type "response" gives the linear predictor for "gaussian" family and fitted probabilities for "binomial" family.

...

Potentially other arguments to be passed to and from methods; currently not in use.

Value

Predictions which the model object makes at xnew.

See Also

fwelnet.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set.seed(1)
n <- 100; p <- 20
x <- matrix(rnorm(n * p), n, p)
beta <- matrix(c(rep(2, 5), rep(0, 15)), ncol = 1)
y <- x %*% beta + rnorm(n)
z <- cbind(1, abs(beta) + rnorm(p))

fit <- fwelnet(x, y, z)
predict(fit, xnew = x[1:5, ])

biny <- ifelse(y > 0, 1, 0)
fit <- fwelnet(x, biny, z, family = "binomial")
# linear predictor values
predict(fit, xnew = x[1:5, ])
# fitted probabilities
predict(fit, xnew = x[1:5, ], type = "response")

kjytay/fwelnet documentation built on June 9, 2020, 1:39 p.m.