[R-sig-ME] MCMCglmm predictions using new data error
Alberto Gallano
alberto.gc8 at gmail.com
Wed Jan 6 23:39:33 CET 2016
I'm trying to make predictions from an MCMCglmm model using new data. This
is a feature that was recently added to the predict.MCMCglmm function
(version 2.22). However, when I set things up as I would for other predict
methods, I get the following error:
> Error in eval(expr, envir, enclos) : object 'y' not found
where 'y' is my response vector. I'm including a simplified replicable
example below. Is the set up of the prediction grid different for the
MCMCglmm predict method compared with other methods?
best,
Alberto
#
----------------------------------------------------------------------------------
library(MCMCglmm)
set.seed(123)
dat <- data.frame(x = rnorm(100), y = rnorm(100))
fit <- MCMCglmm(
fixed = y ~ x,
rcov = ~ units,
data = dat,
family = "gaussian",
pr = TRUE, pl = TRUE,
saveX = TRUE, saveZ = TRUE,
nitt = 1.3e+4, thin = 10, burnin = 3e+3
)
pred_grid <- data.frame(x = seq(-1, 1, length.out = 30))
predict(fit, newdata = pred_grid)
#
----------------------------------------------------------------------------------
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list