Skip to content
Prev 81064 / 398502 Next

Predicting and Plotting "hypothetical" values of factors

On 17 Nov 2005 18:00:45 +0100, Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:
Perhaps still too complicated but if interp is
an interpolation function and xx are the two levels and yy
are the corresponding linear predictors (not the responses)
then plot xx interpolated vs the inverse link of yy
interpolated:

# interpolation function
interp <- function(x, length = 100) seq(x[1], x[2], length = length)

# levels and predictions (on linear predictor scale) from levels
xx <- c(1.1, 4.5)
yy <- predict(mymod1, newdata = list(myfac = factor(levs)))

plot(interp(xx), family(mymod1)$linkinv(interp(yy)))