Skip to content

Commit

Permalink
exported estimate_mean_and_sd, incremented package version to 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
markolalovic committed Jul 26, 2024
1 parent 7449425 commit 5468ad7
Show file tree
Hide file tree
Showing 30 changed files with 330 additions and 168 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: latent2likert
Title: Converting Latent Variables into Likert Scale Responses
Version: 1.2.1
Version: 1.2.2
Authors@R:
person("Marko", "Lalovic", , "[email protected]", role = c("aut", "cre"))
Description: Effectively simulates the discretization process inherent to
Expand All @@ -11,17 +11,17 @@ Description: Effectively simulates the discretization process inherent to
survey data that use Likert scales, especially when applying
statistical techniques that require metric data.
License: MIT + file LICENSE
URL: https://lalovic.io/latent2likert/
URL: https://latent2likert.lalovic.io/
BugReports: https://github.com/markolalovic/latent2likert/issues/
Depends:
R (>= 3.5)
Imports:
graphics,
mvtnorm,
sn,
stats,
utils
Suggests:
sn,
knitr,
rmarkdown,
testthat (>= 3.0.0)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(discretize_density)
export(estimate_mean_and_sd)
export(estimate_params)
export(plot_likert_transform)
export(response_prop)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@
- Modularized core functions for improved readability.
- Improved the structure and organization of the codebase.
- Enhanced error handling for various correlation input scenarios.

## Version 1.2.2
- Release date: 2024-07-26
- Exported previously internal function `estimate_mean_and_sd` based on user feedback, now available for direct use.
- Moved the package `sn` to Suggests.
- Fixed vignette building errors.
2 changes: 1 addition & 1 deletion R/estimation.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ estimate_params <- function(data, n_levels, skew = 0) {
#' responses. The algorithm ensures stability by reparameterizing the system
#' and applying constraints to prevent stepping into invalid regions.
#'
#' @noRd
#' @export
estimate_mean_and_sd <- function(prob, n_levels, skew = 0,
eps = 1e-6, maxit = 100) {
prob <- as.vector(pad_levels(prob, n_levels))
Expand Down
7 changes: 6 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ The **latent2likert** package is designed to effectively simulate the discretiza

## Installation

You can install the latest version from CRAN:
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.
Expand Down
127 changes: 57 additions & 70 deletions README.html

Large diffs are not rendered by default.

48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ metric data.

## Installation

You can install the latest version from CRAN:
You can install the released version from CRAN:

``` r
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
Expand All @@ -51,10 +57,13 @@ install this dependency during interactive sessions if needed.
## Structure

<figure>

<img src="man/figures/overview-min.png" width="80%" alt="Overview of inputs and outputs"/>
<figcaption>

<em>Overview of inputs and outputs.</em>
</figcaption>

</figure>

## Using `rlikert`
Expand All @@ -67,7 +76,7 @@ scale, use:
``` r
library(latent2likert)
rlikert(size = 10, n_items = 1, n_levels = 5)
#> [1] 2 5 2 2 3 2 4 4 3 3
#> [1] 4 4 2 3 5 2 4 2 3 3
```

To generate responses to multiple items with specified parameters:
Expand All @@ -80,16 +89,16 @@ rlikert(size = 10,
sd = c(0.8, 1, 1),
corr = 0.5)
#> Y1 Y2 Y3
#> [1,] 3 4 3
#> [2,] 1 2 1
#> [3,] 3 1 3
#> [4,] 2 1 3
#> [5,] 2 1 4
#> [6,] 2 2 5
#> [7,] 3 2 5
#> [8,] 1 1 2
#> [9,] 3 2 3
#> [10,] 2 2 3
#> [1,] 3 2 4
#> [2,] 2 1 1
#> [3,] 2 1 2
#> [4,] 3 2 4
#> [5,] 2 2 4
#> [6,] 2 3 5
#> [7,] 3 1 2
#> [8,] 2 2 3
#> [9,] 2 3 5
#> [10,] 3 2 5
```

You can also provide a correlation matrix:
Expand All @@ -113,9 +122,9 @@ these estimates are typically lower:
``` r
cor(data)
#> Y1 Y2 Y3
#> Y1 1.0000000 -0.5384098 -0.3715239
#> Y2 -0.5384098 1.0000000 0.4012943
#> Y3 -0.3715239 0.4012943 1.0000000
#> Y1 1.0000000 -0.5223151 -0.3449648
#> Y2 -0.5223151 1.0000000 0.3398699
#> Y3 -0.3449648 0.3398699 1.0000000
```

## Using `estimate_params`
Expand All @@ -125,9 +134,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.06292803 -0.98863044 0.10704210
#> sd 0.81566374 1.08402520 0.95083534
#> estimates Y1 Y2 Y3
#> mean 0.006261483 -0.952847125 -0.011843866
#> sd 0.745185144 1.012219189 0.954714824
```

## Transformation
Expand All @@ -145,11 +154,14 @@ plot_likert_transform(n_items = 3,
```

<figure>

<img src="man/figures/transformation-min.png" width="80%" alt="Transformation of latent variables to Likert response variables"/>
<figcaption>

<em>Transformation of latent variables to Likert response
variables.</em>
</figcaption>

</figure>

<br>
Expand Down
24 changes: 0 additions & 24 deletions dev/fix_site.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/using_latent2likert.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5468ad7

Please sign in to comment.