# Suggestions for the design of Survey.jl?

**URL:** <https://discourse.julialang.org/t/suggestions-for-the-design-of-survey-jl/86381>\
**Category:** Statistics\
**Tags:** survey\
**Created:** [August 26, 2022, 1:38pm UTC](https://discourse.julialang.org/t/suggestions-for-the-design-of-survey-jl/86381 "2022-08-26T13:38:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iuliadmtru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iuliadmtru/32/39126_2.png) [@iuliadmtru](https://discourse.julialang.org/u/iuliadmtru)\
**Post date:** [August 26, 2022, 1:38pm UTC](https://discourse.julialang.org/t/suggestions-for-the-design-of-survey-jl/86381/1 "2022-08-26T13:38:01Z")

</div>

Hello,

[We](https://github.com/xKDR) are building [`Survey.jl`](https://github.com/xKDR/Survey.jl), a package for statistical estimates from surveys. The inspiration for the package comes from the corresponding [R `survey` package](https://CRAN.R-project.org/package=survey) created by Thomas Lumley.

We started out imitating the R API to make the transition from R to Julia easier. Along the way we decided to switch to [a more Julia-specific design](https://github.com/xKDR/Survey.jl/issues/40) while still addressing the transition problem by using wrappers for the R-like API or documentation notes. The Julia way, emphasising multiple dispatch, yields clean code and opens the way for bazaar-style development of sub-components by multiple different people.

In the R world there is an entire ecosystem that has arisen on top of the survey package, such as [`srvyr`](https://CRAN.R-project.org/package=srvyr) or [`svrepmisc`](https://rdrr.io/github/carlganz/svrepmisc/). We hope to accomplish the same kind of growth with our package. This is why we bring forward this discussion regarding the design that should be adopted for Survey.jl. The key questions are:

- How can we make the transition from R to Julia easier?
- How can the current design be improved to provide a good user experience?
- Can we improve on the R package in terms of functionality?

Any involvement and suggestion would be of great help, particularly if you have experience with statistics and/or survey analysis.

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [August 26, 2022, 2:49pm UTC](https://discourse.julialang.org/t/suggestions-for-the-design-of-survey-jl/86381/2 "2022-08-26T14:49:42Z")

</div>

Nice to hear that you are working on designing a Julian API for that nice package!

My general recommendation would be to try to move as much as possible from using `svy`-prefixed functions to using generic Julia functions dispatching on Survey.jl objects. For example, `svyglm` could be replaced with a special `glm` method when `data` is a survey design object.

I had also mentioned some ideas about replacing `svyby` with `combine(groupby(...), ...)` at [https://github.com/xKDR/Survey.jl/issues/4](https://github.com/xKDR/Survey.jl/issues/4).

One area where you can probably improve on the R package quite easily is that, at least for designs with replicate weights, thanks to the [`StatisticalModel`](https://github.com/JuliaStats/StatsAPI.jl/blob/main/src/statisticalmodel.jl)/[`RegressionModel`](https://github.com/JuliaStats/StatsAPI.jl/blob/main/src/regressionmodel.jl) interface from StatsAPI, you could support fitting any custom model type defined in a package by calling `fit` on it with each set of weights and computing standard errors for coefficients automatically based on the coefficients obtained with each set. IIUC this would offer the features of svrepmisc, but also extend it automatically to any new model family, without Survey.jl having to support it explicitly. This is an area where R is often lacking (everything is hardcoded, making it hard to extend to new use cases).

---

<div class="post-metadata">

**Author:** ![PharmCat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pharmcat/32/6953_2.png) [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Post date:** [August 26, 2022, 8:55pm UTC](https://discourse.julialang.org/t/suggestions-for-the-design-of-survey-jl/86381/3 "2022-08-26T20:55:58Z")

</div>

Hi! I’m currently not a Survey.jl user (don’t use R too), but when I opened documentation, I saw than it hard to understand exactly what package do without using R documentation. I think, it will be useful if you add documentation about package purpose and functionalities for only-Julia-users.

---

<div class="post-metadata">

**Author:** ![Eric](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eric/32/25565_2.png) [@Eric](https://discourse.julialang.org/u/Eric)\
**Post date:** [August 28, 2022, 8:18pm UTC](https://discourse.julialang.org/t/suggestions-for-the-design-of-survey-jl/86381/4 "2022-08-28T20:18:05Z")

</div>

For the ones coming from SAS, it would be useful to have some links to the main procedures (packages in the Julia/R parlance). I don’t think it is necessary to have fully worked out code examples but high-level directions like “if you were doing regression with surveyreg, then look into XYZ”.  
The main SAS procedures are [here](https://support.sas.com/rnd/app/stat/procedures/SurveyAnalysis.html).
