I am not getting any output (0 rows) when specifying confidence interval with quantiles. Any ideas? Here's a reprex:
library(tidyverse) # for tidyverse
library(here) # for file paths
#> here() starts at C:/Users/sazimmer/AppData/Local/Temp/RtmpyMdwWk/reprex5a68704646a1
library(survey) # for some survey analysis
#> Loading required package: grid
#> Loading required package: Matrix
#>
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#>
#> expand, pack, unpack
#> Loading required package: survival
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
library(srvyr) # for tidy survey analysis
#>
#> Attaching package: 'srvyr'
#> The following object is masked from 'package:stats':
#>
#> filter
# recs <- read_rds(here("Data", "recs.rds"))
#
# recs %>%
# select(NWEIGHT, BRRWT1:BRRWT20, TOTALDOL) %>%
# mutate_if(is.numeric, round, 1) %>%
# slice(1:10) %>%
# dput()
recs <- structure(list(NWEIGHT = c(12085.2, 14410.2, 23326, 12165.3,
16717.7, 26058.9, 45952.8, 15281, 14034.7, 43359.2), BRRWT1 = c(16555.3,
21486.3, 12297.4, 18554, 8075.7, 37004.1, 28077.4, 22962.3, 6989.9,
73353.8), BRRWT2 = c(5938, 19147, 36659.8, 5209.1, 8427.3, 34907.2,
71118.6, 7067.5, 6954.7, 19161.1), BRRWT3 = c(17725.6, 7320.4,
10476.2, 18041.5, 8335.6, 15314.9, 20106.9, 25747.7, 7097.5,
16672.1), BRRWT4 = c(17635.6, 23567.9, 10101.9, 5441.8, 23666.4,
33343, 68172.2, 23842.5, 20873, 18551), BRRWT5 = c(6032.8, 21926.6,
10291.1, 5815.6, 7674.5, 15332.5, 64424.8, 7951.1, 8224.2, 81545.2
), BRRWT6 = c(17095.4, 7477.4, 39732, 4936, 25586.8, 14433.9,
56769.9, 26022.5, 19524.2, 63728), BRRWT7 = c(6003.4, 21544,
11547.8, 22136.1, 23442, 14590.9, 22868.6, 7984.6, 21250.8, 67869
), BRRWT8 = c(5994.1, 8189.4, 12678.5, 18412.7, 26866.4, 32685.3,
18690.8, 6924.7, 19723.2, 19365.2), BRRWT9 = c(5403, 6616.4,
38550.9, 18910.6, 8263.6, 34548.4, 27477.9, 6676.5, 5853.1, 69789.9
), BRRWT10 = c(17569.6, 7260.4, 10754.5, 6621.4, 8210.5, 33987.8,
84209.8, 23981.8, 6368.9, 64151.3), BRRWT11 = c(16621, 21417,
44738.6, 20070.6, 8292.4, 14716.9, 22968.8, 23687.5, 7158.6,
22341.6), BRRWT12 = c(18815.8, 21356.5, 36050.6, 23333.1, 25607.7,
32993.5, 24615.3, 24816.2, 22569.4, 67045.8), BRRWT13 = c(5660.4,
7196.1, 12305.6, 18647.6, 24152.6, 36403.8, 61313.4, 22493.8,
22462.3, 19394.3), BRRWT14 = c(20846.4, 8036.6, 36765.3, 5191.9,
25632.3, 34958.6, 24262.1, 6726.5, 22151.8, 77443.7), BRRWT15 = c(7251.4,
21021.6, 10564.8, 17992.9, 27171.8, 14994.7, 55610, 25790, 19986.2,
83486.3), BRRWT16 = c(6305.8, 6465.2, 10107.8, 5299.3, 7484.6,
33526.7, 31353, 24029.8, 7626.1, 75868), BRRWT17 = c(17556.9,
7067.4, 10337, 5938.8, 24470.2, 15120.5, 22056.8, 6785.7, 23286.2,
17688.3), BRRWT18 = c(5502.9, 19909.7, 40280.8, 4850.4, 8446.1,
14267, 21275.6, 26481.6, 6040, 22775.7), BRRWT19 = c(17874.9,
7107.3, 11448.9, 21861.2, 7888.2, 14766.8, 74685.1, 7270.7, 6770.2,
21210.8), BRRWT20 = c(17451.2, 19018.8, 12917.4, 18002.6, 8830.7,
32376.9, 80576.5, 6998.6, 7081.4, 74481), TOTALDOL = c(1406.1,
1366, 2828.8, 2103, 910.9, 1040, 1015.2, 2384.1, 2485, 1973.7
)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"
))
recs_des <- recs %>%
as_survey_rep(weights=NWEIGHT,
repweights=starts_with("BRRWT"),
type="Fay",
rho=0.5,
mse=TRUE)
### no output?
recs_des %>%
summarize(
Spent=survey_quantile(
x = TOTALDOL,
quantiles = c(.25, .75),
vartype = "ci"
)
)
#> [1] Spent_q25 Spent_q75 Spent_q25_low Spent_q75_low Spent_q25_upp
#> [6] Spent_q75_upp
#> <0 rows> (or 0-length row.names)
recs_des %>%
summarize(
Spent=survey_quantile(
x = TOTALDOL,
quantiles = c(.25, .75),
vartype = "se"
)
)
#> Spent_q25 Spent_q75 Spent_q25_se Spent_q75_se
#> 1 999.7143 2068.924 20.65815 399.1772
recs_des %>%
summarize(
Spent=survey_mean(
x = TOTALDOL,
vartype = "ci"
)
)
#> Spent Spent_low Spent_upp
#> 1 1674.696 1110.019 2239.373
Created on 2021-03-07 by the reprex package (v1.0.0)