Skip to contents

Validate obs_population object for imuGAP

Check observation meta data object

Usage

check_obs_population(
  obs_population,
  observations,
  locations,
  max_cohort,
  max_age
)

check_obs_population(
  obs_population,
  observations,
  locations,
  max_cohort,
  max_age
)

Arguments

obs_population

a data.frame, the the observation weighting object, with columns

  • obs_id, the observation id the row concerns

  • dose, which dose the row concerns

  • location, the location the row concerns

  • cohort, the cohort at that location the row concerns

  • age, the age of that cohort the row concerns

  • weight, the relative contribution of this row to an observation Note that multiple rows may concern the same observation, meaning that the populations from different cohorts, locations, and ages may be pooled in an observation

observations

a data.frame with:

  • nonnegative integer positive column

  • positive integer sample_n column, which must be greater than or equal to the positive column

  • optionally, an id column, 1:size(observations)

locations

a data.frame, with integer columns id and parent_id. See Details for restrictions.

max_cohort

if present, what is the maximum cohort that should be present?

max_age

if present, what is the maximum age that should be present?

max_obs_id

optional positive integer, the maximum valid observation id

max_location

optional positive integer, the maximum valid location id

subset

logical; if FALSE (default), observations must be complete. If TRUE, max_obs_id must be provided.

Value

if x is valid, returns the canonical obs_population object

Details

A valid obs_population object must:

  • be convertible to a data.table via data.table::setDT()

  • contain the columns "obs_id", "location", "cohort", "age", "dose", and "weight"

  • obs_id, integers >= 1; if max_obs_id is provided, <= max_obs_id; if subset is FALSE, all integers 1:max_obs_id must be present

  • location must be a positive integer less than or equal to max_location. however, not all locations need to be represented in wts

  • cohort must be a positive integer

  • age must be a positive integer

  • dose must be 1 or 2

  • weight must be a positive numeric value; weights must sum to 1 by obs_id

Errors

If x is not valid, raises an error describing the issue.