Description Usage Arguments Details Value Author(s) See Also Examples
predict the latent link value for interval regression models, either unconditional or conditional of being in the observed interval. Compute the expected values of residuals.
1 2 3 4 |
object |
“intReg” object, estimated interval regression model |
newdata |
a list or frame for new data. If |
type |
character, what to predict:
|
... |
currently ignored |
residuals reports generalized residuals, the expected difference between the predicted and actual link E[predicted y* - y*|l <= y* < u, x].
a numeric vector, the predicted values/residuals.
Ott Toomet
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 31 32 33 34 35 36 37 38 39 40 | data(Kakadu, package="Ecdat")
set.seed(1)
Kakadu <- Kakadu[sample(nrow(Kakadu), 400),]
# subsample to speed up the estimation
## Estimate in log form, change 999 to Inf
lb <- log(Kakadu$lower)
ub <- Kakadu$upper
ub[ub > 998] <- Inf
ub <- log(ub)
y <- cbind(lb, ub)
m <- intReg(y ~ sex + log(income) + age + schooling +
recparks + jobs + lowrisk + wildlife + future + aboriginal + finben +
mineparks + moreparks + gov +
envcon + vparks + tvenv + major, data=Kakadu)
## Expect the conditional and unconditional predictions to deviate by
Ey <- predict(m, type="link")
print(head(Ey))
Eyc <- predict(m, type="linkConditional")
print(head(Eyc))
## New example with new data. Note the intervals are only necessary for
## 'linkConditional' prediction
## For simplicity, sample from the original one
newDat <- Kakadu[sample(nrow(Kakadu), 10),]
## There are two ways to create new intervals:
## either varaibles 'LB' and 'UB' in the new data frame:
newdatA <- newDat
newdatA$LB <- log(newDat$lower)
newdatA$UB <- log(newDat$upper)
EycA <- predict(m, newdata=newdatA, type="linkConditional")
print(head(EycA))
## ... or by introducing a variable 'yInt' which is a factor
## with 'cut'-style intervals like '[LB,UB)':
newdatB <- newDat
y <- rnorm(nrow(newDat), 6, 3)
newdatB$yInt <- cut(y, breaks=c(0, 2, 5, 20, 50, 100, 250, Inf))
EycB <- predict(m, newdata=newdatB, type="linkConditional")
print(head(EycB))
## extract residuals
eps <- residuals(m)
head(eps)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.