[R-sig-ME] MCMCglmm Predict failing with "NA/NaN/Inf in foreign function call" for binary responses
Will Styler
wstyler at umich.edu
Fri Feb 3 17:24:44 CET 2017
Hello,
After successfully fitting my models, I've been struggling to get predicted
curves for illustration. I'm working with binary data, with b-splines (to
model change over time), and some random effects, and any time that I use
the predict function in MCMCglmm 2.24, it returns the below error:
> Error in MCMCglmm(fixed = object$Fixed$formula, random =
object$Random$formula, : NA/NaN/Inf in foreign function call (arg 3)
Although my model is rather more complex, here's a toy example returning
the same issue during the "predict" call.
Do you have any advice on how to proceed? Or, if I'm barking up the wrong
tree, is there an easier approach to getting the model's predictions for a
given set of conditions which I can graph?
Thanks,
Will
-----------------
Will Styler
Post-Doctoral Research Fellow
University of Michigan Department of Linguistics
http://savethevowels.org/will
> library(MCMCglmm)
>
> set.seed(123)
>
> dat <- data.frame(x = rnorm(100), y = sample(c(0,1)),z=as.factor(
seq(1:2)),r1=as.factor(seq(1:20)))
>
> prior = list(R = list(V = 1, n = 0, fix = 1), G = list(G1 = list(V =1,n =
1)))
>
> fit <- MCMCglmm(
>
> fixed = y ~ bs(x)*z,
>
> random =~r1,
>
> rcov = ~ units,
>
> data = dat,
>
> family = "threshold",
>
> pr = TRUE, pl = TRUE,
>
> prior=prior,
>
> saveX = TRUE, saveZ = TRUE,
>
> nitt = 1.3e+4, thin = 10, burnin = 3e+3
>
> )
>
>
> pred_grid <- data.frame(x = seq(-1, 1, length.out =
30),y=0,z=factor(seq(1:2)),r1="1")
>
> predict(fit, newdata = pred_grid)
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list