weighted_se()
computes weighted standard errors of a variable or for
all variables of a data frame. survey_median()
computes the median for
a variable in a survey-design (see [survey::svydesign()]
).
weighted_correlation()
computes a weighted correlation for a two-sided
alternative hypothesis.
survey_median(x, design)
weighted_correlation(data, ...)
# S3 method for default
weighted_correlation(data, x, y, weights, ci.lvl = 0.95, ...)
# S3 method for formula
weighted_correlation(formula, data, ci.lvl = 0.95, ...)
weighted_se(x, weights = NULL)
(Numeric) vector or a data frame. For survey_median()
or weighted_ttest()
,
the bare (unquoted) variable name, or a character vector with the variable name.
An object of class svydesign
, providing
a specification of the survey design.
A data frame.
Currently not used.
Optional, bare (unquoted) variable name, or a character vector with the variable name.
Bare (unquoted) variable name, or a character vector with
the variable name of the numeric vector of weights. If weights = NULL
,
unweighted statistic is reported.
Confidence level of the interval.
A formula of the form lhs ~ rhs1 + rhs2
where lhs
is a
numeric variable giving the data values and rhs1
a factor with two
levels giving the corresponding groups and rhs2
a variable with weights.
The weighted (test) statistic.
data(efc)
weighted_se(efc$c12hour, abs(runif(n = nrow(efc))))
#> [1] 6.811783
# survey_median ----
# median for variables from weighted survey designs
data(nhanes_sample)
des <- survey::svydesign(
id = ~SDMVPSU,
strat = ~SDMVSTRA,
weights = ~WTINT2YR,
nest = TRUE,
data = nhanes_sample
)
survey_median(total, des)
#> $total
#> 0.5
#> [1,] 6
#>
#> attr(,"hasci")
#> [1] FALSE
#> attr(,"class")
#> [1] "newsvyquantile"
survey_median("total", des)
#> $total
#> 0.5
#> [1,] 6
#>
#> attr(,"hasci")
#> [1] FALSE
#> attr(,"class")
#> [1] "newsvyquantile"