View source: R/LogisticRegression.R
predict.lr | R Documentation |
Predicted values of a certain type based on a lr
object.
## S3 method for class 'lr'
predict(object, newdata = NULL, thresh = 0, type = "preds", ...)
object |
an object of class " |
newdata |
an optional data frame to predict from. If omitted, predictions will be from the original data frame used to fit the model. |
thresh |
an optional threshold parameter, see 'Details'. |
type |
type of predictions, can be one of "preds", "probs" or "vals", see 'Details'. |
... |
further arguments |
Predictions from a logistic regression model are formed by first multiplying the model matrix by the parameter vector, i.e.
f(x; \beta) := X \beta.
These values are outputted when the type
argument is "vals". Predictions for the positive class can be obtained when these values
are above a certain threshold value, the argument thresh
, i.e.
f(x; \beta) \ge t,
where the threshold t
is usually equal to zero. This is how the predictions are made when the type
argument is "preds".
To get probabilities, the sigmoid
function is used on the values, i.e.
p(y=1) = 1/(1 + e^{-X \beta}).
a vector of predictions, probabilities or values, depending on the input to type
.
y = sample(0:1, 50, replace=TRUE)
d = data.frame(y = y, x = rnorm(10*y + 15))
fit = lr(y ~ x, data = d)
predict(fit, type="preds")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.