predict.ctqr: Prediction After Quantile Regression

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/A2_aux_functions.R

Description

This function returns predictions for an object of class “ctqr”.

Usage

1
2
## S3 method for class 'ctqr'
predict(object, newdata, se.fit = FALSE, ...)

Arguments

object

a ctqr object.

newdata

optional data frame in which to look for variables with which to predict. It must include all the covariates that enter the quantile regression model. If omitted, the fitted values are used.

se.fit

logical. If TRUE, standard errors of the predictions are also computed.

...

for future methods.

Details

This function produces predicted values obtained by evaluating the regression function at newdata (which defaults to model.frame(object)).

Value

If se = FALSE, a matrix of fitted values, with rows corresponding to different observations, and one column for each value of object$p. If se = TRUE, a list with two items:

fit

a matrix of fitted values, as described above.

se.fit

a matrix of estimated standard errors.

Author(s)

Paolo Frumento paolo.frumento@unipi.it

See Also

ctqr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Using simulated data

n <- 1000
x1 <- runif(n)
x2 <- runif(n)
t <- 1 + x1 + x2 + runif(n, -1,1)
c <- rnorm(n,3,1)
y <- pmin(t,c)
d <- (t <= c)

model <- ctqr(Surv(y,d) ~ x1 + x2, p = c(0.25,0.5))
pred <- predict(model) # the same as fitted(model)
predict(model, newdata = data.frame(x1 = c(0.2,0.6), x2 = c(0.1,0.9)), se.fit = TRUE)

ctqr documentation built on Feb. 2, 2021, 1:06 a.m.