1

I am dredging an unmarked occupancy model and have run into a few obstacles:

1) After first dredging the detection component of the model, I am trying to dredge the occupancy component of the model with the fixed subset of predictors previously selected for the detection component, as follows:

global_occ <-occu( ~ Freq + I(Freq^2) + n  +mean_tree_d9 + mean_tree_kurt  ~ C1 + C2 + C3 + C4 + S1 + S2 + S3 + S4 + Hour + I(Hour^2) + Deg_class + Freq_fire + age + Freq + mean_tree_d9 + mean_tree_d4 + mean_tree_d2 + mean_shrub_stdev + mean_tree_kurt + mean_tree_mad, umf_all)

system.time(dredge_occ<-pdredge(global_occ, rank=AIC, m.max=5, cluster=clust, fixed=`p(Freq)`&`p(I(Freq^2))`&`p(n)`&`p(mean_tree_d9)`&`p(mean_tree_kurt)`))


> dredge_occ

Global model call: occu(formula = ~Freq + I(Freq^2) + n + mean_tree_d9 + mean_tree_kurt ~ 
    C1 + C2 + C3 + C4 + S1 + S2 + S3 + S4 + Hour + I(Hour^2) + 
        Deg_class + Freq_fire + age + Freq + mean_tree_d9 + mean_tree_d4 + 
        mean_tree_d2 + mean_shrub_stdev + mean_tree_kurt + mean_tree_mad, data = umf_all)
---
Model selection table 
   p(Int) psi(Int) p(Frq) p(I(Frq^2)) p(men_tre_d9) p(men_tre_krt)    p(n) df    logLik     AIC delta weight
31  -8.68    -1.93 -8.518      -2.439       -0.2369        -0.2295 0.07039  7 -9664.791 19343.6     0      1
Models ranked by AIC(x) 

UPDATE: I tried using Kamil's solution below, but it wasn't working because the "m.max" parameter imposes a universal constraint (across both p and psi components) on the maximum number of variables for any individual model and therefore was not permitting any psi covariates to be fitted...

SilvanD
  • 325
  • 2
  • 14

1 Answers1

2

?dredge says: fixed is "either a single sided formula or a character vector giving names of terms". In your case it is an expression (suitable as the subset argument). So, your code should read: pdredge(global_occ, rank=AIC, m.max=5, cluster=clust, fixed=c("p(Freq)", "p(I(Freq^2))", "p(n)", "p(mean_tree_d9)", "p(mean_tree_kurt)"))

Kamil Bartoń
  • 1,482
  • 9
  • 10
  • One follow-up question: If I wanted more complex subsetting rules, my understanding is that I have to use "subset" and not "fixed"; however, I'm not clear on the following: Let's say, I want 'p(Freq)' in all models, however, when 'psi(C1)' and 'psi(S2)' appear, I want them to appear together. How do I conjoin the two formulas? I know the following is incorrect because I don't want to fix C1 and S1 to the psi component, but I just want to make sure they appear together when they appear. Thank you so much. pdredge(global_occ, cluster=clust, subset=`p(Freq)`&`psi(C1)`&&`psi(S1)`) – SilvanD Jul 19 '18 at 18:43
  • `subset` works as if the term names were logical values (of length 1, so `&` and `&&` give the same result), equal `TRUE` if the model term is present. See `?Logic` for a reference on logical operators in R. – Kamil Bartoń Jul 20 '18 at 09:42
  • Thanks, Kamil. One final question: Do you know why the call trace > 1 does not seem to work with pdredge? It throws out an error. I'd like to be able to monitor the process with a progress bar. – SilvanD Jul 23 '18 at 14:14
  • `trace` does not work properly with `pdredge`, but it does not give an error in my case. Fixing that is on my TODO list, but not really a priority. – Kamil Bartoń Jul 23 '18 at 15:14