predict.niqr: Prediction After Nonlinear Quantile Regression Coefficients...

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

View source: R/qrcmNL.R

Description

Predictions from an object of class “niqr”.

Usage

1
2
## S3 method for class 'niqr'
predict(object, type=c("beta", "CDF", "QF", "sim"), newdata, p, ...)

Arguments

object

an object of class “niqr”, the result of a call to niqr.

type

a character string specifying the type of prediction. See ‘Details’.

newdata

an optional data frame in which to look for variables with which to predict. If omitted, the data are used. For type = "CDF", it must include the response variable. Ignored if type = "beta".

p

a numeric vector indicating the order(s) of the quantile to predict. Only used if type = "beta" or type = "QF".

...

for future methods.

Details

Different type of prediction from the model.

Note

Prediction may generate quantile crossing if the support of the new covariates values supplied in newdata is different from that of the observed data.

Author(s)

Gianluca Sottile gianluca.sottile@unipa.it

See Also

niqr, for model fitting; test.fit.niqr, to do goodness of fit test; summary.niqr and plot.niqr, for summarizing and plotting niqr objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# using simulated data

n <- 1000
x <- runif(n)
fun <- function(theta, p){
  beta0 <- theta[1] + exp(theta[2]*p)
  beta1 <- theta[3] + theta[4]*p
  cbind(beta0, beta1)}
beta <- fun(c(1,1,1,1), runif(n))
y <- beta[, 1] + beta[, 2]*x
model <- niqr(fun=fun, x0=rep(0, 4), X=cbind(1,x), y=y)

# predict beta(0.25), beta(0.5), beta(0.75)
predict(model, type = "beta", p = c(0.25,0.5, 0.75))

# predict the CDF and the PDF at new values of x and y
predict(model, type = "CDF",
        newdata = data.frame(X1=runif(3), y = c(1,2,3)))

# computes the quantile function at new x, for p = (0.25,0.5,0.75)
predict(model, type = "QF", p = c(0.25,0.5,0.75),
        newdata = data.frame(X1=runif(3), y = c(1,2,3)))

# simulate data from the fitted model
ysim <- predict(model, type = "sim") # 'newdata' can be supplied

# if the model is correct, the distribution of y and that of ysim should be similar
qy <- quantile(y, prob = seq(.1,.9,.1))
qsim <- quantile(ysim, prob = seq(.1,.9,.1))
plot(qy, qsim); abline(0,1)

qrcmNL documentation built on Sept. 22, 2017, 9:02 a.m.