Model selection with procD?

219 views
Skip to first unread message

Faysal Bibi

unread,
Jul 5, 2021, 5:58:14 AM7/5/21
to geomorph R package
Hello
Is there any way to use model selection (e.g. AIC) to choose among multiple fits made using procD.pgls or procD.lm? 

e.g. 
fit0 < - procD.pgls(shape~size, tree)
fit1 <- procD.pgls(shape~size+diet, tree)
fit2 <- procD.pgls(shape~size+diet+species, tree)

Thanks

Mike Collyer

unread,
Jul 5, 2021, 8:30:57 AM7/5/21
to geomorph R package
The model.comparison function in RRPP should work.

Mike

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/b72ebdba-91de-4289-bcbf-5e3f5efd1864n%40googlegroups.com.

Faysal Bibi

unread,
Jul 5, 2021, 10:24:37 AM7/5/21
to geomorph-...@googlegroups.com
Hi Mike - I had already tried that and it didn’t work, gives:
 
Error in model.comparison(fit0, fit1, fit2) : 
Objects must be lm.rrpp fits


You received this message because you are subscribed to a topic in the Google Groups "geomorph R package" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geomorph-r-package/_CEEzJapItg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/26436ACC-7DAB-4778-9A48-13D5DEFE9764%40gmail.com.

Mike Collyer

unread,
Jul 5, 2021, 10:34:13 AM7/5/21
to geomorph R package
It works for me (see below).  Maybe check your versions of RRPP and geomorph and make sure you are up to date.

Mike

> data(plethspecies)
> Y.gpa<-gpagen(plethspecies$land)    

Performing GPA
  |=========================================================================================| 100%

Making projections... Finished!
> gdf <- geomorph.data.frame(Y.gpa, phy = plethspecies$phy)
> pleth.pgls <- procD.pgls(coords ~ Csize, phy = phy, data = gdf, 
+                          iter = 999)

Please be aware that printing progress slows down the analysis (perhaps slightly).

Preliminary Model Fit...

Sums of Squares calculations: 1000 permutations.
  |=========================================================================================| 100%
> pleth.null <- procD.pgls(coords ~ 1, phy = phy, data = gdf, 
+                          iter = 999)

Please be aware that printing progress slows down the analysis (perhaps slightly).

Preliminary Model Fit...

Sums of Squares calculations: 1000 permutations.
  |=========================================================================================| 100%

No terms for ANOVA; only RSS calculated in each permutation
> model.comparison(pleth.null, pleth.pgls, type = "logLik")
          logLik residual.pc.no penalty        AIC
1     271.439968              8      88 -454.87994
Csize   2.381009              8     104   99.23798

Faysal Bibi

unread,
Jul 5, 2021, 11:06:53 AM7/5/21
to geomorph-...@googlegroups.com
Ah that was it, thanks, updating worked.

However, for my comparisons, type=“cov.trace” works fine, but when I try type=“logLik” for the same fits I consistently get "Error: Independent variables are missing from either the data frame or global environment,”

Any ideas why? I tried different parameters of tol or pc.no to reduce dimensionality but without success. 

Mike Collyer

unread,
Jul 5, 2021, 4:02:10 PM7/5/21
to geomorph-...@googlegroups.com
The only thing that could cause that error is the refitting of your models based on the dimensions desired (it is a lm.rrpp error, not a model.comparison error.

I would have to look at your script and data to diagnose the issue.  If you like, you can send them to me outside of the group email.

Mike

Faysal Bibi

unread,
Jul 6, 2021, 4:33:36 AM7/6/21
to geomorph R package
Thanks, just did.
Reply all
Reply to author
Forward
0 new messages