backEnhFit: backEnhFit

View source: R/backEnhFit.r

backEnhFitR Documentation

backEnhFit

Description

For a given set of covariates, fit a genearlized additive model via a backwards-selection paradigm, allowing for both selection of confounding covariates, as well as variable temporal B-splines.

Usage

backEnhFit(
  tmp.df,
  df,
  initialVars,
  possibleVars,
  m.i,
  eff.ind.inside,
  max.df.spline,
  eff.inside.dates,
  trap,
  model.info,
  fits,
  plot.file,
  option,
  bsplBegDt,
  bsplEndDt
)

Arguments

tmp.df

The reduced data frame originating from df containing only efficiency-trial dates; i.e., those with non-NA nReleased values.

df

The data frame for a specific TrapPositionID containing efficiency-trial information and covariates, if available, at the time of fitting enhanced efficiency trials in eff_model.r (or F.efficiency.model ).

initialVars

The set of possible variables available for model inclusion, following application of the 90 form a subset of the possibleVars.

possibleVars

The set of all available variables for possible inclusion to the fitting of an enhanced efficiency model. Usually include efficiency-trial variables, environmental covariate variables, and CAMP-collected variables.

m.i

An integer containing the number of rows in data frame tmp.df.

eff.ind.inside

A logical vector of length equal to the number of rows of data frame df, expressing which batchDates fall within the temporal data-range for which estimation occurs.

max.df.spline

An integer expressing the highest allowable spline degree.

eff.inside.dates

A POXIX-type vector of length 2, housing the first and last batchDates for which vector eff.ind.inside is TRUE.

trap

An alphanumeric TrapPositionID value, as itemized within df (and tmp.df).

model.info

A list containing information derived from an immediate preceding call to function plotbsSpline. Used to help get the current fit iteration going.

fits

A list object of length equal to the number of TrapPositionIDs requiring a model fit. Ultimately passed to the boostrapping routine.

plot.file

The name of the file prefix under which output is to be saved. Set to NA to plot to the plot window.

option

A graphical option for displaying spline fits. Typically (and hard-coded) set to 2.

bsplBegDt

The first date, via the spline-1959-1960 paradigm, to which all efficiency years and dates collapse.

bsplEndDt

The last date, via the spline-1959-1960 paradigm, to which all efficiency years and dates collapse.

Details

Function bachEnhFit is the workhorse function that fits the backwards-fitting algorithm for enhanced-efficiency splines. It utilizes tests of deviances to identify variables for possible exclusion from an initial model containing all avalabile covariates, and smaller subets following the removal of the most non-significant covariate identified on the most recent preceding model fitting.

An alpha value of 0.10 is used to test for possible stopping of the model; i.e., if all included covariates in a model have p-values less than 0.10, all covariates are retained, and the model-fitting procedure stops. Note that the value of 0.10 is set within the function via initial parameter pCutOff.

Value

Several objects, all housed within a list.

fit

The final fit for the current TrapPositionID of interest.

model.info

List of model information resulting from the application of backEnhFit to each unique TrapPositionID in df.

fits

List of fits resulting from the application of backEnhFit to each unique TrapPositionID in df.

covarStringPlot

A record of considered variables necessary model plotting outside of the function.

interimVars1Num

Set of variables remaining for model inclusion when both CAMP waterTemp_C and Environmental-covariate temp_C are present.

interimVars2Num

Set of variables remaining for model inclusion when both CAMP discharge_cfs and Environmental-covariate flow_cfs are present.

Author(s)

WEST Inc.

See Also

eff_model_enh, plotbsSpline

Examples

## Not run: 
out <- backEnhFit(tmp.df,
                  df,
                  initialVars,
                  possibleVars,
                  m.i,
                  eff.ind.inside,
                  max.df.spline,
                  eff.inside.dates,
                  trap,
                  model.info,
                  fits,
                  plot.file,
                  option,
                  bsplBegDt,
                  bsplEndDt)

## End(Not run)

tmcd82070/CAMP_RST documentation built on April 6, 2022, 12:07 a.m.