Skip to content

Commit

Permalink
Revised the articles (mainly, 07-explore.Rmd)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhoriuchi committed Aug 16, 2023
1 parent 774e8a6 commit b2d0e1b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
3 changes: 2 additions & 1 deletion data-raw/read_save_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ out1 <- reshape_projoint(.dataframe = exampleData1,
.outcomes_ids = c("A", "B"),
.alphabet = "K",
.repeated = TRUE,
.flipped = TRUE)
.flipped = TRUE,
.fill = TRUE)

save_labels(out1, "data-raw/labels_original.csv")
out1_arranged <- read_labels(out1, "data-raw/labels_arranged.csv")
Expand Down
Binary file modified data/out1_arranged.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion vignettes/02-wrangle.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ out1 <- reshape_projoint(.dataframe = exampleData1,
.fill = FALSE)
```

Let's walk through the arguments we have specified. `.dataframe` is a data frame, ideally read in from Qualtrics using `read_Qualtrics()` but not necessarily. The `.idvar` argument, a character, indicates that in `exampleData1`, the column `ResponseId` indicates unique survey respondents. The `.outcomes` variable lists all the columns that are outcomes; the last element in this vector is the repeated task (if it was conducted). `.outcomes_ids` indicates the possible options for an outcome; specifically, it is a vector of characters with two elements, which are the last characters of the names of the first and second profiles. For example, it should be c("A", "B") if the profile names are "Candidate A" and "Candidate B". This character vector can be anything, such as c("1", "2"), c("a", "b"), etc. *If you have multiple tasks in your design, you should use the same profile names across all these tasks*. `.alphabet` defaults to "K" if the conjoint survey was conducted using either our tool or Strezhnev's [Conjoint Survey Design Tool](https://github.com/astrezhnev/conjointsdt). The final two arguments, `.repeated` and `.flipped`, again relate to the repeated task. If the `.repeated` is set to `TRUE`, then the last element of the `.outcomes` vector is taken to be a repetition of the first task; `.flipped` indicates whether the profiles are in the reversed order.
Let's walk through the arguments we have specified. `.dataframe` is a data frame, ideally read in from Qualtrics using `read_Qualtrics()` but not necessarily. The `.idvar` argument, a character, indicates that in `exampleData1`, the column `ResponseId` indicates unique survey respondents. The `.outcomes` variable lists all the columns that are outcomes; the last element in this vector is the repeated task (if it was conducted). `.outcomes_ids` indicates the possible options for an outcome; specifically, it is a vector of characters with two elements, which are the last characters of the names of the first and second profiles. For example, it should be c("A", "B") if the profile names are "Candidate A" and "Candidate B". This character vector can be anything, such as c("1", "2"), c("a", "b"), etc. *If you have multiple tasks in your design, you should use the same profile names across all these tasks*. `.alphabet` defaults to "K" if the conjoint survey was conducted using either our tool or Strezhnev's [Conjoint Survey Design Tool](https://github.com/astrezhnev/conjointsdt). The final two arguments, `.repeated` and `.flipped`, again relate to the repeated task. If the `.repeated` is set to `TRUE`, then the last element of the `.outcomes` vector is taken to be a repetition of the first task; `.flipped` indicates whether the profiles are in the reversed order. See Section 2.3 for `.fill`.

#### With the not-flipped repeated tasks

Expand Down
72 changes: 68 additions & 4 deletions vignettes/07-explore.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,78 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

The choice-level analysis will allow reserachers to examine many more questions under-investigated in the litearture. This article explains some possible avenues for fruitful research.
The choice-level analysis will allow researchers to examine many more questions under-investigated in the literature. This article explains some possible avenues for fruitful research.

### 6.1 Examine trade-offs
### 7.1 Load the projoint package and the other necessary package

To be written
```{r}
library(projoint)
library(ggplot2)
```

As in the previous articles, we use the already wrangled and cleaned data named "out1_reshaped." To see what the attribute IDs and level IDs means, you can type:
```{r}
out1_arranged@labels
```


### 7.1 Examine trade-offs

You may be interested in how people make a choice when they face trade-off options. For example, on the one hand, they may want to live in an inexpensive house. On the other hand, they may prefer to avoid living in an area with a high crime rate. Which of these two options would they prefer? You can compare these two options directly. For the customization of the figure, see [Visualize MMs or AMCEs, Choice-level analysis](https://yhoriuchi.github.io/projoint/articles/05-visualize.html#choice-level-analysis)

```{r, fig.height=4, fig.width=8}
qoi_1 <- set_qoi(
.structure = "choice_level",
.att_choose = "att1",
.lev_choose = "level1",
.att_notchoose = "att6",
.lev_notchoose = "level2"
)
mm1 <- projoint(.data = out1_arranged,
.qoi = qoi_1,
.structure = "choice_level",
.ignore_position = TRUE)
plot(mm1,
.labels = c("Housing Cost\n(15% of pre-tax income)",
"Violent Crime Rate\n(20% > National Average)")) +
labs(y = "Marginal mean",
x = NULL) +
coord_cartesian(ylim = c(0, 1)) +
geom_hline(yintercept = 0.5,
linetype = "dashed",
color = "darkgray")
```

### 6.1 Set multiple levels for the attribute of interest

To be written
You may be interested in measuring the marginal means of choosing more than one level. For example, you may want to estimate the marginal mean of choosing "City, more residential area" OR "City, downtown area" as opposed to "Suburban, only houses" OR "Suburban, downtown area". Then, you can run the following code:

```{r, fig.height=4, fig.width=8}
qoi_2 <- set_qoi(
.structure = "choice_level",
.att_choose = "att7",
.lev_choose = c("level2", "level3"),
.att_notchoose = "att7",
.lev_notchoose = c("level5", "level6")
)
mm2 <- projoint(.data = out1_arranged,
.qoi = qoi_2,
.structure = "choice_level",
.ignore_position = TRUE)
plot(mm2,
.labels = c("City", "Suburban")) +
labs(y = "Marginal mean",
x = "Type of place") +
coord_cartesian(ylim = c(0, 1)) +
geom_hline(yintercept = 0.5,
linetype = "dashed",
color = "darkgray")
```



0 comments on commit b2d0e1b

Please sign in to comment.