Skip to content

Commit

Permalink
Making example code in readme easier to read.
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Chlebicki committed Nov 23, 2023
1 parent 6a6559e commit 79d924d
Show file tree
Hide file tree
Showing 2 changed files with 533 additions and 35 deletions.
261 changes: 244 additions & 17 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,253 @@ possible scenarios:

### When unit-level data is available for non-probability survey only

| Estimator | Example code |
|-------------------|-----------------------------------------------------|
| Mass imputation based on regression imputation | `` nonprob(outcome = y ~ x1 + x2 + ... + xk, data = nonprob, pop_totals = c(`(Intercept)`=N, x1=tau_x1, x2=tau_x2, ..., xk=tau_xk), method_outcome = "glm", family_outcome = "gaussian") `` |
| Inverse probability weighting | `` nonprob(selection = ~ x1 + x2 + ... + xk, target = ~ y, data = nonprob, pop_totals = c(`(Intercept)`=N, x1=tau_x1, x2=tau_x2, ..., xk=tau_xk), method_selection = "logit") `` |
| Inverse probability weighting with calibration constraint | `` nonprob(selection = ~ x1 + x2 + ... + xk, target = ~ y, data = nonprob, pop_totals = c(`(Intercept)`=N, x1=tau_x1, x2=tau_x2, ..., xk=tau_xk), method_selection = "logit", control_selection = controlSel(est_method_sel = "gee", h = 1)) `` |
| Doubly robust estimator | `` nonprob(selection = ~ x1 + x2 + ... + xk, outcome = y ~ x1 + x2 + …, + xk, pop_totals = c(`(Intercept)`=N, x1=tau_x1, x2=tau_x2, ..., xk=tau_xk), svydesign = prob, method_outcome = "glm", family_outcome = "gaussian") `` |
<table class='table'>
<tr> <th>Estimator</th> <th>Example code</th> <tr>
<tr>
<td>
Mass imputation based on regression imputation
</td>
<td>
```{r, eval = FALSE}
nonprob(
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
pop_totals = c(`(Intercept)`= N,
x1 = tau_x1,
x2 = tau_x2,
...,
xk = tau_xk),
method_outcome = "glm",
family_outcome = "gaussian"
)
```
</td>
<tr>
<tr>
<td>
Inverse probability weighting
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
target = ~ y,
data = nonprob,
pop_totals = c(`(Intercept)` = N,
x1 = tau_x1,
x2 = tau_x2,
...,
xk = tau_xk),
method_selection = "logit"
)
```
</td>
<tr>
<tr>
<td>
Inverse probability weighting with calibration constraint
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
target = ~ y,
data = nonprob,
pop_totals = c(`(Intercept)`= N,
x1 = tau_x1,
x2 = tau_x2,
...,
xk = tau_xk),
method_selection = "logit",
control_selection = controlSel(est_method_sel = "gee", h = 1)
)
```
</td>
<tr>
<tr>
<td>
Doubly robust estimator
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
outcome = y ~ x1 + x2 + …, + xk,
pop_totals = c(`(Intercept)` = N,
x1 = tau_x1,
x2 = tau_x2,
...,
xk = tau_xk),
svydesign = prob,
method_outcome = "glm",
family_outcome = "gaussian"
)
```
</td>
<tr>
</table>

### When unit-level data are available for both surveys

| Estimator | Example code |
|----------------------|--------------------------------------------------|
| Mass imputation based on regression imputation | `nonprob(outcome = y ~ x1 + x2 + ... + xk, data = nonprob, svydesign = prob, method_outcome = "glm", family_outcome = "gaussian")` |
| Mass imputation based on nearest neighbour imputation | `nonprob(outcome = y ~ x1 + x2 + ... + xk, data = nonprob, svydesign = prob, method_outcome = "nn", family_outcome = "gaussian", control_outcome=controlOutcome(k = 2))` |
| Mass imputation based on predictive mean matching | `nonprob(outcome = y ~ x1 + x2 + ... + xk, data = nonprob, svydesign = prob, method_outcome = "pmm", family_outcome = "gaussian")` |
| Mass imputation based on regression imputation with variable selection (LASSO) | `nonprob(outcome = y ~ x1 + x2 + ... + xk, data = nonprob, svydesign = prob, method_outcome = "pmm", family_outcome = "gaussian", control_outcome=controlOut(penalty = "lasso"), control_inference = controlInf(vars_selection = TRUE))` |
| Inverse probability weighting | `nonprob(selection = ~ x1 + x2 + ... + xk, target = ~ y, data = nonprob, svydesign = prob, method_selection = "logit")` |
| Inverse probability weighting with calibration constraint | `nonprob(selection = ~ x1 + x2 + ... + xk, target = ~ y, data = nonprob, svydesign = prob, method_selection = "logit", control_selection = controlSel(est_method_sel = "gee", h = 1))` |
| Inverse probability weighting with calibration constraint with variable selection (SCAD) | `nonprob(selection = ~ x1 + x2 + ... + xk, target = ~ y, data = nonprob, svydesign = prob, method_outcome = "pmm", family_outcome = "gaussian", control_inference = controlInf(vars_selection = TRUE))` |
| Doubly robust estimator | `nonprob(selection = ~ x1 + x2 + ... + xk, outcome = y ~ x1 + x2 + …, + xk, data = nonprob, svydesign = prob, method_outcome = "glm", family_outcome = "gaussian")` |
| Doubly robust estimator with variable selection (SCAD) and bias minimization | `nonprob(selection = ~ x1 + x2 + ... + xk, outcome = y ~ x1 + x2 + …, + xk, data = nonprob, svydesign = prob, method_outcome = "glm", family_outcome = "gaussian", , control_inference = controlInf(vars_selection = TRUE, bias_correction = TRUE))` |
<table class='table'>
<tr> <th>Estimator</th> <th>Example code</th> <tr>
<tr>
<td>
Mass imputation based on regression imputation
</td>
<td>
```{r, eval = FALSE}
nonprob(
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
svydesign = prob,
method_outcome = "glm",
family_outcome = "gaussian"
)
```
</td>
<tr>
<tr>
<td>
Mass imputation based on nearest neighbour imputation
</td>
<td>
```{r, eval = FALSE}
nonprob(
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
svydesign = prob,
method_outcome = "nn",
family_outcome = "gaussian",
control_outcome = controlOutcome(k = 2)
)
```
</td>
<tr>
<tr>
<td>
Mass imputation based on predictive mean matching
</td>
<td>
```{r, eval = FALSE}
nonprob(
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
svydesign = prob,
method_outcome = "pmm",
family_outcome = "gaussian"
)
```
</td>
<tr>
<tr>
<td>
Mass imputation based on regression imputation with variable selection (LASSO)
</td>
<td>
```{r, eval = FALSE}
nonprob(
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
svydesign = prob,
method_outcome = "pmm",
family_outcome = "gaussian",
control_outcome = controlOut(penalty = "lasso"),
control_inference = controlInf(vars_selection = TRUE)
)
```
</td>
<tr>
<tr>
<td>
Inverse probability weighting
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
target = ~ y,
data = nonprob,
svydesign = prob,
method_selection = "logit"
)
```
</td>
<tr>
<tr>
<td>
Inverse probability weighting with calibration constraint
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
target = ~ y,
data = nonprob,
svydesign = prob,
method_selection = "logit",
control_selection = controlSel(est_method_sel = "gee", h = 1)
)
```
</td>
<tr>
<tr>
<td>
Inverse probability weighting with calibration constraint with variable selection (SCAD)
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
target = ~ y,
data = nonprob,
svydesign = prob,
method_outcome = "pmm",
family_outcome = "gaussian",
control_inference = controlInf(vars_selection = TRUE)
)
```
</td>
<tr>
<tr>
<td>
Doubly robust estimator
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
svydesign = prob,
method_outcome = "glm",
family_outcome = "gaussian"
)
```
</td>
<tr>
<tr>
<td>
Doubly robust estimator with variable selection (SCAD) and bias minimization
</td>
<td>
```{r, eval = FALSE}
nonprob(
selection = ~ x1 + x2 + ... + xk,
outcome = y ~ x1 + x2 + ... + xk,
data = nonprob,
svydesign = prob,
method_outcome = "glm",
family_outcome = "gaussian",
control_inference = controlInf(
vars_selection = TRUE,
bias_correction = TRUE
)
)
```
</td>
<tr>
</table>

## Examples

Expand Down
Loading

0 comments on commit 79d924d

Please sign in to comment.