Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add subpopulation to printing of survey object #163

Open
szimmer opened this issue Jul 15, 2023 · 0 comments
Open

Feature request: add subpopulation to printing of survey object #163

szimmer opened this issue Jul 15, 2023 · 0 comments

Comments

@szimmer
Copy link
Contributor

szimmer commented Jul 15, 2023

Let's say I create two survey objects: dstrata and dstrata_mod where dstrata_mod is created by using filter to make a subpopulation. The printed objects look the same. It'd be nice to have some indicator that the filtering has been done.

library(srvyr)
#> 
#> Attaching package: 'srvyr'
#> The following object is masked from 'package:stats':
#> 
#>     filter

data(api, package="survey")

dstrata <- apistrat %>%
  as_survey_design(strata = stype, weights = pw)

dstrata
#> Stratified Independent Sampling design (with replacement)
#> Called via srvyr
#> Sampling variables:
#>  - ids: `1`
#>  - strata: stype
#>  - weights: pw
#> Data variables: cds (chr), stype (fct), name (chr), sname (chr), snum (dbl),
#>   dname (chr), dnum (int), cname (chr), cnum (int), flag (int), pcttest (int),
#>   api00 (int), api99 (int), target (int), growth (int), sch.wide (fct),
#>   comp.imp (fct), both (fct), awards (fct), meals (int), ell (int), yr.rnd
#>   (fct), mobility (int), acs.k3 (int), acs.46 (int), acs.core (int), pct.resp
#>   (int), not.hsg (int), hsg (int), some.col (int), col.grad (int), grad.sch
#>   (int), avg.ed (dbl), full (int), emer (int), enroll (int), api.stu (int), pw
#>   (dbl), fpc (dbl)

dstrata_filt <- dstrata %>%
  filter(stype=="E") 
dstrata_filt
#> Stratified Independent Sampling design (with replacement)
#> Called via srvyr
#> Sampling variables:
#>  - ids: `1`
#>  - strata: stype
#>  - weights: pw
#> Data variables: cds (chr), stype (fct), name (chr), sname (chr), snum (dbl),
#>   dname (chr), dnum (int), cname (chr), cnum (int), flag (int), pcttest (int),
#>   api00 (int), api99 (int), target (int), growth (int), sch.wide (fct),
#>   comp.imp (fct), both (fct), awards (fct), meals (int), ell (int), yr.rnd
#>   (fct), mobility (int), acs.k3 (int), acs.46 (int), acs.core (int), pct.resp
#>   (int), not.hsg (int), hsg (int), some.col (int), col.grad (int), grad.sch
#>   (int), avg.ed (dbl), full (int), emer (int), enroll (int), api.stu (int), pw
#>   (dbl), fpc (dbl)

Created on 2023-07-15 with reprex v2.0.2

Related SUDAAN example extract below with bold for emphasis for some ideas.

proc regress data=temp1 filetype=sas design = jackknife;
weight rakedw0;
jackwgts rakedw1--rakedw80 / adjjack=1;
model ae13 = ae14 racehpra;
subpopn srsex = 1;
subgroup racehpra;
levels 4;
run;
Number of observations read : 55428 Weighted count: 23847415
Observations in subpopulation : 23002 Weighted count: 11631728
Observations used in the analysis : 3744 Weighted count: 2522055
Denominator degrees of freedom : 80

Maximum number of estimable parameters for the model is 5
Weighted mean response is 3.133033

Multiple R-Square for the dependent variable AE13: 0.231226
Variance Estimation Method: Replicate Weight Jackknife
Working Correlations: Independent
Link Function: Identity
Response variable AE13: Number of drinks on the days drinking alcohol
For Subpopulation: SRSEX = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant