latent2likert

Converting latent variables into Likert scale responses

https://github.com/markolalovic/latent2likert

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (20.8%) to scientific vocabulary

Keywords

likert likert-data simulation survey-data
Last synced: 4 months ago · JSON representation

Repository

Converting latent variables into Likert scale responses

Basic Info
Statistics
  • Stars: 19
  • Watchers: 2
  • Forks: 2
  • Open Issues: 0
  • Releases: 7
Topics
likert likert-data simulation survey-data
Created about 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Codemeta

README.Rmd

---
output: github_document
---



```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  dpi=250,
  out.width = "70%")
```

# latent2likert Package logo


[![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](https://codecov.io/gh/markolalovic/latent2likert/branch/main/graph/badge.svg?token=HZTG6RUB2J)](https://app.codecov.io/gh/markolalovic/latent2likert)
[![CRAN status](https://www.r-pkg.org/badges/version/latent2likert)](https://CRAN.R-project.org/package=latent2likert)
[![downloads](https://cranlogs.r-pkg.org/badges/latent2likert)](https://cranlogs.r-pkg.org/badges/latent2likert)


## Overview

The **latent2likert** package is designed to effectively simulate the discretization process inherent to Likert scales while minimizing distortion. It converts continuous latent variables into ordinal categories to generate Likert scale item responses. This is particularly useful for accurately modeling and analyzing survey data that use Likert scales, especially when applying statistical techniques that require metric data.


## Installation

You can install the released version from CRAN:

```{r, eval = FALSE}
install.packages("latent2likert")
```

Or the latest development version from GitHub:
``` r
devtools::install_github("markolalovic/latent2likert")
```

## Dependencies

To keep the package lightweight, **latent2likert** only imports [mvtnorm](https://cran.r-project.org/package=mvtnorm), along with the standard R packages stats and graphics, which are typically included in R releases. An additional suggested dependency is the package [sn](https://cran.r-project.org/package=sn), which is required only for generating random responses from correlated Likert items based on a multivariate skew normal distribution. The package prompts the user to install this dependency during interactive sessions if needed.

## Features

* `rlikert`: Generates random responses to Likert scale questions based on specified means and standard deviations of latent variables, with optional settings for skewness and correlations.
* `estimate_params`: Estimates latent parameters from existing survey data.


## Structure

Overview of inputs and outputs
Overview of inputs and outputs.
## Using `rlikert` You can use the `rlikert` function to simulate Likert item responses. To generate a sample of random responses to one item on a 5-point Likert scale, use: ```{r} library(latent2likert) rlikert(size = 10, n_items = 1, n_levels = 5) ``` To generate responses to multiple items with specified parameters: ```{r} 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) ``` You can also provide a correlation matrix: ```{r} 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) ``` Note that the correlations among the Likert response variables are only estimates of the actual correlations between the latent variables, and these estimates are typically lower: ```{r} cor(data) ``` ## Using `estimate_params` Given the data, you can estimate the values of latent parameters using: ```{r} estimate_params(data, n_levels = c(4, 5, 6), skew = 0) ``` ## Transformation To visualize the transformation, you can use `plot_likert_transform()`. It plots the densities of latent variables in the first row and transformed discrete probability distributions below: ```{r, eval = FALSE} 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)) ```
Transformation of latent variables to Likert response variables
Transformation of latent variables to Likert response variables.

Note that, depending on the value of the skewness parameter, the normal latent distribution is used if skew = 0, otherwise the skew normal distribution is used. The value of skewness is restricted to the range -0.95 to 0.95, that is > `skew >= -0.95` and `skew <= 0.95`. ## Further Reading * 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 Alternatively, you can simulate Likert item responses using the `draw_likert` function from the [fabricatr](https://CRAN.R-project.org/package=fabricatr) package. This function recodes a latent variable into a Likert response variable by specifying intervals that subdivide the continuous range. The **latent2likert** package, however, offers an advantage by automatically calculating optimal intervals that minimize distortion between the latent variable and the Likert response variable for both normal and skew normal latent distributions, eliminating the need to manually specify the intervals. There are also several alternative approaches that do not rely on latent distributions. One method involves directly defining a discrete probability distribution and sampling from it using the `sample` function in R or the `likert` function from the [wakefield](https://CRAN.R-project.org/package=wakefield) package. Another approach is to specify the means, standard deviations, and correlations among Likert response variables. For this, you can use [LikertMakeR](https://CRAN.R-project.org/package=LikertMakeR) or [SimCorMultRes](https://CRAN.R-project.org/package=SimCorMultRes) to generate correlated multinomial responses. Additionally, you can define a data generating process. For those familiar with item response theory, the [mirt](https://CRAN.R-project.org/package=mirt) package allows users to specify discrimination and difficulty parameters for each response category.

Owner

  • Name: Marko Lalovic
  • Login: markolalovic
  • Kind: user
  • Location: Hamburg, Germany

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "identifier": "latent2likert",
  "description": "Effectively simulates the discretization process inherent to Likert scales while minimizing distortion. It converts continuous latent variables into ordinal categories to generate Likert scale item responses. Particularly useful for accurately modeling and analyzing survey data that use Likert scales, especially when applying statistical techniques that require metric data.",
  "name": "latent2likert: Converting Latent Variables Into Likert Scale Responses",
  "codeRepository": "https://github.com/markolalovic/latent2likert",
  "issueTracker": "https://github.com/markolalovic/latent2likert/issues/",
  "license": "https://spdx.org/licenses/MIT",
  "version": "1.2.1",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 4.4.0 (2024-04-24)",
  "author": [
    {
      "@type": "Person",
      "givenName": "Marko",
      "familyName": "Lalovic",
      "email": "marko@lalovic.io"
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Marko",
      "familyName": "Lalovic",
      "email": "marko@lalovic.io"
    }
  ],
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "sn",
      "name": "sn",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=sn"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "cowplot",
      "name": "cowplot",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=cowplot"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "GGally",
      "name": "GGally",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=GGally"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "ggh4x",
      "name": "ggh4x",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=ggh4x"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "gridExtra",
      "name": "gridExtra",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=gridExtra"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=knitr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "psych",
      "name": "psych",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=psych"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "RColorBrewer",
      "name": "RColorBrewer",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=RColorBrewer"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "rmarkdown",
      "name": "rmarkdown",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rmarkdown"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat",
      "version": ">= 3.0.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=testthat"
    }
  ],
  "softwareRequirements": {
    "1": {
      "@type": "SoftwareApplication",
      "identifier": "R",
      "name": "R",
      "version": ">= 3.5"
    },
    "2": {
      "@type": "SoftwareApplication",
      "identifier": "graphics",
      "name": "graphics"
    },
    "3": {
      "@type": "SoftwareApplication",
      "identifier": "mvtnorm",
      "name": "mvtnorm",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=mvtnorm"
    },
    "4": {
      "@type": "SoftwareApplication",
      "identifier": "stats",
      "name": "stats"
    },
    "SystemRequirements": null
  },
  "fileSize": "2130.159KB",
  "relatedLink": "https://lalovic.io/latent2likert/",
  "releaseNotes": "https://github.com/markolalovic/latent2likert/blob/master/NEWS.md",
  "readme": "https://github.com/markolalovic/latent2likert/blob/main/README.md",
  "contIntegration": [
    "https://github.com/markolalovic/latent2likert/actions/workflows/R-CMD-check.yaml",
    "https://app.codecov.io/gh/markolalovic/latent2likert?branch=main"
  ],
  "keywords": [
    "simulation",
    "likert",
    "survey-data",
    "likert-data"
  ]
}

GitHub Events

Total
  • Watch event: 4
  • Fork event: 1
Last Year
  • Watch event: 4
  • Fork event: 1