fitSpline: fitSpline

View source: R/fitSpline.r

fitSplineR Documentation

fitSpline

Description

Fit a temporal spline with a given set of covariates; i.e., fit a generalized additive model (GAM).

Usage

fitSpline(
  covarString,
  df,
  eff.ind.inside,
  tmp.df,
  dist,
  max.df,
  eff.inside.dates
)

Arguments

covarString

A character string of length one housing all covariates to be considered, with all covariates collapsed via " + ".

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 ).

eff.ind.inside

A vector of length equal to the number of rows in data frame df set equal to TRUE when the df batchDate is inside the data range specified by eff.inside.dates.

tmp.df

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

dist

The distributional family used in calls to function glm. Almost always set to "binomial".

max.df

The highest number of degrees of freedom to be used in the fitting of temporal-dimension splines. Set by max.df.spline, which is 4 in function eff.models.

eff.inside.dates

A temporal POSIX vector of length two indicating the first and last batchDate efficiency trials.

Details

Note that returned object bspl is not the same as cur.bspl. In order to stop, the loop that evaluates temporal splines must first evaluate the next model. In the case that the next model fails to be better than the current model, the current model is the winner. Object cur.bspl is the basis matrix associated with the winning current model, while bspl is the basis maxtri associated with that (non-winning) next model.

The overdispersion parameter is fit in the traditional way, i.e., via Pearson residuals.

Value

A list containing several different objects.

fit

The glm-type object resulting from the fit.

fit.AIC

The AIC of fit.

bspl

The matrix of ALL batchDates within eff.inside.dates of the final evaluated model.

tmp.bs

The matrix of REDUCED batchDatess from bspl tied to efficiency-trial dates.

cur.df

The final number of degrees-of-freedom used in the final temporal spline fit.

disp
s.beg

The first date housed within the 1960-spline paradigm variable batchDate2.

s.end

The last date housed within the 1960-spline paradigm variable batchDate2.

cur.bspl

The matrix of ALL batchDates within eff.inside.dates of fit model.

Examples

 
## Not run: 
fit <- fitSpline(covarString,
                 df,
                 eff.ind.inside,
                 tmp.df,
                 dist,
                 max.df,
                 eff.inside.dates)

## End(Not run)

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