growthModelComp: Compares growth and survival objects built from different...

View source: R/IPMpack-Util.r

growthModelCompR Documentation

Compares growth and survival objects built from different covariate sets.

Description

Function compares model fits for growth and survival objects built with different linear combinations of covariates (plotting currently restricted to transforms of size; but comparison can include any chosen covariates). Growth can have multiple response forms. Returns a list containing a summary table of covariates and scores, and another list containing all of the growth (or survival) objects used in the comparison.

Usage

growthModelComp(dataf, 
    expVars = c(sizeNext~1,  sizeNext~size, sizeNext~size + size2), 
	regressionType = "constantVar",  testType = "AIC", 
		makePlot = FALSE, mainTitle = "", plotLegend = TRUE, 
		  legendPos = "topright",...)
		
survModelComp(dataf, expVars = c(surv~1,  surv~size, surv~size + size2), 
    testType = "AIC", 
	makePlot = FALSE, mainTitle = "",ncuts=20, plotLegend = TRUE, 
	   legendPos = "bottomleft", ...)

Arguments

dataf

dataframe with columns size, surv, and the growth response variable of choice

expVars

list of Formulas. Defaults to c(sizeNext~1, sizeNext~size, sizeNext~size + size2).

regressionType

character string identifying whether the type of regression run will have constant or changing variance (for growthModelComp. Defaults to constantVar.

testType

character string identifying the metric used to compare models. Can be any string that uses loglike from the lm or glm object. For example "AIC" or "BIC". Defaults to "AIC".

makePlot

logical whether to make plots with the comparison building. Defaults to FALSE.

mainTitle

string to place as the main attribute in plots (if makePlot = TRUE. defaults to NULL.

ncuts

for survModelComp, number of cuts in the data-set to be used in plotting

plotLegend

logical whether to plot a legend. Defaults to FALSE.

legendPos

places legend. Defaults to "topright".

...

additional arguments for plotting (ylim, col, etc)

Details

Both growthModelComp and survModelComp use a dataframe that has variables size and sizeNext to build a series of nested models. The default will build growth or survival objects with an intercept, an intercept and size, an an intercept with size and size^2 terms.

The models build use only lm or glm (and not mcmcGLMM for example) to estimate maximum likelihood estimates of functions. The testType (default "AIC" uses the loglike output from the lm or glm objects to score the model.

Plotting calls the functions plotGrowthModelComp or plotSurvModelComp to plot the objects. These functions can also be called after building the model comparison lists that are returned. If called outside of the initial building functions, they need to receive the GrowthObjects or SurvObjects list in the outputList from the build function. See plotGrowthModelComp and plotSurvModelComp for more details.

Value

a list with a summary table of class dataframe with models and scores and list of containing the objects of class grObj and survObj for each model.

Author(s)

C. Jessica E. Metcalf, Sean M. McMahon, Roberto Salguero-Gomez, Eelke Jongejans & Cory Merow.

See Also

makeGrowthObj,makeSurvObj,plotGrowthModelComp, plotSurvModelComp

Examples

# Data with size and sizeNext
dff <- generateData()

growthModelComp(dff, makePlot = TRUE)
survModelComp(dff, makePlot = TRUE)

growthModelComp(dff, makePlot = TRUE, regressionType = "changingVar")


wpetry/IPMpack2 documentation built on Sept. 29, 2022, 9:41 a.m.