Predict from Logistic Trend Filtering
Source:R/logistic_trend_filtering.R
predict.logistic.trend.filtering.fit.RdPredict from Logistic Trend Filtering
Usage
# S3 method for class 'logistic.trend.filtering.fit'
predict(
object,
newdata = NULL,
covariates = NULL,
offset = NULL,
type = c("response", "link"),
lambda.index = NULL,
allow.unconverged = FALSE,
...
)
# S3 method for class 'logistic.trend.filtering.fit'
fitted(object, ...)
# S3 method for class 'logistic.trend.filtering.fit'
residuals(object, ...)
# S3 method for class 'logistic.trend.filtering.fit'
print(x, ...)Arguments
- object
A
logistic.trend.filtering.fitobject.- newdata
Finite numeric predictor locations; default training locations.
- covariates
Additional predictor matrix, with the training column order.
- offset
Offset vector, required for new locations if used during fitting.
- type
"response"for probabilities or"link"for logits.- lambda.index
Path indices; defaults to the CV selection if available, otherwise all supplied penalties.
- allow.unconverged
Explicitly allow predictions from failed fits.
- ...
Reserved for compatibility with generic methods.
- x
A fitted logistic trend-filtering object.
Value
A numeric vector for one path index, otherwise a matrix. Attributes
outside.range and lambda identify boundary predictions and penalties.
Examples
x <- seq(0, 1, length.out = 24)
fit <- fit.logistic.trend.filtering(x, rep(c(0, 1), 12), lambda = Inf)
predict(fit, c(0.25, 0.75))
#> [1] 0.4699421 0.5300579
#> attr(,"outside.range")
#> [1] FALSE FALSE
#> attr(,"lambda")
#> [1] Inf
head(fitted(fit))
#> [1] 0.4401007 0.4452657 0.4504425 0.4556300 0.4608272 0.4660329
head(residuals(fit))
#> [1] -0.4401007 0.5547343 -0.4504425 0.5443700 -0.4608272 0.5339671
print(fit)
#> Order-2 logistic trend filtering (native C++; dense)
#> 24 observations; 24 distinct locations
#> lambda converged status stationarity complementarity
#> Inf TRUE converged 8.326673e-17 0