plot.pgls.R2AIC: Plot (R2 vs AIC) results of a collection of fit PGLS models

View source: R/plotting.R

plot.pgls.R2AICR Documentation

Plot (R2 vs AIC) results of a collection of fit PGLS models

Description

Plots a single panel of R^2 versus AIC, using versions of your choosing.

Usage

## S3 method for class 'pgls.R2AIC'
plot(x, 
            bests=bestBy(x, by=c('n','q','qXn','rwGsm')[4], best=c('AICc','R2.adj')[1], 
            inverse=c(FALSE,TRUE)[1]),bcl=rgb(1,1,1,maxColorValue=3,alpha=1), nx=2, 
            model.as.title='', ...)

Arguments

x

a PGLSi[teration]$optim [optimization] table

bests

a list of the best PGLS models grouped by variable count and sorted by some metric (e.g. adjusted R2)

bcl

background color of plot point

nx

point size expansion factor to multiply against sample size ratio (this model to max of all models)

model.as.title

uses model.1ln.report to create a short character string of the "best" model results as a title

...

other parameters passed to 'plot'

Value

a plot of R2 versus AIC of many PGLS models

Examples


data.path <- system.file("extdata","primate-example.data.csv", package="mmodely")
data <- read.csv(data.path, row.names=1)
pvs <- names(data[3:6])
data$gn_sp <- rownames(data)

tree.path <- system.file("extdata","primate-springer.2012.tre", package="mmodely")
phyl <- ape::read.tree(tree.path)[[5]]

mods <- get.model.combos(predictor.vars=pvs, outcome.var='OC', min.q=2)

# sprinkle in some missing data so as to make model selection more interesting
for(pv in pvs){ data[sample(x=1:nrow(data),size=2),pv] <- NA} 

PGLSi <- pgls.iter(models=mods, phylo=phyl, df=data, k=1,l=1,d=1) 

plot.pgls.R2AIC(PGLSi$optim)   # find the lowest AIC within each q by n sized sub-dataset


mmodely documentation built on May 31, 2023, 6:47 p.m.