fits: Fit all options for a given outcome model scenario, allowing...

Description Usage Arguments Details Value Author(s) See Also

View source: R/fits.R

Description

Fit all options for a given outcome model scenario, allowing fixed-effect environmental covariates to vary.

Usage

1
fits(mStrings, CN, CNMax = 30, row, df, offsetVar, saveModels = FALSE)

Arguments

mStrings

A list housing various model formula strings from function makeModelStrings.

CN

A numeric vector of results, as output via sapply and getKappa from the buildModel wrapper function.

CNMax

A number specifiying the maximum condition number for which models are to be evaluated. Default is 30.

row

A one-row data.frame, typically originating from a csv housing desired model characteristics. Should include at least outcome, fitFunction, outcomeFormula, possibleCovars, baseFormula, ziFormula, and family.

df

A dataframe containing the variables necessary to fit a Piepho & Ogutu linear mixed model.

offsetVar

The variable to be utilized as an offset, submitted as a character string. Typically SamplingPeriods. Default is NULL, or no offset.

saveModels

A logical indicating if each individual model should be pushed as functional output. Default is FALSE.

Details

Function fits fits the model functional form specified via row. Included fit models are dictated via mStrings with calculated condition numbers less than CNMax, whose default is set at 30.

Although function buildModel constructs model strings both with and without an intercept, formula manipulation to create the top dataframe currently assumes the presence of one. Thus, manually removing the intercept via the typical -1 will probably lead to an error.

Currently, count models always assume an offset of log(30) (for 30 m^2 searched per site visit).

Value

A list with several elements.

good

A list of length equal to the number of models whose condition number was less than the CNMax. Entries are direct model objects from fitting, and thus contain all information possibly of value.

bad

A list of length equal to the number of models whose condition number was greater than the CNMax. Entries simply report the offending condition-number values.

mess

A list of length equal to the length in list good. Entries correspond to messages recorded during model fits. Values of NULL mean no message was recorded. Typically, this implies model convergence.

fitsL

A list of length equal to the number of distinct models included via mStrings$modelRaw housing results from the model fit. In the case the condition number was greater than CNMax, the number is the offending condition number. Otherwise, an object of the class peculiar to the model-type fit is returned. In the case that saveModels is FALSE, a simple character string is returned instead.

aic

A list of length equal to the length in list good. Reported numbers are the AIC, as pulled from the summary of the original model fits. Entries with 9999999999 generally represent models for which convergence was achieved, but for which the AIC was reported to be NA. This means these models could be included within the good list.

top

A data.frame encapsulating all other results in a simple tabulated format. Conducive for output to csv format.

Author(s)

Jason Mitchell

See Also

makeModelStrings, getKappa


studyvin/pollinatorAttractiveness documentation built on Dec. 23, 2021, 6:38 a.m.