predict.intReg: predicted outcomes and expected residuals of 'intReg' models

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

Description

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.

Usage

1
2
3
4
## S3 method for class 'intReg'
predict(object, newdata = NULL, type = "link", ...)
## S3 method for class 'intReg'
residuals(object, ...)

Arguments

object

“intReg” object, estimated interval regression model

newdata

a list or frame for new data. If type is ‘linkConditional’, the new data frame must include new intervals. These can either be supplied through two variables ‘LB’ and ‘UB’ for lower and upper bound, or a single variable ‘yInt’ which is a factor with cut–style interval coding in the form “[LB,UB)”. (The brackets and parentheses are equivalent.)

type

character, what to predict:

  • “link” y* for the expected latent link value,

  • “linkConditional” the expected latent value conditional on x and the observed interval (l,u), E[y*|l <= y* < u]

...

currently ignored

Details

residuals reports generalized residuals, the expected difference between the predicted and actual link E[predicted y* - y*|l <= y* < u, x].

Value

a numeric vector, the predicted values/residuals.

Author(s)

Ott Toomet

See Also

intReg

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
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)

intReg documentation built on May 2, 2019, 4:43 p.m.