check_observations: Check whether there are sufficient observations to run a...

View source: R/data_checks.R

check_observationsR Documentation

Check whether there are sufficient observations to run a model

Description

Check whether there are sufficient observations to run a model

Usage

check_observations(x, ...)

## S3 method for class 'data.frame'
check_observations(
  x,
  model,
  count_col = "count",
  year_col = "year",
  month_col = NULL,
  covars = character(0),
  changepoints = numeric(0),
  eps = 1e-08,
  ...
)

## S3 method for class 'trimcommand'
check_observations(x, ...)

## S3 method for class 'character'
check_observations(x, ...)

Arguments

x

A trimcommand object, a data.frame, or the location of a TRIM command file.

...

Parameters passed to other methods.

model

[numeric] Model 1, 2 or 3?

count_col

[character|numeric] column index of the counts in x

year_col

[character|numeric] column index of years or time points in x

month_col

[character|numeric] optional column index of months in x

covars

[character|numeric] column index of covariates in x

changepoints

[numeric] Changepoints (model 2 only)

eps

[numeric] Numbers whose absolute magnitude are lesser than eps are considered zero.

Value

A list with two components. The component sufficient takes the value TRUE or FALSE depending on whether sufficient counts have been found. The component errors is a list, of which the structure depends on the chosen model, that indicates under what conditions insufficient data is present to estimate the model.

  • For model 3 without covariates, $errors is a list whose single element is a vector of time points with insufficient counts.

  • For model 3 with covariates, $errors is a named list with an element for each covariate for which insufficients counts are encountered. Each element is a two-column data.frame. The first column indicates the time point, the second column indicates for which covariate value insufficient counts are found.

  • For Model 2, without covariates $errors is a list with a single element changepoints. It points out what changepoints lead to a time slice with zero observations.

  • For Model 2, with covariates $errors is a named list with an element for each covariate for which inssufficients counts are encountered. Each element is a two-column data.frame, The first colum indicates the changepoint, the second column indicates for which covariate value insufficient counts are found.

See Also

Other modelspec: read_tcf(), read_tdf(), set_trim_verbose(), trim(), trimcommand()


rtrim documentation built on June 22, 2024, 10:39 a.m.