Skip to content

Commit 8f58480

Browse files
Release: 1.7.2
2 parents 725d118 + 73c562e commit 8f58480

File tree

7 files changed

+54
-14
lines changed

7 files changed

+54
-14
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: powerly
22
Title: Sample Size Analysis for Psychological Networks and More
3-
Version: 1.7.1
3+
Version: 1.7.2
44
Authors@R:
55
person(given = "Mihai",
66
family = "Constantin",

NEWS.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# `powerly` `1.7.2`
2+
3+
## Improvements
4+
5+
* Update GGM estimation test to check if the estimation fails when variables
6+
with zero standard deviation are present in the generated data.
7+
8+
* Update GGM estimation to fail when the generated data contains at least one
9+
variable that has a standard deviation equal to zero (i.e., as a result of
10+
generating data with a sample size value that is too low).
11+
12+
* Add GitHub badges with latest release version and number of open issues.
13+
14+
## Bug fixes
15+
16+
* Add tolerance (i.e., `0.0000001` for test checking whether the spline
17+
coefficients are estimated correctly).
18+
19+
* Fix test for the updating of the bounds of a `Range` instance to run only when
20+
the the 2.5th and 97.5th selected sample sizes are different quantities.
21+
22+
* Fix bug in GGM data generating test where the number of nodes to generate data
23+
for were incorrectly sampled.
24+
125
# `powerly` `1.7.1`
226

327
## Improvements

R/GgmModel.R

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ GgmModel <- R6::R6Class("GgmModel",
2424
},
2525

2626
estimate = function(data, gamma = 0.5) {
27+
# Ensure all variables show variance.
28+
if (sum(apply(data, 2, sd) == 0) > 0) {
29+
stop("Variable(s) with SD = 0 detected. Increase the sample size.")
30+
}
31+
2732
# Estimate network using `qgraph`.
2833
network <- suppressMessages(suppressWarnings(
2934
qgraph::EBICglasso(

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
</p>
1010

1111
<p align="center">
12-
<a align="center" href="https://github.com/mihaiconstantin/powerly/actions"><img src="https://github.com/mihaiconstantin/powerly/workflows/R-CMD-check/badge.svg" alt="R-CMD-check" /></a>
12+
<a href="https://github.com/mihaiconstantin/powerly/releases"><img src="https://img.shields.io/github/v/release/mihaiconstantin/powerly?display_name=tag&sort=semver"/></a>
1313
<a href="https://www.r-pkg.org/pkg/powerly"><img src="https://www.r-pkg.org/badges/version/powerly" alt="CRAN version"/></a>
14-
<a href="https://cranchecks.info/pkgs/powerly"><img src="https://cranchecks.info/badges/worst/powerly" alt="CRAN checks"/></a>
15-
<a href="https://app.codecov.io/gh/mihaiconstantin/powerly"><img src="https://codecov.io/gh/mihaiconstantin/powerly/branch/main/graph/badge.svg?token=YUCO8ULBCM" alt="Code coverage"/></a>
1614
<a href="https://www.repostatus.org/#active"><img src="https://www.repostatus.org/badges/latest/active.svg" alt="Repository status"/></a>
15+
<a href="https://app.codecov.io/gh/mihaiconstantin/powerly"><img src="https://codecov.io/gh/mihaiconstantin/powerly/branch/main/graph/badge.svg?token=YUCO8ULBCM" alt="Code coverage"/></a>
16+
<a href="https://github.com/mihaiconstantin/powerly/issues"><img src="https://img.shields.io/github/issues/mihaiconstantin/powerly"/></a>
1717
<a href="https://www.r-pkg.org/pkg/powerly"><img src="https://cranlogs.r-pkg.org/badges/grand-total/powerly" alt="CRAN RStudio mirror downloads"/></a>
18+
<a href="https://github.com/mihaiconstantin/powerly/actions"><img src="https://github.com/mihaiconstantin/powerly/workflows/R-CMD-check/badge.svg" alt="R-CMD-check" /></a>
19+
<a href="https://cranchecks.info/pkgs/powerly"><img src="https://cranchecks.info/badges/worst/powerly" alt="CRAN checks"/></a>
1820
</p>
1921

2022
## Description

tests/testthat/test-ggm.R

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test_that("'GgmModel' generates data correctly", {
88
max_level <- sample(3:5, 1)
99

1010
# Nodes.
11-
nodes <- sample(10:20)
11+
nodes <- sample(10:20, 1)
1212

1313
# Density.
1414
density <- sample(seq(.2, .5, .1), 1)
@@ -40,7 +40,7 @@ test_that("'GgmModel' generated data matches bootnet data", {
4040
max_level <- sample(3:5, 1)
4141

4242
# Nodes.
43-
nodes <- sample(10:20)
43+
nodes <- sample(10:20, 1)
4444

4545
# Density.
4646
density <- sample(seq(.2, .5, .1), 1)
@@ -75,7 +75,7 @@ test_that("'GgmModel' estimates model parameters correctly", {
7575
max_level <- sample(3:5, 1)
7676

7777
# Nodes.
78-
nodes <- sample(10:20)
78+
nodes <- sample(10:20, 1)
7979

8080
# Density.
8181
density <- sample(seq(.2, .5, .1), 1)
@@ -97,6 +97,12 @@ test_that("'GgmModel' estimates model parameters correctly", {
9797

9898
# The parameters should be identical across both methods.
9999
expect_equal(network_qgraph, network_ggm_model, ignore_attr = TRUE)
100+
101+
# Make one variable invariant.
102+
data[, 1] <- data[1, 1]
103+
104+
# Expect the estimation to throw an error due to invariant variables.
105+
expect_error(ggm$estimate(data), "Variable\\(s\\) with SD = 0 detected. Increase the sample size.")
100106
})
101107

102108

@@ -108,7 +114,7 @@ test_that("'GgmModel' computes the correct measure", {
108114
max_level <- sample(3:5, 1)
109115

110116
# Nodes.
111-
nodes <- sample(10:20)
117+
nodes <- sample(10:20, 1)
112118

113119
# Density.
114120
density <- sample(seq(.2, .5, .1), 1)

tests/testthat/test-range.R

+8-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ test_that("'Range' updates bounds correctly based on 'StepThree' confidence inte
7272
expect_equal(min(range$partition), as.numeric(step_3$samples["2.5%"]))
7373
expect_equal(max(range$partition), as.numeric(step_3$samples["97.5%"]))
7474

75-
# Expect that the bounds are of increasing size.
76-
expect_error(
77-
range$update_bounds(step_3, lower_ci = 0.975, upper_ci = 0.025),
78-
"The lower bound cannot be greater that the upper bound."
79-
)
75+
# If the selected samples are not a single quantity.
76+
if(step_3$samples["2.5%"] < step_3$samples["97.5%"]) {
77+
# Expect that the bounds are of increasing size.
78+
expect_error(
79+
range$update_bounds(step_3, lower_ci = 0.975, upper_ci = 0.025),
80+
"The lower bound cannot be greater that the upper bound."
81+
)
82+
}
8083
})
8184

8285

tests/testthat/test-step-two.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ test_that("'StepTwo' fits and interpolates a spline correctly", {
126126
expect_equal(step_2$spline$basis$matrix, basis)
127127

128128
# The estimated spline coefficients should be equal.
129-
expect_equal(step_2$spline$alpha, alpha)
129+
expect_equal(step_2$spline$alpha, alpha, tolerance = 0.0000001)
130130

131131
# The fitted values should be equal.
132132
expect_equal(step_2$spline$fitted, fitted)

0 commit comments

Comments
 (0)