Predict "lpmatrix" of an average model calculated with MumIn (model averaged)

2

I'm trying to use the predict function with type lpmatrix with an object type averaging and I have two doubts, the script would be as follows:

full_gam <- gam (abundance ~ s(chla, k = 4) + s(g_chla, k = 4) +
                 s(sst, k = 4) + s(g_sst, k = 4),
                 offset = log (effort), family = nb, data = training)

gam_dredge <- dredge(full_gam, m.lim=c(1,4), beta = FALSE,

confset.95 <- get.models(gam_dredge,subset = cumsum(gam_dredge$weight) <= .95)

gam_avg <- model.avg(confset.95, revised.var = TRUE)

Xp <- predict(gam_avg, newdata, type="lpmatrix")

sim_coef <- rmvnorm (n_sim, as.numeric(coef(gam_avg)), gam_avg$Vp)

However, when making the prediction I get the following error:

Xp <- predict(gam_avg, newdata, type="lpmatrix")

Error in weighted.mean.default(newX[, i], ...) : 'x' and 'w' must have the same length

And at the time of doing the simulation, I do not know where I can get the Vp values (parameters of the covariance matrix) of the model averaged.

I understand that it may be because within the object there are several models, but do you know if they can be extracted in some way?

Thanks

    
asked by Isa Gar-Bar 16.03.2017 в 17:42
source

0 answers