Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_var_est

Get the variance estimates for a survey estimate


Description

This is a helper to allow srvyr's syntactic style. In general, users will not have to worry about getting survey variance estimates directly unless they are trying to extend srvyr. This function helps convert from the result of a survey function into a data.frame with an estimate and measures of variance around it in a way that summarize expects. See vignette("extending-srvyr") for more details.

Usage

get_var_est(
  stat,
  vartype,
  grps = "",
  level = 0.95,
  df = Inf,
  pre_calc_ci = FALSE,
  deff = FALSE
)

Arguments

stat

A survey statistic object, usually the result of a function from the survey package or svyby.

vartype

A vector indicating which variance estimates to calculate (options are se for standard error, ci for confidence interval, var for variance or cv for coefficient of variation). Multiples are allowed.

grps

A vector indicating the names of the grouping variables for grouped surveys ("" indicates no groups).

level

One or more levels to calculate a confidence interval.

df

Degrees of freedom, many survey functions default to Inf, but srvyr functions generally default to the result of calling degf on the survey object.

pre_calc_ci

Whether the confidence interval is pre-calculated (as in svyciprop)

deff

Whether to return the design effect (calculated using survey::deff)

Value

a tbl_svy with the variables modified


srvyr

'dplyr'-Like Syntax for Summary Statistics of Survey Data

v1.0.1
GPL-2 | GPL-3
Authors
Greg Freedman Ellis [aut, cre], Thomas Lumley [ctb], Tomasz Żółtak [ctb], Ben Schneider [aut, ctb], Pavel N. Krivitsky [ctb]
Initial release
2021-03-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.