Description Usage Arguments Details Note Author(s) See Also Examples
Predictions from an object of class “niqr
”.
1 2 |
object |
an object of class “ |
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. |
Different type of prediction from the model.
Prediction may generate quantile crossing
if the support of the new covariates values supplied in newdata
is different from that of the observed data.
Gianluca Sottile gianluca.sottile@unipa.it
niqr
, for model fitting; test.fit.niqr
, to do goodness of fit test; summary.niqr
and plot.niqr
, for summarizing and plotting niqr
objects.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.