Needing help using a Predict Function in brms

Hi there,

I am trying to use a predicting function in brms.

I have trait data for a select amount of geographical points (DF1), and my new dataset (DF2) is those same trait data but with a vaste amount more geographical points as it forms up species assemblages.

My first Data set DF1:

head(DF1)
 Scientific_Name          latitude   longitude      LAI    solar   TotAreaSpots                     
 B2
 Acanthagenys rufogularis -37.83113   145.8160   2.888929 14.21700   3.31158 
 
 Ailuroedus crassirostris -27.9167    152.3333   2.544430 18.42407   0.19611  
 Menura novaehollandiae   -29.6500    152.0833   2.674176 17.78050   2.96349 

 B2          Nest.type 
54.67732     Cup            
73.88418     Cup
27.40258     Dome

My second data set DF2:

head(DF2)
           Scientific_Name  latitude longitude      LAI    solar TotAreaSpots       
 Acanthagenys rufogularis -37.83113  145.8160 2.888929 14.21700      3.31158 
 Acanthagenys rufogularis -37.54446  149.1793 3.038562 14.80028      3.31158 
 Acanthagenys rufogularis -37.64789  148.0603 2.953508 14.96962      3.31158 

B2  Nest.type 
54.67732      Cup       
54.67732      Cup       
54.67732       Cup       
    
  
> str()

 $ Scientific_Name: Factor w/ 261 levels "Acanthagenys rufogularis",..
 $ latitude       : num  
 $ longitude      : num  
 $ LAI            : num 
 $ solar          : num  
 $ TotAreaSpots   : num  
 $ B2             : num  
 $ Nest.type      : Factor w/ 2 levels "Cup","Dome"

My model:

Fit1 <- brm(mvbind(B2,TotAreaSpots) ~ LAI * solar +  Nest.type ,
               data= DF1, family = gaussian(), cov_ranef = list(phylo=AB)
               ,warmup = 1000, iter = 2000, chains = 4,
               control = list(adapt_delta = 0.99))

And what I would like to do, is to run a predictive model, using DF2 (thus many more geographical points), to see the effects of LAI * solar and nest type on B2 and Spots.

Any suggestions would be highly appreciated!

Have you tried this?

yhat_new_data = posterior_predict(Fit1, newdata = DF2)

Hi!

Yes I have tried both

yhat_new_data <- posterior_predict(Fit1, newdata = DF2)
zhat_new_data <- predict(Fit1,newdata=DF2)

That both return large matrices with summaries such as:

> summary(zhat_new_data)
    Estimate       Est.Error          Q2.5           Q97.5      
 Min.   :64.62   Min.   :22.33   Min.   :18.11   Min.   :109.6  
 1st Qu.:74.12   1st Qu.:23.12   1st Qu.:28.53   1st Qu.:119.8  
 Median :75.75   Median :23.30   Median :30.34   Median :121.6  
 Mean   :76.95   Mean   :23.30   Mean   :31.32   Mean   :122.6  
 3rd Qu.:79.87   3rd Qu.:23.48   3rd Qu.:34.11   3rd Qu.:125.4  
 Max.   :90.44   Max.   :24.57   Max.   :46.94   Max.   :138.2 

However I do not understand this output… Can you help?

this are matrices, because you get as many predictions per case (rows in DF2) as you have posterior samples.

I see! So each row is full posterior distribution.

That’s great- does this mean I can use that matrix to plot on a map my predicted Estimates based of DF2?

I am not sure how much one would learn if the complete matrix were plotted.

I’d rather calculate means and credible interval (e.g. 5th to 95th percentile) and plot those.