data(iris)
# Fit a regression model
mod <- lm(Sepal.Length ~ Sepal.Width + Species, data = iris)
PIC(object = mod,
newdata = data.frame(Sepal.Width = c(0.25, 1.74, 2.99),
Species = factor(c("setosa", "virginica", "virginica"),
levels = c("setosa", "versicolor", "virginica"))))
# Fit a bivariable regression model
mod <- lm(cbind(Sepal.Length, Sepal.Width) ~ Species + Petal.Length, data = iris)
# Note: For multivariable models, response variable columns must be included if
# newdata is specified. If the values of the validation response(s) are
# unknown, specify NA. If partially observed, specify NA only where unknown.
PIC(object = mod,
newdata = data.frame(Sepal.Length = c(4.1, NA, NA),
Sepal.Width = c(NA,NA,3.2),
Petal.Length = c(1.2, 3.5, 7),
Species = factor(c("setosa", "virginica", "virginica"),
levels = c("setosa", "versicolor", "virginica"))))
Run the code above in your browser using DataLab