stotal: Calculate the survey total

View source: R/survey_calcs.R

stotalR Documentation

Calculate the survey total

Description

Calculate the survey total

Usage

stotal(x, ...)

## Default S3 method:
stotal(
  x,
  na.rm = T,
  var_type = "none",
  level = 0.95,
  use_df = T,
  ids,
  sv,
  st,
  ...
)

Arguments

x

vector. Vector of values to compute a weighted total over

...

other arguments. Currently unused.

na.rm

logical. Determines whether NAs are removed from calculations

var_type

character. Report variability as one or more of: standard error ("se", default) and confidence interval ("ci")

level

numeric. A value in the range of (0, 1) denoting what level of confidence the CI should be

use_df

logical. Should the estimated degrees of freedom by used to calculate CIs? Default is FALSE (different from smean. FALSE implies df = Inf.

ids

numeric. indices which are being computed. Can be generally omitted and will be added to the call via '[.dtsurvey'

sv

data.table. Data.table of psu, strata, weight and the like to properly do survey statistics.

st

character. type of survey dataset being analyzed. Can be generally omitted and will be added to the call via '[.dtsurvey'

Details

If var_type is "none", a vector is returned. For factors, the names of the vector correspond to the levels. It should also be ordered in that way In that case a list/data.table is returned with a column for the result and a column specifying the levels. When var_type is not "none" a named list is returned (and then likely converted into a data.table). The list (which should be named) is ordered in the following manner (by slot): result, se, lower, upper, levels – when requested.

Value

a vector or a list (the latter likely converted into a data.table) containing the results


PHSKC-APDE/dtsurvey documentation built on March 6, 2024, 2:14 p.m.