I would really appreciate your input on model design for a data set that explores multiple predictors on a proportion-type response with a phylogenetic correction with multiple sampling events per species. I’ve had to concatenate several guidelines from the brms package because of the nature of this data, and I have no one to consult with on this topic.
Here’s a sample of my data:
library(MuMIn)
### Define data
M_count <- rpois(n = 10, lambda = 4)
F_count <- rpois(n = 10, lambda = 3)
total_N <- (M_count+F_count)
Prop <- (M_count/(M_count+F_count))
year <- rpois(n=10, lambda = 2015)
species <- c("t1","t2","t1","t3","t3","t4","t5","t6","t2","t6")
location <- c("loc1","loc1","loc3","loc2","loc4","loc4","loc2","loc3","loc3","loc4")
temp <- rnorm(n=10, mean = 10, sd=2.7)
ALT <- rnorm(n=10, mean = 300, sd = 220)
Lat <- rnorm(n=10, mean = 31, sd=1.2)
temp.std <- stdize(temp)
ALT.std <- stdize(ALT)
Lat.std <- stdize(Lat)
dat <- data.frame(M_count, F_count, total_N, Prop, year,t,location,temp,ALT,Lat,temp.std,ALT.std,Lat.std)
#add 'phylo'
dat$phylo <- dat$species
#add tree
tree <- rtree(n = 6)
tree_l <- compute.brlen(tree, method = 'Grafen',power = 1)
A <- ape::vcv.phylo(tree_l)
#Fit a Binomial Logistic Regression Model
Bayes_Model_Prop_fit1 <- brm(M_count | trials(total_N) ~ ALT.std + Lat.std + temp.std + (1|phylo) + (1|species),
cov_ranef = list(phylo = A),
data = dat,
family = binomial(link = "logit"),
prior = c(
prior(student_t(3, 0, 10), "sd"),
prior(student_t(3, 0, 20), "Intercept")
),
warmup = 5000,
iter = 5000000,
chains = 2,
inits = "0",
cores = 1,
thin=500,
seed = 123)
Being new to this type of analyses, I really struggled with MCMCglmm before and found no solution for glmer packages that correct for phylogeny with repeated measurements.
I have a few novice questions:
- Is the model I employed suitable? I would appreciate any advice on syntax as well as on fitting.
- Should I incorporate random slopes? If so, how do I do that with all three fixed predictors?
- Is there a way to add weights to the model? (e.g., sampling event sample size ‘total_N’)
- Is there a function that runs all possible models (similar to ‘dredge’)?
Many thanks!