Parallelization of exhaustive occu model fitting routine (pdredge)

403 views
Skip to first unread message

Danielle Rappaport

unread,
Jul 10, 2018, 2:55:13 PM7/10/18
to unmarked
Hi all: 

I am selecting among occupancy models, and given the large (>50) number of plausible covariates, I have opted to use an exhaustive dredging approach to aid in model selection. I am using the pdredge() function from the MuMIn package to dredge all possible occu() model fits, which I need to parallelize in order to finish the model selection procedure before the end of the century. I've adapted some parallelization code from this message board; however, I don't think it's working correctly, which I imagine is indicated by the message "Not using cluster" below.

I'm not experienced at parallelizing code in R, so any suggestions would be greatly appreciated. I'm copy/pasting my script below. 

#dredging on detection component
global_det
<-occu( ~ Freq + I(Freq^2) +n + Deg_class + Freq_fire + age +  mean_all_kurt+ mean_all_mean+mean_all_p90+mean_all_skew+mean_all_stdev+mean_shrub_mean+mean_shrub_stdev+mean_tree_fcover+mean_tree_fract_all+mean_tree_kurt+mean_tree_mad+mean_tree_mean+mean_tree_p90+mean_tree_skew+mean_tree_vdr ~ 1, umf_all)


# Set up the cluster
clusterType
<- if(length(find.package("snow", quiet = TRUE))) "SOCK" else "PSOCK"
clust
<- try(makeCluster(getOption("cl.cores", 4), type = clusterType))


clusterEvalQ
(clust, library(unmarked))
clusterExport
(clust, "umf_all")


# 'stats4' is needed for AIC to work with unmarkedFit objects but is not
# loaded automatically with 'unmarked'.
require(stats4)
invisible
(clusterCall(clust, "library", "stats4", character.only = TRUE))




system
.time(dredge_det<-pdredge(global_det, rank=AIC))



# best models and null model
models_sub
<- subset(dredge_det, delta < 2)


Grant Davis

unread,
Oct 10, 2018, 3:09:22 PM10/10/18
to unmarked
system.time(dredge_det<-pdredge(global_det, rank=AIC))

I think the cluster should be passed to the pdredge function, otherwise it deffaults to NA (not using a cluster).

system.time(dredge_det<-pdredge(global_det, rank=AIC, cluster=clust))
Reply all
Reply to author
Forward
0 new messages