

Lines(newdat$x,newdat$bhi,col="darkgreen",lty=2,lwd=2) Lines(newdat$x,newdat$thi,col="orange",lty=2,lwd=2) Lines(newdat$x,newdat$tlo,col="orange",lty=2,lwd=2) Lines(newdat$x,newdat$phi,col="blue",lty=2,lwd=2) Lines(newdat$x,newdat$plo,col="blue",lty=2,lwd=2) #as we did this 200 times the 95% CI will be bordered by the 5th and 195th valueīb_se<-apply(bb$t,2,function(x) x) #here we basically get a merMod object and return the fitted valuesīb<-bootMer(m,FUN=predFun,nsim=200) #do this 200 times #we have to define a function that will be applied to the nsim simulations Tvar1 <- pvar1+VarCorr(m)$f # must be adapted for more complex models

Pvar1 <- diag(mm %*% tcrossprod(vcov(m),mm)) #predict(m,newdat,re.form=NA) would give the same results
#How to get the confidence intervals in asreml r code#
#first CI and PI using predict-like method, using code posted here: #first case simple lmer, simulate 100 data points from 10 groups with one continuous fixed effect variableĭata$y<-rnorm(100,modmat%*%fixed+rnd,0.3) We can however still derive confidence or prediction intervals keeping in mind that we might underestimate the uncertainty around the estimates. This means there is for now no way to include in the computation of the standard error for predicted values the fact that the fitted random effect standard deviation are just estimates and may be more or less well estimated.

The wikipedia page has some nice explanation about the meaning of confidence intervals.įor GLMM the predict function does not allow one to derive standard error, the reason being (from the help page of rMod): “There is no option for computing standard errors of predictions because it is difficult to define an efficient method that incorporates uncertainty in the variance parameters”. On the other hand the prediction interval focus on single data point and could be interpreted as (again assuming that we draw 95% CI): “If we would sample X times at these particular value for the explanatory variables, the response value would fall between this interval 95% of the time”. The confidence intervals (CI) focus on the regression lines and can be interpreted as (assuming that we draw 95% CI): “If we would repeat our sampling X times the regression line would fall between this interval 95% of the time”. This is then used to draw confidence or prediction intervals around the fitted regression lines. With LM and GLM the predict function can return the standard error for the predicted values on either the observed data or on new data.
