diff --git a/README.Rmd b/README.Rmd index a379951..636f9b1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -94,7 +94,7 @@ p

-```{r courses_grouped_bar_chart, fig.height=3.3, out.width = "100%", echo = FALSE, fig.alt="Courses grouped bar chart"} +```{r courses_grouped_bar_chart, fig.height=3.3, out.width = "80%", echo = FALSE, fig.alt="Courses grouped bar chart"} knitr::include_graphics("./man/figures/articles/courses_grouped_bar_chart.svg") ``` @@ -191,7 +191,7 @@ p

-```{r courses_stacked_bar_chart, fig.height=5.6, out.width = "100%", echo = FALSE, fig.alt="Courses stacked bar chart"} +```{r courses_stacked_bar_chart, fig.height=5.6, out.width = "80%", echo = FALSE, fig.alt="Courses stacked bar chart"} knitr::include_graphics("./man/figures/articles/courses_stacked_bar_chart.svg") ``` @@ -270,7 +270,7 @@ new_items_F <- get_responses(n = nrow(items_F), To compare the results, we can plot the correlation matrix with bar charts on the diagonal: -```{r agree_items_correlations_comparison, fig.height=10, out.width = "100%", echo = FALSE, fig.alt="Agreeableness items correlations comparison"} +```{r agree_items_correlations_comparison, fig.height=10, out.width = "80%", echo = FALSE, fig.alt="Agreeableness items correlations comparison"} knitr::include_graphics("./man/figures/articles/agree_items_correlations_comparison.svg") ``` @@ -312,7 +312,7 @@ plot_grid(p1, p2, nrow = 2)

-```{r agreeableness_grouped_boxplot, fig.height=4.8, out.width = "100%", echo = FALSE, fig.alt="Agreeableness items grouped boxplot"} +```{r agreeableness_grouped_boxplot, fig.height=4.8, out.width = "80%", echo = FALSE, fig.alt="Agreeableness items grouped boxplot"} knitr::include_graphics("./man/figures/articles/agreeableness_grouped_boxplot.svg") ``` diff --git a/README.md b/README.md index 56358ea..48bfefa 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ p

-Courses grouped bar chart +Courses grouped bar chart For a pre- and post comparison, suppose that the participants completed the survey both before and after taking the course. And suppose that @@ -213,7 +213,7 @@ p

-Courses stacked bar chart +Courses stacked bar chart ### Replicating survey data @@ -475,7 +475,7 @@ new_items_F <- get_responses(n = nrow(items_F), To compare the results, we can plot the correlation matrix with bar charts on the diagonal: -Agreeableness items correlations comparison +Agreeableness items correlations comparison The next step would be to create agreeableness scale scores for both groups of participants, by taking the average of these 5 items and @@ -520,7 +520,7 @@ plot_grid(p1, p2, nrow = 2)

-Agreeableness items grouped boxplot +Agreeableness items grouped boxplot ## Dependency statement diff --git a/docs/articles/replicating_survey_data.html b/docs/articles/replicating_survey_data.html index 7caef88..32412e2 100644 --- a/docs/articles/replicating_survey_data.html +++ b/docs/articles/replicating_survey_data.html @@ -276,9 +276,11 @@

Reproducing item responses p3 <- corr_plot(items_F, "Agreeableness items for women") p4 <- corr_plot(new_items_F, "Reproduced agreeableness items for women") -p <- plot_grid(ggmatrix_gtable(p1), ggmatrix_gtable(p2), ggmatrix_gtable(p3), ggmatrix_gtable(p4), ncol = 2) -ggsave(file="./man/figures/articles/agree_items_correlations_comparison.svg", plot=p, width=10, height=10) -

Agreeableness items correlations comparison

+p <- plot_grid(ggmatrix_gtable(p1), ggmatrix_gtable(p2), ggmatrix_gtable(p3), + ggmatrix_gtable(p4), ncol = 2) +ggsave(file="./man/figures/articles/agree_items_correlations_comparison.svg", + plot=p, width=10, height=10) +

Agreeableness items correlations comparison

Recreating scale scores @@ -323,8 +325,9 @@

Recreating scale scoresp1 <- scale_boxplot(data, "Agreeableness in men and women") p2 <- scale_boxplot(new_data, "Reproduced agreeableness in men and women") p <- plot_grid(p1, p2, nrow = 2) -ggsave(file="./man/figures/articles/agreeableness_grouped_boxplot.svg", plot=p, width=10, height=4.8)

-

Agreeableness items grouped boxplot

+ggsave(file="./man/figures/articles/agreeableness_grouped_boxplot.svg", + plot=p, width=10, height=4.8) +

Agreeableness items grouped boxplot

Finally, let’s also run Welch’s t-test to test if men and women differ on agreeableness using both data sets:

diff --git a/docs/articles/simulating_survey_data.html b/docs/articles/simulating_survey_data.html
index 00c211e..afb8ebf 100644
--- a/docs/articles/simulating_survey_data.html
+++ b/docs/articles/simulating_survey_data.html
@@ -270,8 +270,9 @@ 

Comparison of introductor legend.title = element_blank(), plot.title = element_text(size=16)) -ggsave(file="./man/figures/articles/courses_grouped_bar_chart.svg", plot=p, width=10, height=3.3)

-

Courses grouped bar chart

+ggsave(file="./man/figures/articles/courses_grouped_bar_chart.svg", + plot=p, width=10, height=3.3) +

Courses grouped bar chart

Pre and post comparison @@ -315,8 +316,9 @@

Pre and post comparison Course = c(rep("Course A", items * K), rep("Course B", items * K)), Question = questions, Time = as.factor(rep(c(rep("before", 3*K), rep("after", 3*K)), 2)), - resp = rep(rep(1:K, 3), length(data)), - prop = as.vector(sapply(data, function(d) as.vector(t(get_prop_table(d, K)))))) + resp = rep(rep(seq_len(K), 3), length(data)), + prop = as.vector(sapply(data, function(d) { + as.vector(t(get_prop_table(d, K))) }))) head(data) #> Course Question Time resp prop #> 1 Course A Programming before 1 0.5 @@ -351,7 +353,8 @@

Pre and post comparison strip = strip_nested(size = "variable"), labeller = labeller(Question = label_wrap_gen(width = 10)) ) + - ggtitle("On a scale of 1 = Very poor to 5 = Very good, how would you rate your skills?") + + ggtitle("On a scale of 1 = Very poor to 5 = Very good, + how would you rate your skills?") + theme_bw() + theme(strip.placement = "outside") + theme( @@ -370,10 +373,12 @@

Pre and post comparison breaks = seq(from = -1, to = 1, by = 0.5), labels = c(100, 50, 0, 50, 100)) + scale_fill_manual("", breaks = 1:5, values = color_palette, - labels = c("Very poor", "Poor", "Fair", "Good", "Very good")) + labels = c("Very poor", "Poor", + "Fair", "Good", "Very good")) -ggsave(file="./man/figures/articles/courses_stacked_bar_chart.svg", plot=p, width=10, height=5.6)

-

Courses stacked bar chart

+ggsave(file="./man/figures/articles/courses_stacked_bar_chart.svg", + plot=p, width=10, height=5.6) +

Courses stacked bar chart

References diff --git a/docs/index.html b/docs/index.html index 4fd3ced..6f5d4bf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -169,7 +169,7 @@

Simulating survey datap

-

Courses grouped bar chart

+

Courses grouped bar chart

For a pre- and post comparison, suppose that the participants completed the survey both before and after taking the course. And suppose that participants’ assessments of their skills in:

  1. Programming on average increased,
  2. @@ -256,7 +256,7 @@

    Simulating survey datap

    -

    Courses stacked bar chart

    +

    Courses stacked bar chart

    Replicating survey data @@ -483,7 +483,7 @@

    Replicating survey data K = 6, R = cor(items_F))

    To compare the results, we can plot the correlation matrix with bar charts on the diagonal:

    -

    Agreeableness items correlations comparison

    +

    Agreeableness items correlations comparison

    The next step would be to create agreeableness scale scores for both groups of participants, by taking the average of these 5 items and visualize the results with a grouped boxplot:
    Click here to expand
    @@ -517,7 +517,7 @@ 

    Replicating survey dataplot_grid(p1, p2, nrow = 2)

    -

    Agreeableness items grouped boxplot

    +

    Agreeableness items grouped boxplot

    @@ -555,9 +555,7 @@

    Links

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 4cb52d9..f74e7e5 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -6,7 +6,7 @@ articles: replicating_survey_data: replicating_survey_data.html responsesR: responsesR.html simulating_survey_data: simulating_survey_data.html -last_built: 2024-06-06T10:37Z +last_built: 2024-06-06T16:54Z urls: reference: https://markolalovic.github.io/responsesR/reference article: https://markolalovic.github.io/responsesR/articles diff --git a/docs/reference/estimate_parameters.html b/docs/reference/estimate_parameters.html index 24b761a..0662668 100644 --- a/docs/reference/estimate_parameters.html +++ b/docs/reference/estimate_parameters.html @@ -77,7 +77,7 @@

    Estimate parameters

    Arguments

    data
    -

    survey responses, where the columns correspond to individual items. +

    responses, where the columns correspond to individual items. Apart from this, `data` can be of almost any class such as "data.frame" "matrix" or "array".

    diff --git a/docs/reference/get_responses.html b/docs/reference/get_responses.html index 4c211fc..6a1ed0c 100644 --- a/docs/reference/get_responses.html +++ b/docs/reference/get_responses.html @@ -1,5 +1,5 @@ -Get responses — get_responses • responsesRGet responses — get_responses • responsesR @@ -65,7 +65,7 @@

    Get responses

    -

    Generates a sample of random responses based on parameters of latent variables.

    +

    Returns a sample of random responses based on parameters of latent variables.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 481ab0b..d8ae83b 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -110,10 +110,6 @@

    All functions get_pk_mean()

    Calculate the mean of `pk`

    - -

    get_pk_var()

    - -

    Calculate variance of probabilities `pk`

    get_prop_table()

    diff --git a/docs/reference/run_Lloyd.html b/docs/reference/run_Lloyd.html index 2843996..57f4bef 100644 --- a/docs/reference/run_Lloyd.html +++ b/docs/reference/run_Lloyd.html @@ -1,5 +1,5 @@ -Implementation of Lloyd's algorithm — run_Lloyd • responsesRImplementation of Lloyd's algorithm — run_Lloyd • responsesR