Skip to contents
dummy <- dummy_data()

schema_pop <- proto_schema(dummy$pop, dummy$survey$place_type, type = "ideal")
schema_inc <- ssu_schema(
  "<=1000" = c(-Inf, 1000),
  "1001-2000" = c(1001, 2000),
  "2001-3000" = c(2001, 3000),
  "3001-4000" = c(3001, 4000),
  ">4000" = c(4001, Inf),
  adj_threshold = TRUE
)

wt_strata(
  dummy$survey,
  weights = list(
    place_type = dummy$pop,
    income = dummy$income
  ),
  psu = dummy$areas,
  ssu = dummy$survey[c("place_type", "income")],
  schema = list(
    place_type = schema_pop,
    income = schema_inc
  )
)
#> Warning: ! Composite weight surfaces do not overlap for at least one SSU combination.
#>   Falling back to the union of individual surfaces.
#>  If this is not the desired behavior, you can try the following:
#>   - Set `composition = "sequential"` and use relative schemas
#>   - Broaden the schema thresholds
#> Simple feature collection with 50 features and 2 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -0.4926006 ymin: -0.472044 xmax: 4.496891 ymax: 4.406297
#> Projected CRS: PROJCRS["unknown",
#>     BASEGEOGCRS["unknown",
#>         DATUM["Unknown based on WGS 84 ellipsoid",
#>             ELLIPSOID["WGS 84",6378137,298.257223563,
#>                 LENGTHUNIT["metre",1],
#>                 ID["EPSG",7030]]],
#>         PRIMEM["Greenwich",0,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8901]]],
#>     CONVERSION["unknown",
#>         METHOD["Transverse Mercator",
#>             ID["EPSG",9807]],
#>         PARAMETER["Latitude of natural origin",0,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8801]],
#>         PARAMETER["Longitude of natural origin",0,
#>             ANGLEUNIT["degree",0.0174532925199433],
#>             ID["EPSG",8802]],
#>         PARAMETER["Scale factor at natural origin",1,
#>             SCALEUNIT["unity",1],
#>             ID["EPSG",8805]],
#>         PARAMETER["False easting",0,
#>             LENGTHUNIT["metre",1],
#>             ID["EPSG",8806]],
#>         PARAMETER["False northing",0,
#>             LENGTHUNIT["metre",1],
#>             ID["EPSG",8807]]],
#>     CS[Cartesian,2],
#>         AXIS["(E)",east,
#>             ORDER[1],
#>             LENGTHUNIT["metre",1,
#>                 ID["EPSG",9001]]],
#>         AXIS["(N)",north,
#>             ORDER[2],
#>             LENGTHUNIT["metre",1,
#>                 ID["EPSG",9001]]]]
#> First 10 features:
#>    place_type    income                       geometry
#> 1     Village 3001-4000     POINT (3.778597 -0.471939)
#> 2     Village 3001-4000      POINT (3.946702 1.965987)
#> 3     Village 1001-2000     POINT (0.993637 0.2133973)
#> 4        City    <=1000 POINT (0.6572084 -0.002222611)
#> 5     Village 2001-3000      POINT (1.070045 1.096263)
#> 6     Village    <=1000    POINT (1.160284 -0.4039758)
#> 7        City    <=1000  POINT (-0.4926006 -0.2102328)
#> 8        Town 3001-4000  POINT (4.180163 -0.001154389)
#> 9     Village     >4000      POINT (3.490712 1.889183)
#> 10       City    <=1000     POINT (0.9663935 0.232882)