Skip to content

Commit

Permalink
CRAN release
Browse files Browse the repository at this point in the history
  • Loading branch information
markolalovic committed Jun 25, 2024
1 parent cd4fc3c commit a435c37
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 67 deletions.
7 changes: 4 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![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)
<!-- badges: end -->

## Overview
Expand All @@ -27,10 +28,10 @@ The **latent2likert** package is designed to effectively simulate the discretiza

## Installation

You can install the development version from GitHub with:
You can install the latest version from CRAN:

```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("markolalovic/latent2likert")
install.packages("latent2likert")
```

## Dependencies
Expand Down
41 changes: 20 additions & 21 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ <h1 id="latent2likert-">latent2likert
</g>
<svg viewBox="120 -8 60 60">
<path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd" />
</svg></a></p>
</svg></a> <a href="https://CRAN.R-project.org/package=latent2likert"><img role="img" aria-label="CRAN status" src="data:image/svg+xml; charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4NSIgaGVpZ2h0PSIyMCIgYXJpYS1sYWJlbD0iQ1JBTiAxLjIuMSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJiIiB4Mj0iMCIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjYmJiIiBzdG9wLW9wYWNpdHk9Ii4xIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEiIHN0b3Atb3BhY2l0eT0iLjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxtYXNrIGlkPSJhIj4KICAgIDxyZWN0IHdpZHRoPSI4NSIgaGVpZ2h0PSIyMCIgcng9IjMiIGZpbGw9IiNmZmYiLz4KICA8L21hc2s+CiAgPGcgbWFzaz0idXJsKCNhKSI+CiAgICA8cGF0aCBmaWxsPSIjNTU1IiBkPSJNMCAwaDQzdjIwSDB6Ii8+CiAgICA8cGF0aCBmaWxsPSIjNGMxIiBkPSJNNDMgMGg2M3YyMEg0M3oiLz4KICAgIDxwYXRoIGZpbGw9InVybCgjYikiIGQ9Ik0wIDBoODV2MjBIMHoiLz4KICA8L2c+CiAgPGcgZmlsbD0iI2ZmZiIgdGV4dC1hbmNob3I9Im1pZGRsZSIKICAgICBmb250LWZhbWlseT0iRGVqYVZ1IFNhbnMsVmVyZGFuYSxHZW5ldmEsc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxMSI+CiAgICA8dGV4dCB4PSIyMS41IiB5PSIxNSIgZmlsbD0iIzAxMDEwMSIgZmlsbC1vcGFjaXR5PSIuMyI+CiAgICAgIENSQU4KICAgIDwvdGV4dD4KICAgIDx0ZXh0IHg9IjIxLjUiIHk9IjE0Ij4KICAgICAgQ1JBTgogICAgPC90ZXh0PgogICAgPHRleHQgeD0iNjMiIHk9IjE1IiBmaWxsPSIjMDEwMTAxIiBmaWxsLW9wYWNpdHk9Ii4zIj4KICAgICAgMS4yLjEKICAgIDwvdGV4dD4KICAgIDx0ZXh0IHg9IjYzIiB5PSIxNCI+CiAgICAgIDEuMi4xCiAgICA8L3RleHQ+CiAgPC9nPgo8L3N2Zz4=" alt="CRAN status" /></a></p>
<!-- badges: end -->

<h2 id="overview">Overview</h2>
Expand All @@ -640,9 +640,8 @@ <h2 id="overview">Overview</h2>
that use Likert scales, especially when applying statistical techniques
that require metric data.</p>
<h2 id="installation">Installation</h2>
<p>You can install the development version from GitHub with:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="co"># install.packages(&quot;devtools&quot;)</span></span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a>devtools<span class="sc">::</span><span class="fu">install_github</span>(<span class="st">&quot;markolalovic/latent2likert&quot;</span>)</span></code></pre></div>
<p>You can install the latest version from CRAN:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">&quot;latent2likert&quot;</span>)</span></code></pre></div>
<h2 id="dependencies">Dependencies</h2>
<p>To keep the package lightweight, <strong>latent2likert</strong> only
imports <a href="https://cran.r-project.org/package=mvtnorm">mvtnorm</a>, along
Expand Down Expand Up @@ -674,7 +673,7 @@ <h2 id="using-rlikert">Using <code>rlikert</code></h2>
Likert scale, use:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a><span class="fu">library</span>(latent2likert)</span>
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a><span class="fu">rlikert</span>(<span class="at">size =</span> <span class="dv">10</span>, <span class="at">n_items =</span> <span class="dv">1</span>, <span class="at">n_levels =</span> <span class="dv">5</span>)</span>
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a><span class="co">#&gt; [1] 2 5 2 3 3 1 2 2 1 5</span></span></code></pre></div>
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a><span class="co">#&gt; [1] 4 2 3 2 3 5 2 2 3 2</span></span></code></pre></div>
<p>To generate responses to multiple items with specified
parameters:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="fu">rlikert</span>(<span class="at">size =</span> <span class="dv">10</span>,</span>
Expand All @@ -684,16 +683,16 @@ <h2 id="using-rlikert">Using <code>rlikert</code></h2>
<span id="cb3-5"><a href="#cb3-5" tabindex="-1"></a> <span class="at">sd =</span> <span class="fu">c</span>(<span class="fl">0.8</span>, <span class="dv">1</span>, <span class="dv">1</span>),</span>
<span id="cb3-6"><a href="#cb3-6" tabindex="-1"></a> <span class="at">corr =</span> <span class="fl">0.5</span>)</span>
<span id="cb3-7"><a href="#cb3-7" tabindex="-1"></a><span class="co">#&gt; Y1 Y2 Y3</span></span>
<span id="cb3-8"><a href="#cb3-8" tabindex="-1"></a><span class="co">#&gt; [1,] 4 3 5</span></span>
<span id="cb3-9"><a href="#cb3-9" tabindex="-1"></a><span class="co">#&gt; [2,] 3 2 3</span></span>
<span id="cb3-10"><a href="#cb3-10" tabindex="-1"></a><span class="co">#&gt; [3,] 3 3 3</span></span>
<span id="cb3-11"><a href="#cb3-11" tabindex="-1"></a><span class="co">#&gt; [4,] 2 3 4</span></span>
<span id="cb3-12"><a href="#cb3-12" tabindex="-1"></a><span class="co">#&gt; [5,] 2 3 4</span></span>
<span id="cb3-13"><a href="#cb3-13" tabindex="-1"></a><span class="co">#&gt; [6,] 3 2 4</span></span>
<span id="cb3-14"><a href="#cb3-14" tabindex="-1"></a><span class="co">#&gt; [7,] 3 1 3</span></span>
<span id="cb3-15"><a href="#cb3-15" tabindex="-1"></a><span class="co">#&gt; [8,] 2 1 3</span></span>
<span id="cb3-16"><a href="#cb3-16" tabindex="-1"></a><span class="co">#&gt; [9,] 2 1 6</span></span>
<span id="cb3-17"><a href="#cb3-17" tabindex="-1"></a><span class="co">#&gt; [10,] 3 1 3</span></span></code></pre></div>
<span id="cb3-8"><a href="#cb3-8" tabindex="-1"></a><span class="co">#&gt; [1,] 2 1 3</span></span>
<span id="cb3-9"><a href="#cb3-9" tabindex="-1"></a><span class="co">#&gt; [2,] 4 4 6</span></span>
<span id="cb3-10"><a href="#cb3-10" tabindex="-1"></a><span class="co">#&gt; [3,] 3 3 4</span></span>
<span id="cb3-11"><a href="#cb3-11" tabindex="-1"></a><span class="co">#&gt; [4,] 4 3 5</span></span>
<span id="cb3-12"><a href="#cb3-12" tabindex="-1"></a><span class="co">#&gt; [5,] 2 1 6</span></span>
<span id="cb3-13"><a href="#cb3-13" tabindex="-1"></a><span class="co">#&gt; [6,] 3 2 3</span></span>
<span id="cb3-14"><a href="#cb3-14" tabindex="-1"></a><span class="co">#&gt; [7,] 3 1 4</span></span>
<span id="cb3-15"><a href="#cb3-15" tabindex="-1"></a><span class="co">#&gt; [8,] 3 2 2</span></span>
<span id="cb3-16"><a href="#cb3-16" tabindex="-1"></a><span class="co">#&gt; [9,] 2 2 2</span></span>
<span id="cb3-17"><a href="#cb3-17" tabindex="-1"></a><span class="co">#&gt; [10,] 2 1 2</span></span></code></pre></div>
<p>You can also provide a correlation matrix:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a>corr <span class="ot">&lt;-</span> <span class="fu">matrix</span>(<span class="fu">c</span>(<span class="fl">1.00</span>, <span class="sc">-</span><span class="fl">0.63</span>, <span class="sc">-</span><span class="fl">0.39</span>, </span>
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a> <span class="sc">-</span><span class="fl">0.63</span>, <span class="fl">1.00</span>, <span class="fl">0.41</span>, </span>
Expand All @@ -709,17 +708,17 @@ <h2 id="using-rlikert">Using <code>rlikert</code></h2>
and these estimates are typically lower:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="fu">cor</span>(data)</span>
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a><span class="co">#&gt; Y1 Y2 Y3</span></span>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="co">#&gt; Y1 1.0000000 -0.5277858 -0.3678057</span></span>
<span id="cb5-4"><a href="#cb5-4" tabindex="-1"></a><span class="co">#&gt; Y2 -0.5277858 1.0000000 0.3983187</span></span>
<span id="cb5-5"><a href="#cb5-5" tabindex="-1"></a><span class="co">#&gt; Y3 -0.3678057 0.3983187 1.0000000</span></span></code></pre></div>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="co">#&gt; Y1 1.0000000 -0.5485779 -0.3830635</span></span>
<span id="cb5-4"><a href="#cb5-4" tabindex="-1"></a><span class="co">#&gt; Y2 -0.5485779 1.0000000 0.3787044</span></span>
<span id="cb5-5"><a href="#cb5-5" tabindex="-1"></a><span class="co">#&gt; Y3 -0.3830635 0.3787044 1.0000000</span></span></code></pre></div>
<h2 id="using-estimate_params">Using <code>estimate_params</code></h2>
<p>Given the data, you can estimate the values of latent parameters
using:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a><span class="fu">estimate_params</span>(data, <span class="at">n_levels =</span> <span class="fu">c</span>(<span class="dv">4</span>, <span class="dv">5</span>, <span class="dv">6</span>), <span class="at">skew =</span> <span class="dv">0</span>)</span>
<span id="cb6-2"><a href="#cb6-2" tabindex="-1"></a><span class="co">#&gt; items</span></span>
<span id="cb6-3"><a href="#cb6-3" tabindex="-1"></a><span class="co">#&gt; estimates Y1 Y2 Y3</span></span>
<span id="cb6-4"><a href="#cb6-4" tabindex="-1"></a><span class="co">#&gt; mean 0.08270757 -1.10356623 0.01029328</span></span>
<span id="cb6-5"><a href="#cb6-5" tabindex="-1"></a><span class="co">#&gt; sd 0.79986937 1.06032921 1.01115089</span></span></code></pre></div>
<span id="cb6-3"><a href="#cb6-3" tabindex="-1"></a><span class="co">#&gt; estimates Y1 Y2 Y3</span></span>
<span id="cb6-4"><a href="#cb6-4" tabindex="-1"></a><span class="co">#&gt; mean 0.002700821 -0.949328033 0.011770264</span></span>
<span id="cb6-5"><a href="#cb6-5" tabindex="-1"></a><span class="co">#&gt; sd 0.790723208 1.017877712 0.995988467</span></span></code></pre></div>
<h2 id="transformation">Transformation</h2>
<p>To visualize the transformation, you can use
<code>plot_likert_transform()</code>. It plots the densities of latent
Expand Down
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

[![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)
<!-- badges: end -->

## Overview
Expand All @@ -21,11 +23,10 @@ metric data.

## Installation

You can install the development version from GitHub with:
You can install the latest version from CRAN:

``` r
# install.packages("devtools")
devtools::install_github("markolalovic/latent2likert")
install.packages("latent2likert")
```

## Dependencies
Expand Down Expand Up @@ -64,7 +65,7 @@ scale, use:
``` r
library(latent2likert)
rlikert(size = 10, n_items = 1, n_levels = 5)
#> [1] 1 2 5 5 2 3 4 2 4 4
#> [1] 4 2 3 2 3 5 2 2 3 2
```

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

You can also provide a correlation matrix:
Expand All @@ -110,9 +111,9 @@ these estimates are typically lower:
``` r
cor(data)
#> Y1 Y2 Y3
#> Y1 1.0000000 -0.5452650 -0.3539568
#> Y2 -0.5452650 1.0000000 0.3084354
#> Y3 -0.3539568 0.3084354 1.0000000
#> Y1 1.0000000 -0.5485779 -0.3830635
#> Y2 -0.5485779 1.0000000 0.3787044
#> Y3 -0.3830635 0.3787044 1.0000000
```

## Using `estimate_params`
Expand All @@ -122,9 +123,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.04691194 -1.01865288 0.01471470
#> sd 0.77732152 0.96811355 1.01830061
#> estimates Y1 Y2 Y3
#> mean 0.002700821 -0.949328033 0.011770264
#> sd 0.790723208 1.017877712 0.995988467
```

## Transformation
Expand Down
Loading

0 comments on commit a435c37

Please sign in to comment.