diff --git a/README.Rmd b/README.Rmd
index aca2ccb..1e2cd0e 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -131,7 +131,7 @@ Note that, depending on the value of the skewness parameter, the normal latent d
## Further Reading
-* For more detailed information and practical examples, please refer to the package [vignette](https://lalovic.io/latent2likert/articles/intro_to_latent2likert.html).
+* For more detailed information and practical examples, please refer to the package [vignette](https://lalovic.io/latent2likert/articles/using_latent2likert.html).
* The implemented algorithms are described in the functions [reference](https://lalovic.io/latent2likert/reference/index.html).
## Related R Packages
diff --git a/README.html b/README.html
index e9c1904..d3fe5c9 100644
--- a/README.html
+++ b/README.html
@@ -607,26 +607,26 @@
latent2likert
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
codecov
codecov
- unknown
- unknown
+ 96%
+ 96%
-
+
@@ -673,7 +673,7 @@ Using rlikert
Likert scale, use:
#library(latent2likert)
rlikert (size = 10 , n_items = 1 , n_levels = 5 )
-#> [1] 3 2 3 4 3 4 3 4 4 1
+#> [1] 2 4 3 4 5 3 3 3 4 3
To generate responses to multiple items with specified
parameters:
rlikert (size = 10 ,
@@ -683,16 +683,16 @@ Using rlikert
sd = c (0.8 , 1 , 1 ),
corr = 0.5 )
#> Y1 Y2 Y3
-#> [1,] 2 1 4
-#> [2,] 4 2 3
-#> [3,] 2 2 2
-#> [4,] 2 2 2
-#> [5,] 2 1 3
-#> [6,] 2 2 3
-#> [7,] 3 1 2
-#> [8,] 2 3 4
-#> [9,] 3 5 4
-#> [10,] 3 1 5
+#> [1,] 3 3 5
+#> [2,] 2 1 1
+#> [3,] 2 2 3
+#> [4,] 3 2 5
+#> [5,] 2 2 5
+#> [6,] 3 2 4
+#> [7,] 1 1 3
+#> [8,] 3 1 4
+#> [9,] 2 2 4
+#> [10,] 2 2 4
You can also provide a correlation matrix:
corr <- matrix (c (1.00 , - 0.63 , - 0.39 ,
- 0.63 , 1.00 , 0.41 ,
@@ -708,17 +708,17 @@ Using rlikert
and these estimates are typically lower:
cor (data)
#> Y1 Y2 Y3
-#> Y1 1.0000000 -0.5486188 -0.3592762
-#> Y2 -0.5486188 1.0000000 0.4172253
-#> Y3 -0.3592762 0.4172253 1.0000000
+#> Y1 1.0000000 -0.5271298 -0.3544365
+#> Y2 -0.5271298 1.0000000 0.4404984
+#> Y3 -0.3544365 0.4404984 1.0000000
Using estimate_params
Given the data, you can estimate the values of latent parameters
using:
estimate_params (data, n_levels = c (4 , 5 , 6 ), skew = 0 )
#> items
-#> estimates Y1 Y2 Y3
-#> mean 0.014663647 -1.009504893 0.004589209
-#> sd 0.775035961 0.955310905 1.018213994
+#> estimates Y1 Y2 Y3
+#> mean 0.02434619 -1.01561017 0.08093401
+#> sd 0.77743368 0.97395691 1.05227866
To visualize the transformation, you can use
plot_likert_transform()
. It plots the densities of latent
@@ -749,7 +749,7 @@
Further Reading
For more detailed information and practical examples, please refer
-to the package vignette .
+to the package vignette .
The implemented algorithms are described in the functions reference .
diff --git a/README.md b/README.md
index ca7533e..f3ba2ea 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,7 @@
[![R-CMD-check](https://github.com/markolalovic/latent2likert/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/markolalovic/latent2likert/actions/workflows/R-CMD-check.yaml)
-[![Codecov test
-coverage](https://codecov.io/gh/markolalovic/latent2likert/branch/main/graph/badge.svg)](https://app.codecov.io/gh/markolalovic/latent2likert?branch=main)
+[![codecov](https://codecov.io/gh/markolalovic/latent2likert/branch/main/graph/badge.svg?token=HZTG6RUB2J)](https://codecov.io/gh/markolalovic/latent2likert)
## Overview
@@ -65,7 +64,7 @@ scale, use:
``` r
#library(latent2likert)
rlikert(size = 10, n_items = 1, n_levels = 5)
-#> [1] 3 2 3 4 3 4 3 4 4 1
+#> [1] 2 4 3 4 5 3 3 3 4 3
```
To generate responses to multiple items with specified parameters:
@@ -78,16 +77,16 @@ rlikert(size = 10,
sd = c(0.8, 1, 1),
corr = 0.5)
#> Y1 Y2 Y3
-#> [1,] 2 1 4
-#> [2,] 4 2 3
-#> [3,] 2 2 2
-#> [4,] 2 2 2
-#> [5,] 2 1 3
-#> [6,] 2 2 3
-#> [7,] 3 1 2
-#> [8,] 2 3 4
-#> [9,] 3 5 4
-#> [10,] 3 1 5
+#> [1,] 3 3 5
+#> [2,] 2 1 1
+#> [3,] 2 2 3
+#> [4,] 3 2 5
+#> [5,] 2 2 5
+#> [6,] 3 2 4
+#> [7,] 1 1 3
+#> [8,] 3 1 4
+#> [9,] 2 2 4
+#> [10,] 2 2 4
```
You can also provide a correlation matrix:
@@ -111,9 +110,9 @@ these estimates are typically lower:
``` r
cor(data)
#> Y1 Y2 Y3
-#> Y1 1.0000000 -0.5486188 -0.3592762
-#> Y2 -0.5486188 1.0000000 0.4172253
-#> Y3 -0.3592762 0.4172253 1.0000000
+#> Y1 1.0000000 -0.5271298 -0.3544365
+#> Y2 -0.5271298 1.0000000 0.4404984
+#> Y3 -0.3544365 0.4404984 1.0000000
```
## Using `estimate_params`
@@ -123,9 +122,9 @@ Given the data, you can estimate the values of latent parameters using:
``` r
estimate_params(data, n_levels = c(4, 5, 6), skew = 0)
#> items
-#> estimates Y1 Y2 Y3
-#> mean 0.014663647 -1.009504893 0.004589209
-#> sd 0.775035961 0.955310905 1.018213994
+#> estimates Y1 Y2 Y3
+#> mean 0.02434619 -1.01561017 0.08093401
+#> sd 0.77743368 0.97395691 1.05227866
```
## Transformation
@@ -163,7 +162,7 @@ distribution is used. The value of skewness is restricted to the range
- For more detailed information and practical examples, please refer to
the package
- [vignette](https://lalovic.io/latent2likert/articles/intro_to_latent2likert.html).
+ [vignette](https://lalovic.io/latent2likert/articles/using_latent2likert.html).
- The implemented algorithms are described in the functions
[reference](https://lalovic.io/latent2likert/reference/index.html).
diff --git a/docs/index.html b/docs/index.html
index 0a50d35..bbe8491 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -123,7 +123,7 @@ Using rlikert
#library(latent2likert)
rlikert ( size = 10 , n_items = 1 , n_levels = 5 )
-#> [1] 3 2 3 4 3 4 3 4 4 1
+#> [1] 2 4 3 4 5 3 3 3 4 3
To generate responses to multiple items with specified parameters:
rlikert ( size = 10 ,
@@ -133,16 +133,16 @@ Using rlikert
sd = c ( 0.8 , 1 , 1 ) ,
corr = 0.5 )
#> Y1 Y2 Y3
-#> [1,] 2 1 4
-#> [2,] 4 2 3
-#> [3,] 2 2 2
-#> [4,] 2 2 2
-#> [5,] 2 1 3
-#> [6,] 2 2 3
-#> [7,] 3 1 2
-#> [8,] 2 3 4
-#> [9,] 3 5 4
-#> [10,] 3 1 5
+#> [1,] 3 3 5
+#> [2,] 2 1 1
+#> [3,] 2 2 3
+#> [4,] 3 2 5
+#> [5,] 2 2 5
+#> [6,] 3 2 4
+#> [7,] 1 1 3
+#> [8,] 3 1 4
+#> [9,] 2 2 4
+#> [10,] 2 2 4
You can also provide a correlation matrix:
corr <- matrix ( c ( 1.00 , - 0.63 , - 0.39 ,
@@ -158,9 +158,9 @@ Using rlikert
cor ( data )
#> Y1 Y2 Y3
-#> Y1 1.0000000 -0.5486188 -0.3592762
-#> Y2 -0.5486188 1.0000000 0.4172253
-#> Y3 -0.3592762 0.4172253 1.0000000
+#> Y1 1.0000000 -0.5271298 -0.3544365
+#> Y2 -0.5271298 1.0000000 0.4404984
+#> Y3 -0.3544365 0.4404984 1.0000000
Using estimate_params
@@ -170,9 +170,9 @@ Using estimate_params
estimate_params ( data , n_levels = c ( 4 , 5 , 6 ) , skew = 0 )
#> items
-#> estimates Y1 Y2 Y3
-#> mean 0.014663647 -1.009504893 0.004589209
-#> sd 0.775035961 0.955310905 1.018213994
+#> estimates Y1 Y2 Y3
+#> mean 0.02434619 -1.01561017 0.08093401
+#> sd 0.77743368 0.97395691 1.05227866
@@ -242,7 +242,7 @@ Developers
Dev status
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 729120b..cf527a9 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -3,7 +3,7 @@ pkgdown: 2.0.9
pkgdown_sha: ~
articles:
using_latent2likert: using_latent2likert.html
-last_built: 2024-06-20T22:23Z
+last_built: 2024-06-20T22:27Z
urls:
reference: https://markolalovic.github.io/latent2likert/reference
article: https://markolalovic.github.io/latent2likert/articles
diff --git a/docs/search.json b/docs/search.json
index 49d0b51..c36dac9 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -1 +1 @@
-[{"path":"https://markolalovic.github.io/latent2likert/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Marko Lalovic Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Using latent2likert","text":"social sciences, variables interest often conceptualized latent variables — hidden continuous variables measured Likert scale questions, typically categorized Strongly disagree, Disagree, Neutral, Agree, Strongly agree. Researchers frequently aim uncover latent variables using various statistical techniques. Accurate modeling survey data essential comparative analysis simulation. latent2likert package addresses need providing effective algorithm simulate Likert response variables hypothetical latent variables. vignette provides two practical workflow examples demonstrating use latent2likert package.","code":""},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"simulating-survey-data","dir":"Articles","previous_headings":"","what":"Simulating Survey Data","title":"Using latent2likert","text":"following hypothetical survey simulation loosely based actual comparative study teaching learning R pair introductory statistics labs (McNamara 2024). Imagine situation 10 participants Course 20 participants Course B completed survey. Suppose initial question : “rate experience course?” four possible answers: Poor, Fair, Good, Excellent. Let’s assume participants Course neutral regarding question, participants Course B positive experience average. choosing appropriate parameters latent distributions setting number categories n_levels = 4, can generate hypothetical responses (standard deviation sd = 1 skewness skew = 0, default): summarize results, create data frame responses: results can visualized using grouped bar chart:","code":"library(latent2likert) # load the package set.seed(12345) # to ensure reproducible results course_A <- rlikert(size = 10, n_items = 1, n_levels = 4, mean = 0, sd = 1) course_B <- rlikert(size = 20, n_items = 1, n_levels = 4, mean = 1, sd = 1) n_levels <- 4 n_groups <- 2 cats <- c(\"Poor\", \"Fair\", \"Good\", \"Excellent\") data <- data.frame( Course = rep(c(\"A\", \"B\"), each = n_levels), Response = factor(rep(cats, n_groups), levels = cats), Proportion = c(response_prop(course_A, n_levels), response_prop(course_B, n_levels)) ) data <- data[data$Prop > 0, ] data #> Course Response Proportion #> 1 A Poor 0.30 #> 2 A Fair 0.20 #> 3 A Good 0.20 #> 4 A Excellent 0.30 #> 6 B Fair 0.10 #> 7 B Good 0.25 #> 8 B Excellent 0.65"},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"pre-and-post-comparison","dir":"Articles","previous_headings":"","what":"Pre and Post Comparison","title":"Using latent2likert","text":"Now suppose survey also asked participants rate skills 5-point Likert scale, ranging 1 (poor) 5 (good) : Programming, Searching Online, Solving Problems. survey completed participants taking course pre post-comparison. Suppose participants’ assessments : Programming skills average increased, Searching Online stayed , Solving Problems increased Course , decreased participants Course B. Let’s simulate survey data scenario: Create data frame responses summarize results: visualize results stacked bar chart:","code":"# Pre- and post-assessments of skills for Course A pre_A <- rlikert(size = 10, n_items = 3, n_levels = 5, mean = c(-1, 0, 1)) post_A <- rlikert(size = 10, n_items = 3, n_levels = 5, mean = c(0, 0, 2)) # Pre- and post-assessments of skills for Course B pre_B <- rlikert(size = 20, n_items = 3, n_levels = 5, mean = c(-1, 0, 1)) post_B <- rlikert(size = 20, n_items = 3, n_levels = 5, mean = c(0, 0, 0)) pre_post <- list(pre_A, post_A, pre_B, post_B) n_items <- 6 # for 3 questions before and after n_levels <- 5 # for a 5-point Likert scale skills <- c(\"Programming\", \"Searching online\", \"Solving problems\") questions <- rep(as.vector(sapply(skills, function(skill) rep(skill, n_levels))), 4) questions <- factor(questions, levels = skills) data <- data.frame ( Course = c(rep(\"Course A\", n_items * n_levels), rep(\"Course B\", n_items * n_levels)), Question = questions, Time = as.factor(rep(c(rep(\"before\", 3*n_levels), rep(\"after\", 3*n_levels)), 2)), Response = rep(rep(seq_len(n_levels), 3), length(pre_post)), Proportion = as.vector(sapply(pre_post, function(d) { as.vector(t(response_prop(d, n_levels))) }))) head(data) #> Course Question Time Response Proportion #> 1 Course A Programming before 1 0.5 #> 2 Course A Programming before 2 0.2 #> 3 Course A Programming before 3 0.3 #> 4 Course A Programming before 4 0.0 #> 5 Course A Programming before 5 0.0 #> 6 Course A Searching online before 1 0.1"},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"recreating-scale-scores","dir":"Articles","previous_headings":"","what":"Recreating Scale Scores","title":"Using latent2likert","text":"use part bfi data set (Revelle 2024). particular first 5 items corresponding agreeableness. investigate differences agreeableness men women also use gender attribute. Load data: Separate items two groups according gender: reproduce items, start estimating parameters latent variables, assuming normal providing number possible response categories ‘n_levels = 6’: , generate new responses items using estimated parameters estimated correlations: next step create agreeableness scale scores groups participants, taking average 5 items. visualize results grouped boxplot:","code":"data(part_bfi) head(part_bfi) #> A1 A2 A3 A4 A5 gender #> 61617 2 4 3 4 4 0 #> 61618 2 4 5 2 5 1 #> 61620 5 4 5 4 4 1 #> 61621 4 4 6 5 5 1 #> 61622 2 3 3 4 5 0 #> 61623 6 6 5 6 5 1 vars <- c(\"A1\", \"A2\", \"A3\", \"A4\", \"A5\") items_M <- part_bfi[part_bfi$gender == 0, vars] items_F <- part_bfi[part_bfi$gender == 1, vars] params_M <- estimate_params(data = items_M, n_levels = 6) params_F <- estimate_params(data = items_F, n_levels = 6) set.seed(12345) # to ensure reproducible results new_items_M <- rlikert(size = nrow(items_M), n_items = 5, n_levels = 6, mean = params_M[\"mean\", ], sd = params_M[\"sd\", ], corr = cor(items_M)) new_items_F <- rlikert(size = nrow(items_F), n_items = 5, n_levels = 6, mean = params_F[\"mean\", ], sd = params_F[\"sd\", ], corr = cor(items_F)) # Combine new items and gender in new data frame new_data <- data.frame(rbind(new_items_M, new_items_F)) new_data$gender <- c(rep(0, nrow(items_M)), rep(1, nrow(items_F))) head(new_data) #> Y1 Y2 Y3 Y4 Y5 gender #> 1 3 5 5 4 5 0 #> 2 1 5 4 4 4 0 #> 3 2 6 5 6 4 0 #> 4 4 4 4 6 5 0 #> 5 4 5 3 2 2 0 #> 6 5 4 5 6 5 0 # We also need to reverse the first item because it has negative correlations part_bfi$A1 <- (min(part_bfi$A1) + max(part_bfi$A1)) - part_bfi$A1 new_data$Y1 <- (min(new_data$Y1) + max(new_data$Y1)) - new_data$Y1 # Create agreeableness scale scores part_bfi$agreeable <- rowMeans(part_bfi[, vars]) new_data$agreeable <- rowMeans(new_data[, c(\"Y1\", \"Y2\", \"Y3\", \"Y4\", \"Y5\")])"},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Marko Lalovic. Author, maintainer.","code":""},{"path":"https://markolalovic.github.io/latent2likert/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Lalovic M (2024). latent2likert: Converting Latent Variables Likert Scale Responses. R package version 1.2.1, https://lalovic.io/latent2likert/.","code":"@Manual{, title = {latent2likert: Converting Latent Variables into Likert Scale Responses}, author = {Marko Lalovic}, year = {2024}, note = {R package version 1.2.1}, url = {https://lalovic.io/latent2likert/}, }"},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Converting Latent Variables into Likert Scale Responses","text":"R package latent2likert designed effectively simulate discretization process inherent Likert scales minimizing distortion. converts continuous latent variables ordinal categories generate Likert scale item responses. particularly useful accurately modeling analyzing survey data use Likert scales, especially applying statistical techniques require metric data.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Converting Latent Variables into Likert Scale Responses","text":"can install development version GitHub :","code":"# install.packages(\"devtools\") #devtools::install_github(\"markolalovic/latent2likert\")"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"dependencies","dir":"","previous_headings":"","what":"Dependencies","title":"Converting Latent Variables into Likert Scale Responses","text":"keep package lightweight, latent2likert imports mvtnorm, along standard R packages stats graphics, typically included R releases. additional suggested dependency sn package, required generating random responses correlated Likert items based multivariate skew normal distribution. package prompts user install dependency interactive sessions needed.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"features","dir":"","previous_headings":"","what":"Features","title":"Converting Latent Variables into Likert Scale Responses","text":"rlikert: Generates random responses Likert scale questions based specified means standard deviations latent variables, optional settings skewness correlations. estimate_params: Estimates latent parameters existing survey data.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"structure","dir":"","previous_headings":"","what":"Structure","title":"Converting Latent Variables into Likert Scale Responses","text":"Overview inputs outputs.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"using-rlikert","dir":"","previous_headings":"","what":"Using rlikert","title":"Converting Latent Variables into Likert Scale Responses","text":"generate sample random responses one item 5-point Likert scale, use: generate responses multiple items specified parameters: can also provide correlation matrix: Note correlations among Likert response variables estimates actual correlations latent variables, estimates typically lower:","code":"#library(latent2likert) rlikert(size = 10, n_items = 1, n_levels = 5) #> [1] 3 2 3 4 3 4 3 4 4 1 rlikert(size = 10, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = 0.5) #> Y1 Y2 Y3 #> [1,] 2 1 4 #> [2,] 4 2 3 #> [3,] 2 2 2 #> [4,] 2 2 2 #> [5,] 2 1 3 #> [6,] 2 2 3 #> [7,] 3 1 2 #> [8,] 2 3 4 #> [9,] 3 5 4 #> [10,] 3 1 5 corr <- matrix(c(1.00, -0.63, -0.39, -0.63, 1.00, 0.41, -0.39, 0.41, 1.00), nrow=3) data <- rlikert(size = 10^3, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = corr) cor(data) #> Y1 Y2 Y3 #> Y1 1.0000000 -0.5486188 -0.3592762 #> Y2 -0.5486188 1.0000000 0.4172253 #> Y3 -0.3592762 0.4172253 1.0000000"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"using-estimate_params","dir":"","previous_headings":"","what":"Using estimate_params","title":"Converting Latent Variables into Likert Scale Responses","text":"Given data, can estimate values latent parameters using:","code":"estimate_params(data, n_levels = c(4, 5, 6), skew = 0) #> items #> estimates Y1 Y2 Y3 #> mean 0.014663647 -1.009504893 0.004589209 #> sd 0.775035961 0.955310905 1.018213994"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"transformation","dir":"","previous_headings":"","what":"Transformation","title":"Converting Latent Variables into Likert Scale Responses","text":"visualize transformation, can use plot_likert_transform(). plots densities latent variables first row transformed discrete probability distributions : Transformation latent variables Likert response variables. Note , depending value skewness parameter, normal latent distribution used skew = 0, otherwise skew normal distribution used. value skewness restricted range -0.95 0.95, skew >= -0.95 skew <= 0.95.","code":"plot_likert_transform(n_items = 3, n_levels = 5, mean = c(0, -1, 0), sd = c(0.8, 1, 1), skew = c(0, 0, 0.5))"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"further-reading","dir":"","previous_headings":"","what":"Further Reading","title":"Converting Latent Variables into Likert Scale Responses","text":"detailed information practical examples, please refer package vignette. implemented algorithms described functions reference.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"related-r-packages","dir":"","previous_headings":"","what":"Related R Packages","title":"Converting Latent Variables into Likert Scale Responses","text":"simulate Likert item responses, draw_likert function fabricatr package can used recode latent variable Likert response variable specifying intervals subdivide continuous range. latent2likert package, however, offers advantage automatically calculating optimal intervals minimize distortion latent variable Likert response variable normal skew normal latent distributions, eliminating need manually specify intervals. also several alternative approaches rely latent distributions. One method involves directly defining discrete probability distribution sampling using sample function R likert function wakefield package. Another approach specify means, standard deviations, correlations among Likert response variables. , can use LikertMakeR SimCorMultRes generate correlated multinomial responses. Additionally, can define data generating process. familiar item response theory, mirt package allows users specify discrimination difficulty parameters response category.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":null,"dir":"Reference","previous_headings":"","what":"Discretize Density — discretize_density","title":"Discretize Density — discretize_density","text":"Transforms density function continuous random variable discrete probability distribution minimal distortion using Lloyd-Max algorithm.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Discretize Density — discretize_density","text":"","code":"discretize_density(density_fn, n_levels, eps = 1e-06)"},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Discretize Density — discretize_density","text":"density_fn probability density function. n_levels cardinality set possible outcomes. eps convergence threshold algorithm.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Discretize Density — discretize_density","text":"list containing: prob discrete probability distribution. endp endpoints intervals partition continuous domain. repr representation points intervals. dist distortion measured mean-squared error (MSE).","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Discretize Density — discretize_density","text":"function addresses problem transforming continuous random variable \\(X\\) discrete random variable \\(Y\\) minimal distortion. Distortion measured mean-squared error (MSE): $$ \\text{E}\\left[ (X - Y)^2 \\right] = \\sum_{k=1}^{K} \\int_{x_{k-1}}^{x_{k}} f_{X}(x) \\left( x - r_{k} \\right)^2 \\, dx $$ : \\(f_{X}\\) probability density function \\(X\\), \\(K\\) number possible outcomes \\(Y\\), \\(x_{k}\\) endpoints intervals partition domain \\(X\\), \\(r_{k}\\) representation points intervals. problem solved using following iterative procedure: \\(1.\\) Start arbitrary initial set representation points: \\(r_{1} < r_{2} < \\dots < r_{K}\\). \\(2.\\) Repeat following steps improvement MSE falls given \\(\\varepsilon\\). \\(3.\\) Calculate endpoints \\(x_{k} = (r_{k+1} + r_{k})/2\\) \\(k = 1, \\dots, K-1\\) set \\(x_{0}\\) \\(x_{K}\\) \\(-\\infty\\) \\(\\infty\\), respectively. \\(4.\\) Update representation points setting \\(r_{k}\\) equal conditional mean \\(X\\) given \\(X \\(x_{k-1}, x_{k})\\) \\(k = 1, \\dots, K\\). execution step \\((3)\\) step \\((4)\\), MSE decreases remains . MSE nonnegative, approaches limit. algorithm terminates improvement MSE less given \\(\\varepsilon > 0\\), ensuring convergence finite number iterations. procedure known Lloyd-Max's algorithm, initially used scalar quantization closely related k-means algorithm. Local convergence proven log-concave density functions Kieffer. Many common probability distributions log-concave including normal skew normal distribution, shown Azzalini.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Discretize Density — discretize_density","text":"Azzalini, . (1985). class distributions includes normal ones. Scandinavian Journal Statistics 12(2), 171–178. Kieffer, J. (1983). Uniqueness locally optimal quantizer log-concave density convex error function. IEEE Transactions Information Theory 29, 42–47. Lloyd, S. (1982). Least squares quantization PCM. IEEE Transactions Information Theory 28 (2), 129–137.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Discretize Density — discretize_density","text":"","code":"discretize_density(density_fn = stats::dnorm, n_levels = 5) #> $prob #> [1] 0.1063142 0.2444957 0.2983803 0.2444957 0.1063142 #> #> $endp #> [1] -Inf -1.2463707 -0.3831349 0.3831349 1.2463707 Inf #> #> $repr #> [1] -1.7264716 -0.7662698 0.0000000 0.7662698 1.7264716 #> #> $dist #> [1] 0.07994185 #> discretize_density(density_fn = function(x) { 2 * stats::dnorm(x) * stats::pnorm(0.5 * x)}, n_levels = 4) #> $prob #> [1] 0.1647781 0.3380772 0.3359810 0.1611637 #> #> $endp #> [1] -Inf -0.5537368 0.3597728 1.2808536 Inf #> #> $repr #> [1] -1.04423728 -0.06323628 0.78278182 1.77892538 #> #> $dist #> [1] 0.1026681 #>"},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate Latent Parameters — estimate_params","title":"Estimate Latent Parameters — estimate_params","text":"Estimates location scaling parameters latent variables existing survey data.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate Latent Parameters — estimate_params","text":"","code":"estimate_params(data, n_levels, skew = 0)"},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate Latent Parameters — estimate_params","text":"data survey data columns representing individual items. Apart , data can almost class \"data.frame\" \"matrix\" \"array\". n_levels number response categories, vector number. skew marginal skewness latent variables, defaults 0.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate Latent Parameters — estimate_params","text":"table estimated parameters latent variable.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate Latent Parameters — estimate_params","text":"relationship continuous random variable \\(X\\) discrete probability distribution \\(p_k\\), \\(k = 1, \\dots, K\\), can described system non-linear equations: $$ p_{k} = F_{X}\\left( \\frac{x_{k - 1} - \\xi}{\\omega} \\right) - F_{X}\\left( \\frac{x_{k} - \\xi}{\\omega} \\right) \\quad \\text{} \\ k = 1, \\dots, K $$ : \\(F_{X}\\) cumulative distribution function \\(X\\), \\(K\\) number possible response categories, \\(x_{k}\\) endpoints defining boundaries response categories, \\(p_{k}\\) probability \\(k\\)-th response category, \\(\\xi\\) location parameter \\(X\\), \\(\\omega\\) scaling parameter \\(X\\). endpoints \\(x_{k}\\) calculated discretizing random variable \\(Z\\) mean 0 standard deviation 1 follows distribution \\(X\\). solving system non-linear equations iteratively, can find parameters best fit observed discrete probability distribution \\(p_{k}\\). function estimate_params: Computes proportion table responses item. Estimates probabilities \\(p_{k}\\) item. Computes estimates \\(\\xi\\) \\(\\omega\\) item. Combines estimated parameters items table.","code":""},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate Latent Parameters — estimate_params","text":"","code":"data(part_bfi) vars <- c(\"A1\", \"A2\", \"A3\", \"A4\", \"A5\") estimate_params(data = part_bfi[, vars], n_levels = 6) #> items #> estimates A1 A2 A3 A4 A5 #> mean -0.9759824 1.0830781 0.9776057 1.1723519 0.9006478 #> sd 1.1798137 0.7968668 0.8432599 1.3825407 0.8648150"},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":null,"dir":"Reference","previous_headings":"","what":"Agreeableness and Gender Data — part_bfi","title":"Agreeableness and Gender Data — part_bfi","text":"dataset cleaned version small part bfi dataset psychTools package. contains responses first 5 items agreeableness scale International Personality Item Pool (IPIP) gender attribute. includes responses 2800 subjects. item answered six point Likert scale ranging 1 (inaccurate), 6 (accurate). Gender coded 0 male 1 female. Missing values addressed using mode imputation.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Agreeableness and Gender Data — part_bfi","text":"","code":"data(part_bfi)"},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Agreeableness and Gender Data — part_bfi","text":"object class \"data.frame\" 2800 observations following 6 variables: A1 indifferent feelings others. A2 Inquire others' well-. A3 Know comfort others. A4 Love children. A5 Make people feel ease. gender Gender respondent.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Agreeableness and Gender Data — part_bfi","text":"International Personality Item Pool (ipip.ori.org) https://search.r-project.org/CRAN/refmans/psychTools/html/bfi.html","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Agreeableness and Gender Data — part_bfi","text":"Revelle, W. (2024). Psych: Procedures Psychological, Psychometric, Personality Research. Evanston, Illinois: Northwestern University. https://CRAN.R-project.org/package=psych","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Agreeableness and Gender Data — part_bfi","text":"","code":"data(part_bfi) head(part_bfi) #> A1 A2 A3 A4 A5 gender #> 61617 2 4 3 4 4 0 #> 61618 2 4 5 2 5 1 #> 61620 5 4 5 4 4 1 #> 61621 4 4 6 5 5 1 #> 61622 2 3 3 4 5 0 #> 61623 6 6 5 6 5 1"},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Transformation — plot_likert_transform","title":"Plot Transformation — plot_likert_transform","text":"Plots densities latent variables first row transformed discrete probability distributions .","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Transformation — plot_likert_transform","text":"","code":"plot_likert_transform(n_items, n_levels, mean = 0, sd = 1, skew = 0)"},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Transformation — plot_likert_transform","text":"n_items number Likert scale items (questions). n_levels number response categories Likert item. Integer vector integers. mean means latent variables. Numeric vector numerics. Defaults 0. sd standard deviations latent variables. Numeric vector numerics. Defaults 1. skew marginal skewness latent variables. Numeric vector numerics. Defaults 0.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Transformation — plot_likert_transform","text":"plot showing densities latent variables corresponding discrete probability distributions.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Transformation — plot_likert_transform","text":"","code":"plot_likert_transform(n_items = 3, n_levels = c(3, 4, 5)) plot_likert_transform(n_items = 3, n_levels = 5, mean=c(0, 1, 2)) plot_likert_transform(n_items = 3, n_levels = 5, sd=c(0.8, 1, 1.2)) plot_likert_transform(n_items = 3, n_levels = 5, skew=c(-0.5, 0, 0.5))"},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate Response Proportions — response_prop","title":"Calculate Response Proportions — response_prop","text":"Returns table proportions possible response category.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate Response Proportions — response_prop","text":"","code":"response_prop(data, n_levels)"},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate Response Proportions — response_prop","text":"data numeric vector matrix responses. n_levels number response categories.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate Response Proportions — response_prop","text":"table response category proportions.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate Response Proportions — response_prop","text":"","code":"data <- c(1, 2, 2, 3, 3, 3) response_prop(data, n_levels = 3) #> 1 2 3 #> 0.1666667 0.3333333 0.5000000 data_matrix <- matrix(c(1, 2, 2, 3, 3, 3), ncol = 2) response_prop(data_matrix, n_levels = 3) #> Response #> Item 1 2 3 #> [1,] 0.3333333 0.6666667 0 #> [2,] 0.0000000 0.0000000 1"},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Random Responses — rlikert","title":"Generate Random Responses — rlikert","text":"Generates array random responses Likert-type questions based specified latent variables.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Random Responses — rlikert","text":"","code":"rlikert(size, n_items, n_levels, mean = 0, sd = 1, skew = 0, corr = 0)"},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Random Responses — rlikert","text":"size number observations. n_items number Likert scale items (number questions). n_levels number response categories item. Integer vector integers. mean means latent variables. Numeric vector numerics. Defaults 0. sd standard deviations latent variables. Numeric vector numerics. Defaults 1. skew marginal skewness latent variables. Numeric vector numerics. Defaults 0. corr correlations latent variables. Can single numeric value representing correlation pairs, actual correlation matrix. Defaults 0.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Random Responses — rlikert","text":"matrix random responses dimensions size n_items. column names Y1, Y2, ..., Yn n number items. entry matrix represents Likert scale response, ranging 1 n_levels.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Random Responses — rlikert","text":"","code":"# Generate responses for a single item with 5 levels rlikert(size = 10, n_items = 1, n_levels = 5) #> [1] 3 5 4 3 3 2 2 3 4 4 # Generate responses for three items with different levels and parameters rlikert( size = 10, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = 0.5 ) #> Y1 Y2 Y3 #> [1,] 3 1 3 #> [2,] 2 1 3 #> [3,] 3 4 2 #> [4,] 2 1 2 #> [5,] 2 2 2 #> [6,] 3 2 2 #> [7,] 3 4 4 #> [8,] 2 1 2 #> [9,] 2 2 4 #> [10,] 3 4 4 # Generate responses with a correlation matrix corr <- matrix(c( 1.00, -0.63, -0.39, -0.63, 1.00, 0.41, -0.39, 0.41, 1.00 ), nrow = 3) data <- rlikert( size = 1000, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = corr )"},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulate Likert Scale Item Responses — simulate_likert","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"Simulates Likert scale item responses based specified number response categories centered parameters latent variable.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"","code":"simulate_likert(n_levels, cp)"},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"n_levels Integer. number response categories Likert scale item. cp Named vector. centered parameters latent variable, including mean (mu), standard deviation (sd), skewness (skew). Skewness must -0.95 0.95.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"named vector probabilities response category.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"simulation process uses following model proposed Boari Nai-Ruscone. Let \\(X\\) continuous variable interest, measured using Likert scale questions \\(K\\) response categories. observed discrete variable \\(Y\\) defined follows: $$ Y = k, \\quad \\text{ } \\ \\ x_{k - 1} < X \\leq x_{k} \\quad \\text{ } \\ \\ k = 1, \\dots, K $$ \\(x_{k}\\), \\(k = 0, \\dots, K\\) endpoints defined domain \\(X\\) : $$ -\\infty = x_{0} < x_{1} < \\dots < x_{K - 1} < x_{K} = \\infty. $$ endpoints dictate transformation density \\(f_{X}\\) \\(X\\) discrete probability distribution: $$ \\text{Pr}(Y = k) = \\int_{x_{k - 1}}^{x_{k}} f_{X}(x) \\, dx \\quad \\text{ } \\ \\ k = 1, \\dots, K. $$ continuous latent variable modeled using skew normal distribution. function simulate_likert performs following steps: Ensures centered parameters within acceptable range. Converts centered parameters direct parameters. Defines density function skew normal distribution. Computes probabilities response category using optimal endpoints.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"Boari, G. Nai Ruscone, M. (2015). procedure simulating likert scale item responses. Electronic journal applied statistical analysis 8(3), 288–297. doi:10.1285/i20705948v8n3p288","code":""},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"","code":"cp <- c(mu = 0, sd = 1, skew = 0.5) simulate_likert(n_levels = 5, cp = cp) #> 1 2 3 4 5 #> 0.15995244 0.29511214 0.28435807 0.18964493 0.07093241 cp2 <- c(mu = 1, sd = 2, skew = -0.3) simulate_likert(n_levels = 7, cp = cp2) #> 1 2 3 4 5 6 7 #> 0.08311645 0.07169556 0.07928979 0.08940184 0.10477572 0.13413804 0.43758260"},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-010-release-date-2020-10-17","dir":"Changelog","previous_headings":"","what":"latent2likert 0.1.0 (Release date: 2020-10-17)","title":"latent2likert 0.1.0 (Release date: 2020-10-17)","text":"Initial release (development version). Tested platforms: x86_64-pc-linux-gnu (64-bit) x86_64-w64-mingw32 (64-bit).","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-100-release-date-2024-03-28","dir":"Changelog","previous_headings":"","what":"latent2likert 1.0.0 (Release date: 2024-03-28)","title":"latent2likert 1.0.0 (Release date: 2024-03-28)","text":"option generate correlated Likert scale items added function rLikert(). New function estimate_parameters() added allows estimation parameters existing survey data replicate accurately. Issues related dependencies resolved. version now imports standard R packages mvtnorm, stats, graphics packages stats graphics, typically included R releases. package sn necessary generating correlated responses based skew normal distribution. Added user prompts installing sn package necessary.","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-110-release-date-2024-06-06","dir":"Changelog","previous_headings":"","what":"latent2likert 1.1.0 (Release date: 2024-06-06)","title":"latent2likert 1.1.0 (Release date: 2024-06-06)","text":"minor update functions vignettes.","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-111-release-date-2024-06-06","dir":"Changelog","previous_headings":"","what":"latent2likert 1.1.1 (Release date: 2024-06-06)","title":"latent2likert 1.1.1 (Release date: 2024-06-06)","text":"package renamed responsesR latent2likert. capture essence converting latent variables Likert scale responses. Improvements package website documentation.","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-121-release-date-2024-06-12","dir":"Changelog","previous_headings":"","what":"latent2likert 1.2.1 (Release date: 2024-06-12)","title":"latent2likert 1.2.1 (Release date: 2024-06-12)","text":"Refactored code improved modularity maintainability. Modularized core functions better readability. Improved structure organization codebase. Improved error handling different cases correlations input. Updated estimate_parameters() function estimating latent parameters survey data. codebase currently development, finer details may change.","code":""}]
+[{"path":"https://markolalovic.github.io/latent2likert/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Marko Lalovic Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Using latent2likert","text":"social sciences, variables interest often conceptualized latent variables — hidden continuous variables measured Likert scale questions, typically categorized Strongly disagree, Disagree, Neutral, Agree, Strongly agree. Researchers frequently aim uncover latent variables using various statistical techniques. Accurate modeling survey data essential comparative analysis simulation. latent2likert package addresses need providing effective algorithm simulate Likert response variables hypothetical latent variables. vignette provides two practical workflow examples demonstrating use latent2likert package.","code":""},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"simulating-survey-data","dir":"Articles","previous_headings":"","what":"Simulating Survey Data","title":"Using latent2likert","text":"following hypothetical survey simulation loosely based actual comparative study teaching learning R pair introductory statistics labs (McNamara 2024). Imagine situation 10 participants Course 20 participants Course B completed survey. Suppose initial question : “rate experience course?” four possible answers: Poor, Fair, Good, Excellent. Let’s assume participants Course neutral regarding question, participants Course B positive experience average. choosing appropriate parameters latent distributions setting number categories n_levels = 4, can generate hypothetical responses (standard deviation sd = 1 skewness skew = 0, default): summarize results, create data frame responses: results can visualized using grouped bar chart:","code":"library(latent2likert) # load the package set.seed(12345) # to ensure reproducible results course_A <- rlikert(size = 10, n_items = 1, n_levels = 4, mean = 0, sd = 1) course_B <- rlikert(size = 20, n_items = 1, n_levels = 4, mean = 1, sd = 1) n_levels <- 4 n_groups <- 2 cats <- c(\"Poor\", \"Fair\", \"Good\", \"Excellent\") data <- data.frame( Course = rep(c(\"A\", \"B\"), each = n_levels), Response = factor(rep(cats, n_groups), levels = cats), Proportion = c(response_prop(course_A, n_levels), response_prop(course_B, n_levels)) ) data <- data[data$Prop > 0, ] data #> Course Response Proportion #> 1 A Poor 0.30 #> 2 A Fair 0.20 #> 3 A Good 0.20 #> 4 A Excellent 0.30 #> 6 B Fair 0.10 #> 7 B Good 0.25 #> 8 B Excellent 0.65"},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"pre-and-post-comparison","dir":"Articles","previous_headings":"","what":"Pre and Post Comparison","title":"Using latent2likert","text":"Now suppose survey also asked participants rate skills 5-point Likert scale, ranging 1 (poor) 5 (good) : Programming, Searching Online, Solving Problems. survey completed participants taking course pre post-comparison. Suppose participants’ assessments : Programming skills average increased, Searching Online stayed , Solving Problems increased Course , decreased participants Course B. Let’s simulate survey data scenario: Create data frame responses summarize results: visualize results stacked bar chart:","code":"# Pre- and post-assessments of skills for Course A pre_A <- rlikert(size = 10, n_items = 3, n_levels = 5, mean = c(-1, 0, 1)) post_A <- rlikert(size = 10, n_items = 3, n_levels = 5, mean = c(0, 0, 2)) # Pre- and post-assessments of skills for Course B pre_B <- rlikert(size = 20, n_items = 3, n_levels = 5, mean = c(-1, 0, 1)) post_B <- rlikert(size = 20, n_items = 3, n_levels = 5, mean = c(0, 0, 0)) pre_post <- list(pre_A, post_A, pre_B, post_B) n_items <- 6 # for 3 questions before and after n_levels <- 5 # for a 5-point Likert scale skills <- c(\"Programming\", \"Searching online\", \"Solving problems\") questions <- rep(as.vector(sapply(skills, function(skill) rep(skill, n_levels))), 4) questions <- factor(questions, levels = skills) data <- data.frame ( Course = c(rep(\"Course A\", n_items * n_levels), rep(\"Course B\", n_items * n_levels)), Question = questions, Time = as.factor(rep(c(rep(\"before\", 3*n_levels), rep(\"after\", 3*n_levels)), 2)), Response = rep(rep(seq_len(n_levels), 3), length(pre_post)), Proportion = as.vector(sapply(pre_post, function(d) { as.vector(t(response_prop(d, n_levels))) }))) head(data) #> Course Question Time Response Proportion #> 1 Course A Programming before 1 0.5 #> 2 Course A Programming before 2 0.2 #> 3 Course A Programming before 3 0.3 #> 4 Course A Programming before 4 0.0 #> 5 Course A Programming before 5 0.0 #> 6 Course A Searching online before 1 0.1"},{"path":"https://markolalovic.github.io/latent2likert/articles/using_latent2likert.html","id":"recreating-scale-scores","dir":"Articles","previous_headings":"","what":"Recreating Scale Scores","title":"Using latent2likert","text":"use part bfi data set (Revelle 2024). particular first 5 items corresponding agreeableness. investigate differences agreeableness men women also use gender attribute. Load data: Separate items two groups according gender: reproduce items, start estimating parameters latent variables, assuming normal providing number possible response categories ‘n_levels = 6’: , generate new responses items using estimated parameters estimated correlations: next step create agreeableness scale scores groups participants, taking average 5 items. visualize results grouped boxplot:","code":"data(part_bfi) head(part_bfi) #> A1 A2 A3 A4 A5 gender #> 61617 2 4 3 4 4 0 #> 61618 2 4 5 2 5 1 #> 61620 5 4 5 4 4 1 #> 61621 4 4 6 5 5 1 #> 61622 2 3 3 4 5 0 #> 61623 6 6 5 6 5 1 vars <- c(\"A1\", \"A2\", \"A3\", \"A4\", \"A5\") items_M <- part_bfi[part_bfi$gender == 0, vars] items_F <- part_bfi[part_bfi$gender == 1, vars] params_M <- estimate_params(data = items_M, n_levels = 6) params_F <- estimate_params(data = items_F, n_levels = 6) set.seed(12345) # to ensure reproducible results new_items_M <- rlikert(size = nrow(items_M), n_items = 5, n_levels = 6, mean = params_M[\"mean\", ], sd = params_M[\"sd\", ], corr = cor(items_M)) new_items_F <- rlikert(size = nrow(items_F), n_items = 5, n_levels = 6, mean = params_F[\"mean\", ], sd = params_F[\"sd\", ], corr = cor(items_F)) # Combine new items and gender in new data frame new_data <- data.frame(rbind(new_items_M, new_items_F)) new_data$gender <- c(rep(0, nrow(items_M)), rep(1, nrow(items_F))) head(new_data) #> Y1 Y2 Y3 Y4 Y5 gender #> 1 3 5 5 4 5 0 #> 2 1 5 4 4 4 0 #> 3 2 6 5 6 4 0 #> 4 4 4 4 6 5 0 #> 5 4 5 3 2 2 0 #> 6 5 4 5 6 5 0 # We also need to reverse the first item because it has negative correlations part_bfi$A1 <- (min(part_bfi$A1) + max(part_bfi$A1)) - part_bfi$A1 new_data$Y1 <- (min(new_data$Y1) + max(new_data$Y1)) - new_data$Y1 # Create agreeableness scale scores part_bfi$agreeable <- rowMeans(part_bfi[, vars]) new_data$agreeable <- rowMeans(new_data[, c(\"Y1\", \"Y2\", \"Y3\", \"Y4\", \"Y5\")])"},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Marko Lalovic. Author, maintainer.","code":""},{"path":"https://markolalovic.github.io/latent2likert/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Lalovic M (2024). latent2likert: Converting Latent Variables Likert Scale Responses. R package version 1.2.1, https://lalovic.io/latent2likert/.","code":"@Manual{, title = {latent2likert: Converting Latent Variables into Likert Scale Responses}, author = {Marko Lalovic}, year = {2024}, note = {R package version 1.2.1}, url = {https://lalovic.io/latent2likert/}, }"},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Converting Latent Variables into Likert Scale Responses","text":"R package latent2likert designed effectively simulate discretization process inherent Likert scales minimizing distortion. converts continuous latent variables ordinal categories generate Likert scale item responses. particularly useful accurately modeling analyzing survey data use Likert scales, especially applying statistical techniques require metric data.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Converting Latent Variables into Likert Scale Responses","text":"can install development version GitHub :","code":"# install.packages(\"devtools\") #devtools::install_github(\"markolalovic/latent2likert\")"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"dependencies","dir":"","previous_headings":"","what":"Dependencies","title":"Converting Latent Variables into Likert Scale Responses","text":"keep package lightweight, latent2likert imports mvtnorm, along standard R packages stats graphics, typically included R releases. additional suggested dependency sn package, required generating random responses correlated Likert items based multivariate skew normal distribution. package prompts user install dependency interactive sessions needed.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"features","dir":"","previous_headings":"","what":"Features","title":"Converting Latent Variables into Likert Scale Responses","text":"rlikert: Generates random responses Likert scale questions based specified means standard deviations latent variables, optional settings skewness correlations. estimate_params: Estimates latent parameters existing survey data.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"structure","dir":"","previous_headings":"","what":"Structure","title":"Converting Latent Variables into Likert Scale Responses","text":"Overview inputs outputs.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"using-rlikert","dir":"","previous_headings":"","what":"Using rlikert","title":"Converting Latent Variables into Likert Scale Responses","text":"generate sample random responses one item 5-point Likert scale, use: generate responses multiple items specified parameters: can also provide correlation matrix: Note correlations among Likert response variables estimates actual correlations latent variables, estimates typically lower:","code":"#library(latent2likert) rlikert(size = 10, n_items = 1, n_levels = 5) #> [1] 2 4 3 4 5 3 3 3 4 3 rlikert(size = 10, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = 0.5) #> Y1 Y2 Y3 #> [1,] 3 3 5 #> [2,] 2 1 1 #> [3,] 2 2 3 #> [4,] 3 2 5 #> [5,] 2 2 5 #> [6,] 3 2 4 #> [7,] 1 1 3 #> [8,] 3 1 4 #> [9,] 2 2 4 #> [10,] 2 2 4 corr <- matrix(c(1.00, -0.63, -0.39, -0.63, 1.00, 0.41, -0.39, 0.41, 1.00), nrow=3) data <- rlikert(size = 10^3, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = corr) cor(data) #> Y1 Y2 Y3 #> Y1 1.0000000 -0.5271298 -0.3544365 #> Y2 -0.5271298 1.0000000 0.4404984 #> Y3 -0.3544365 0.4404984 1.0000000"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"using-estimate_params","dir":"","previous_headings":"","what":"Using estimate_params","title":"Converting Latent Variables into Likert Scale Responses","text":"Given data, can estimate values latent parameters using:","code":"estimate_params(data, n_levels = c(4, 5, 6), skew = 0) #> items #> estimates Y1 Y2 Y3 #> mean 0.02434619 -1.01561017 0.08093401 #> sd 0.77743368 0.97395691 1.05227866"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"transformation","dir":"","previous_headings":"","what":"Transformation","title":"Converting Latent Variables into Likert Scale Responses","text":"visualize transformation, can use plot_likert_transform(). plots densities latent variables first row transformed discrete probability distributions : Transformation latent variables Likert response variables. Note , depending value skewness parameter, normal latent distribution used skew = 0, otherwise skew normal distribution used. value skewness restricted range -0.95 0.95, skew >= -0.95 skew <= 0.95.","code":"plot_likert_transform(n_items = 3, n_levels = 5, mean = c(0, -1, 0), sd = c(0.8, 1, 1), skew = c(0, 0, 0.5))"},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"further-reading","dir":"","previous_headings":"","what":"Further Reading","title":"Converting Latent Variables into Likert Scale Responses","text":"detailed information practical examples, please refer package vignette. implemented algorithms described functions reference.","code":""},{"path":"https://markolalovic.github.io/latent2likert/index.html","id":"related-r-packages","dir":"","previous_headings":"","what":"Related R Packages","title":"Converting Latent Variables into Likert Scale Responses","text":"simulate Likert item responses, draw_likert function fabricatr package can used recode latent variable Likert response variable specifying intervals subdivide continuous range. latent2likert package, however, offers advantage automatically calculating optimal intervals minimize distortion latent variable Likert response variable normal skew normal latent distributions, eliminating need manually specify intervals. also several alternative approaches rely latent distributions. One method involves directly defining discrete probability distribution sampling using sample function R likert function wakefield package. Another approach specify means, standard deviations, correlations among Likert response variables. , can use LikertMakeR SimCorMultRes generate correlated multinomial responses. Additionally, can define data generating process. familiar item response theory, mirt package allows users specify discrimination difficulty parameters response category.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":null,"dir":"Reference","previous_headings":"","what":"Discretize Density — discretize_density","title":"Discretize Density — discretize_density","text":"Transforms density function continuous random variable discrete probability distribution minimal distortion using Lloyd-Max algorithm.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Discretize Density — discretize_density","text":"","code":"discretize_density(density_fn, n_levels, eps = 1e-06)"},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Discretize Density — discretize_density","text":"density_fn probability density function. n_levels cardinality set possible outcomes. eps convergence threshold algorithm.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Discretize Density — discretize_density","text":"list containing: prob discrete probability distribution. endp endpoints intervals partition continuous domain. repr representation points intervals. dist distortion measured mean-squared error (MSE).","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Discretize Density — discretize_density","text":"function addresses problem transforming continuous random variable \\(X\\) discrete random variable \\(Y\\) minimal distortion. Distortion measured mean-squared error (MSE): $$ \\text{E}\\left[ (X - Y)^2 \\right] = \\sum_{k=1}^{K} \\int_{x_{k-1}}^{x_{k}} f_{X}(x) \\left( x - r_{k} \\right)^2 \\, dx $$ : \\(f_{X}\\) probability density function \\(X\\), \\(K\\) number possible outcomes \\(Y\\), \\(x_{k}\\) endpoints intervals partition domain \\(X\\), \\(r_{k}\\) representation points intervals. problem solved using following iterative procedure: \\(1.\\) Start arbitrary initial set representation points: \\(r_{1} < r_{2} < \\dots < r_{K}\\). \\(2.\\) Repeat following steps improvement MSE falls given \\(\\varepsilon\\). \\(3.\\) Calculate endpoints \\(x_{k} = (r_{k+1} + r_{k})/2\\) \\(k = 1, \\dots, K-1\\) set \\(x_{0}\\) \\(x_{K}\\) \\(-\\infty\\) \\(\\infty\\), respectively. \\(4.\\) Update representation points setting \\(r_{k}\\) equal conditional mean \\(X\\) given \\(X \\(x_{k-1}, x_{k})\\) \\(k = 1, \\dots, K\\). execution step \\((3)\\) step \\((4)\\), MSE decreases remains . MSE nonnegative, approaches limit. algorithm terminates improvement MSE less given \\(\\varepsilon > 0\\), ensuring convergence finite number iterations. procedure known Lloyd-Max's algorithm, initially used scalar quantization closely related k-means algorithm. Local convergence proven log-concave density functions Kieffer. Many common probability distributions log-concave including normal skew normal distribution, shown Azzalini.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Discretize Density — discretize_density","text":"Azzalini, . (1985). class distributions includes normal ones. Scandinavian Journal Statistics 12(2), 171–178. Kieffer, J. (1983). Uniqueness locally optimal quantizer log-concave density convex error function. IEEE Transactions Information Theory 29, 42–47. Lloyd, S. (1982). Least squares quantization PCM. IEEE Transactions Information Theory 28 (2), 129–137.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/discretize_density.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Discretize Density — discretize_density","text":"","code":"discretize_density(density_fn = stats::dnorm, n_levels = 5) #> $prob #> [1] 0.1063142 0.2444957 0.2983803 0.2444957 0.1063142 #> #> $endp #> [1] -Inf -1.2463707 -0.3831349 0.3831349 1.2463707 Inf #> #> $repr #> [1] -1.7264716 -0.7662698 0.0000000 0.7662698 1.7264716 #> #> $dist #> [1] 0.07994185 #> discretize_density(density_fn = function(x) { 2 * stats::dnorm(x) * stats::pnorm(0.5 * x)}, n_levels = 4) #> $prob #> [1] 0.1647781 0.3380772 0.3359810 0.1611637 #> #> $endp #> [1] -Inf -0.5537368 0.3597728 1.2808536 Inf #> #> $repr #> [1] -1.04423728 -0.06323628 0.78278182 1.77892538 #> #> $dist #> [1] 0.1026681 #>"},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":null,"dir":"Reference","previous_headings":"","what":"Estimate Latent Parameters — estimate_params","title":"Estimate Latent Parameters — estimate_params","text":"Estimates location scaling parameters latent variables existing survey data.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Estimate Latent Parameters — estimate_params","text":"","code":"estimate_params(data, n_levels, skew = 0)"},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Estimate Latent Parameters — estimate_params","text":"data survey data columns representing individual items. Apart , data can almost class \"data.frame\" \"matrix\" \"array\". n_levels number response categories, vector number. skew marginal skewness latent variables, defaults 0.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Estimate Latent Parameters — estimate_params","text":"table estimated parameters latent variable.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Estimate Latent Parameters — estimate_params","text":"relationship continuous random variable \\(X\\) discrete probability distribution \\(p_k\\), \\(k = 1, \\dots, K\\), can described system non-linear equations: $$ p_{k} = F_{X}\\left( \\frac{x_{k - 1} - \\xi}{\\omega} \\right) - F_{X}\\left( \\frac{x_{k} - \\xi}{\\omega} \\right) \\quad \\text{} \\ k = 1, \\dots, K $$ : \\(F_{X}\\) cumulative distribution function \\(X\\), \\(K\\) number possible response categories, \\(x_{k}\\) endpoints defining boundaries response categories, \\(p_{k}\\) probability \\(k\\)-th response category, \\(\\xi\\) location parameter \\(X\\), \\(\\omega\\) scaling parameter \\(X\\). endpoints \\(x_{k}\\) calculated discretizing random variable \\(Z\\) mean 0 standard deviation 1 follows distribution \\(X\\). solving system non-linear equations iteratively, can find parameters best fit observed discrete probability distribution \\(p_{k}\\). function estimate_params: Computes proportion table responses item. Estimates probabilities \\(p_{k}\\) item. Computes estimates \\(\\xi\\) \\(\\omega\\) item. Combines estimated parameters items table.","code":""},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/reference/estimate_params.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Estimate Latent Parameters — estimate_params","text":"","code":"data(part_bfi) vars <- c(\"A1\", \"A2\", \"A3\", \"A4\", \"A5\") estimate_params(data = part_bfi[, vars], n_levels = 6) #> items #> estimates A1 A2 A3 A4 A5 #> mean -0.9759824 1.0830781 0.9776057 1.1723519 0.9006478 #> sd 1.1798137 0.7968668 0.8432599 1.3825407 0.8648150"},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":null,"dir":"Reference","previous_headings":"","what":"Agreeableness and Gender Data — part_bfi","title":"Agreeableness and Gender Data — part_bfi","text":"dataset cleaned version small part bfi dataset psychTools package. contains responses first 5 items agreeableness scale International Personality Item Pool (IPIP) gender attribute. includes responses 2800 subjects. item answered six point Likert scale ranging 1 (inaccurate), 6 (accurate). Gender coded 0 male 1 female. Missing values addressed using mode imputation.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Agreeableness and Gender Data — part_bfi","text":"","code":"data(part_bfi)"},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Agreeableness and Gender Data — part_bfi","text":"object class \"data.frame\" 2800 observations following 6 variables: A1 indifferent feelings others. A2 Inquire others' well-. A3 Know comfort others. A4 Love children. A5 Make people feel ease. gender Gender respondent.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Agreeableness and Gender Data — part_bfi","text":"International Personality Item Pool (ipip.ori.org) https://search.r-project.org/CRAN/refmans/psychTools/html/bfi.html","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Agreeableness and Gender Data — part_bfi","text":"Revelle, W. (2024). Psych: Procedures Psychological, Psychometric, Personality Research. Evanston, Illinois: Northwestern University. https://CRAN.R-project.org/package=psych","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/part_bfi.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Agreeableness and Gender Data — part_bfi","text":"","code":"data(part_bfi) head(part_bfi) #> A1 A2 A3 A4 A5 gender #> 61617 2 4 3 4 4 0 #> 61618 2 4 5 2 5 1 #> 61620 5 4 5 4 4 1 #> 61621 4 4 6 5 5 1 #> 61622 2 3 3 4 5 0 #> 61623 6 6 5 6 5 1"},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Transformation — plot_likert_transform","title":"Plot Transformation — plot_likert_transform","text":"Plots densities latent variables first row transformed discrete probability distributions .","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Transformation — plot_likert_transform","text":"","code":"plot_likert_transform(n_items, n_levels, mean = 0, sd = 1, skew = 0)"},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Transformation — plot_likert_transform","text":"n_items number Likert scale items (questions). n_levels number response categories Likert item. Integer vector integers. mean means latent variables. Numeric vector numerics. Defaults 0. sd standard deviations latent variables. Numeric vector numerics. Defaults 1. skew marginal skewness latent variables. Numeric vector numerics. Defaults 0.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Transformation — plot_likert_transform","text":"plot showing densities latent variables corresponding discrete probability distributions.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/plot_likert_transform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Transformation — plot_likert_transform","text":"","code":"plot_likert_transform(n_items = 3, n_levels = c(3, 4, 5)) plot_likert_transform(n_items = 3, n_levels = 5, mean=c(0, 1, 2)) plot_likert_transform(n_items = 3, n_levels = 5, sd=c(0.8, 1, 1.2)) plot_likert_transform(n_items = 3, n_levels = 5, skew=c(-0.5, 0, 0.5))"},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate Response Proportions — response_prop","title":"Calculate Response Proportions — response_prop","text":"Returns table proportions possible response category.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate Response Proportions — response_prop","text":"","code":"response_prop(data, n_levels)"},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate Response Proportions — response_prop","text":"data numeric vector matrix responses. n_levels number response categories.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate Response Proportions — response_prop","text":"table response category proportions.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/response_prop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate Response Proportions — response_prop","text":"","code":"data <- c(1, 2, 2, 3, 3, 3) response_prop(data, n_levels = 3) #> 1 2 3 #> 0.1666667 0.3333333 0.5000000 data_matrix <- matrix(c(1, 2, 2, 3, 3, 3), ncol = 2) response_prop(data_matrix, n_levels = 3) #> Response #> Item 1 2 3 #> [1,] 0.3333333 0.6666667 0 #> [2,] 0.0000000 0.0000000 1"},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate Random Responses — rlikert","title":"Generate Random Responses — rlikert","text":"Generates array random responses Likert-type questions based specified latent variables.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate Random Responses — rlikert","text":"","code":"rlikert(size, n_items, n_levels, mean = 0, sd = 1, skew = 0, corr = 0)"},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate Random Responses — rlikert","text":"size number observations. n_items number Likert scale items (number questions). n_levels number response categories item. Integer vector integers. mean means latent variables. Numeric vector numerics. Defaults 0. sd standard deviations latent variables. Numeric vector numerics. Defaults 1. skew marginal skewness latent variables. Numeric vector numerics. Defaults 0. corr correlations latent variables. Can single numeric value representing correlation pairs, actual correlation matrix. Defaults 0.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate Random Responses — rlikert","text":"matrix random responses dimensions size n_items. column names Y1, Y2, ..., Yn n number items. entry matrix represents Likert scale response, ranging 1 n_levels.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/rlikert.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate Random Responses — rlikert","text":"","code":"# Generate responses for a single item with 5 levels rlikert(size = 10, n_items = 1, n_levels = 5) #> [1] 3 5 4 3 3 2 2 3 4 4 # Generate responses for three items with different levels and parameters rlikert( size = 10, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = 0.5 ) #> Y1 Y2 Y3 #> [1,] 3 1 3 #> [2,] 2 1 3 #> [3,] 3 4 2 #> [4,] 2 1 2 #> [5,] 2 2 2 #> [6,] 3 2 2 #> [7,] 3 4 4 #> [8,] 2 1 2 #> [9,] 2 2 4 #> [10,] 3 4 4 # Generate responses with a correlation matrix corr <- matrix(c( 1.00, -0.63, -0.39, -0.63, 1.00, 0.41, -0.39, 0.41, 1.00 ), nrow = 3) data <- rlikert( size = 1000, n_items = 3, n_levels = c(4, 5, 6), mean = c(0, -1, 0), sd = c(0.8, 1, 1), corr = corr )"},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulate Likert Scale Item Responses — simulate_likert","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"Simulates Likert scale item responses based specified number response categories centered parameters latent variable.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"","code":"simulate_likert(n_levels, cp)"},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"n_levels Integer. number response categories Likert scale item. cp Named vector. centered parameters latent variable, including mean (mu), standard deviation (sd), skewness (skew). Skewness must -0.95 0.95.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"named vector probabilities response category.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"simulation process uses following model proposed Boari Nai-Ruscone. Let \\(X\\) continuous variable interest, measured using Likert scale questions \\(K\\) response categories. observed discrete variable \\(Y\\) defined follows: $$ Y = k, \\quad \\text{ } \\ \\ x_{k - 1} < X \\leq x_{k} \\quad \\text{ } \\ \\ k = 1, \\dots, K $$ \\(x_{k}\\), \\(k = 0, \\dots, K\\) endpoints defined domain \\(X\\) : $$ -\\infty = x_{0} < x_{1} < \\dots < x_{K - 1} < x_{K} = \\infty. $$ endpoints dictate transformation density \\(f_{X}\\) \\(X\\) discrete probability distribution: $$ \\text{Pr}(Y = k) = \\int_{x_{k - 1}}^{x_{k}} f_{X}(x) \\, dx \\quad \\text{ } \\ \\ k = 1, \\dots, K. $$ continuous latent variable modeled using skew normal distribution. function simulate_likert performs following steps: Ensures centered parameters within acceptable range. Converts centered parameters direct parameters. Defines density function skew normal distribution. Computes probabilities response category using optimal endpoints.","code":""},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"Boari, G. Nai Ruscone, M. (2015). procedure simulating likert scale item responses. Electronic journal applied statistical analysis 8(3), 288–297. doi:10.1285/i20705948v8n3p288","code":""},{"path":[]},{"path":"https://markolalovic.github.io/latent2likert/reference/simulate_likert.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulate Likert Scale Item Responses — simulate_likert","text":"","code":"cp <- c(mu = 0, sd = 1, skew = 0.5) simulate_likert(n_levels = 5, cp = cp) #> 1 2 3 4 5 #> 0.15995244 0.29511214 0.28435807 0.18964493 0.07093241 cp2 <- c(mu = 1, sd = 2, skew = -0.3) simulate_likert(n_levels = 7, cp = cp2) #> 1 2 3 4 5 6 7 #> 0.08311645 0.07169556 0.07928979 0.08940184 0.10477572 0.13413804 0.43758260"},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-010-release-date-2020-10-17","dir":"Changelog","previous_headings":"","what":"latent2likert 0.1.0 (Release date: 2020-10-17)","title":"latent2likert 0.1.0 (Release date: 2020-10-17)","text":"Initial release (development version). Tested platforms: x86_64-pc-linux-gnu (64-bit) x86_64-w64-mingw32 (64-bit).","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-100-release-date-2024-03-28","dir":"Changelog","previous_headings":"","what":"latent2likert 1.0.0 (Release date: 2024-03-28)","title":"latent2likert 1.0.0 (Release date: 2024-03-28)","text":"option generate correlated Likert scale items added function rLikert(). New function estimate_parameters() added allows estimation parameters existing survey data replicate accurately. Issues related dependencies resolved. version now imports standard R packages mvtnorm, stats, graphics packages stats graphics, typically included R releases. package sn necessary generating correlated responses based skew normal distribution. Added user prompts installing sn package necessary.","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-110-release-date-2024-06-06","dir":"Changelog","previous_headings":"","what":"latent2likert 1.1.0 (Release date: 2024-06-06)","title":"latent2likert 1.1.0 (Release date: 2024-06-06)","text":"minor update functions vignettes.","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-111-release-date-2024-06-06","dir":"Changelog","previous_headings":"","what":"latent2likert 1.1.1 (Release date: 2024-06-06)","title":"latent2likert 1.1.1 (Release date: 2024-06-06)","text":"package renamed responsesR latent2likert. capture essence converting latent variables Likert scale responses. Improvements package website documentation.","code":""},{"path":"https://markolalovic.github.io/latent2likert/news/index.html","id":"latent2likert-121-release-date-2024-06-12","dir":"Changelog","previous_headings":"","what":"latent2likert 1.2.1 (Release date: 2024-06-12)","title":"latent2likert 1.2.1 (Release date: 2024-06-12)","text":"Refactored code improved modularity maintainability. Modularized core functions better readability. Improved structure organization codebase. Improved error handling different cases correlations input. Updated estimate_parameters() function estimating latent parameters survey data. codebase currently development, finer details may change.","code":""}]