I would like to use the prediction function from the package "prediction" in R (April 19, 2017 - Thomas J. Leeper) and compute the standard error of my predictions.
I have an lme model from the "nlme" package.
This is an example of how my data looks like. The model predicts higher heart rate of an animal when its speed is greater, when the ambient temperature is higher and when there are more observers at a short distance (significant interaction of Distance_animal_observer and Number_observer). The model takes into account the random effect of the Experiment_ID and the autocorrelation in time within the Experiment_ID level.
Is it possible to get an estimation of the standard error when doing a prediction?
Thank you so much in advance for your help!
set.seed(1)
df<-data.frame(Experiment_ID=c(1,1,1,2,2,2,3,3,3),
Heart_Rate=rnorm(9,60,10),
Time=c(as.POSIXct("2018-11-13 12:48:00",tz="UTC"),
as.POSIXct("2018-11-13 12:49:00",tz="UTC"),
as.POSIXct("2018-11-13 12:50:00",tz="UTC"),
as.POSIXct("2018-11-08 01:25:00",tz="UTC"),
as.POSIXct("2018-11-08 01:26:00",tz="UTC"),
as.POSIXct("2018-11-08 01:27:00",tz="UTC"),
as.POSIXct("2018-12-11 00:02:00",tz="UTC"),
as.POSIXct("2018-12-11 00:03:00",tz="UTC"),
as.POSIXct("2018-12-11 00:04:00",tz="UTC")),
Animal_ID=c("ID_1","ID_1","ID_1","ID_2","ID_2","ID_2","ID_3","ID_3","ID_3"),
Number_observer=c(1,1,1,2,2,2,1,1,1),
Speed_animal=rnorm(9,5,2),
Distance_animal_observer=rnorm(9,100,20),
Temperature_ambient=rnorm(9,10,2))
library(nlme)
Model<-lme(sqrt(Heart_Rate) ~ sqrt(Speed_animal)+Temperature_ambient+(Number_observer+ Distance_animal_observer)^2 ,
random= ~1|Experiment_ID, data=df,correlation = corAR1(form= ~1 | Experiment_ID))
library(prediction)
prediction(Model, data = find_data(Model), at = list(Speed_animal=4, Temperature_ambient=10, Number_observer= 1, Distance_animal_observer= 100))