Skip to content

Commit

Permalink
Minor edits of vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
yhoriuchi committed Aug 8, 2023
1 parent 2c18aa4 commit 92a1c91
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
11 changes: 8 additions & 3 deletions vignettes/05-visualize.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ vignette: >

The `projoint` package features a set of tools for producing publication-ready figures from conjoint analyses.


### 5.1 Load the projoint package

```{r}
library(projoint)
```

### 5.2 Estimate MMs and AMCEs.
### 5.2 Profile-level analysis

#### Estimate MMs and AMCEs.

```{r}
mm <- projoint(out1_arranged)
amce <- projoint(out1_arranged, .estimand = "amce")
```

### 5.3 Visualize MMs and AMCEs
#### Visualize MMs and AMCEs

By default, most researchers should prefer to view the corrected estimates of either MMs or AMCEs. Researchers can, however, choose to instead visualize the uncorrected estimates, or to view both together.

Expand All @@ -40,3 +41,7 @@ plot_projoint(amce, .estimand = "amce")
plot_projoint(amce, .estimand = "amce", .estimates = "uncorrected")
plot_projoint(amce, .estimand = "amce", .estimates = "both")
```

### 5.3 Choice-level analysis

To be written.
28 changes: 24 additions & 4 deletions vignettes/06-compare.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ library(dplyr)
library(ggplot2)
```

### 6.2 Read and Wrangle data
### 6.2 Profile-level analysis

#### Read and Wrangle data

To begin, define the outcome questions in the original dataset.

Expand Down Expand Up @@ -79,20 +81,33 @@ df_1 <- read_labels(df_1, "../data-raw/labels_arranged.csv")
df_d <- read_labels(df_d, "../data-raw/labels_arranged.csv")
```

### 6.3 Estimate MMs or AMCEs and the difference in the estimates
#### Estimate MMs or AMCEs and the difference in the estimates

For each of the three data frames, estimate the MMs, AMCEs, or the differences in these estimates. The following example estimate profile-level marginal means (default).
```{r}
out_0 <- projoint(df_0)
out_1 <- projoint(df_1)
out_d <- projoint(df_d, .by_var = "white")
```

Importantly, if your conjoint design includes the repeated task, the `projoint()` function applied to each subgroup will estimate IRR for the corresponding subgroup. The output of `out_d` includes the data for these differences
```{r}
out_d@estimates
```

You can also check `tau` for each subgroup:
```{r}
out_d@tau
```
Then, make and save three ggplot objects.

```{r}
plot_0 <- plot_projoint(out_0)
plot_1 <- plot_projoint(out_1)
plot_d <- plot_projoint(out_d, .by_var = TRUE)
```

### 6.4 Visualize subgroup differences
#### Visualize subgroup differences

Then, make a plot using the `patchwork` package. Researchers can add/modify layers of each ggplot. The default horizontal axis label is "Difference" if `.by_var = TRUE` is specified in the `plot_projoint()` function.

Expand Down Expand Up @@ -121,4 +136,9 @@ g_d <- plot_d +
library(patchwork)
g_0 + g_1 + g_d
```
```

### 6.3 Choice-level analysis

To be written.

0 comments on commit 92a1c91

Please sign in to comment.