Skip to content
Merged
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: parameters
Title: Processing of Model Parameters
Version: 0.30.0.11
Version: 0.30.0.12
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ S3method(standard_error,cpglmm)
S3method(standard_error,crch)
S3method(standard_error,crq)
S3method(standard_error,data.frame)
S3method(standard_error,datawizard_kurtosis)
S3method(standard_error,datawizard_skewness)
S3method(standard_error,default)
S3method(standard_error,deltaMethod)
S3method(standard_error,draws)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
this failed with an error. An invalid value for `p_adjust` no longer shows the
method in the footer of the printed output (#854).

* Fixed issue where `standard_error()` returned `NULL` for objects from
`datawizard::skewness()` and `datawizard::kurtosis()`.

# parameters 0.30.0

## Changes
Expand Down
13 changes: 12 additions & 1 deletion R/methods_skewness_kurtosis.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#' @export
standard_error.parameters_skewness <- function(model, ...) {
attributes(model)$SE
# datawizard returns SE as column, older objects stored it as attribute
if ("SE" %in% names(model)) {
model$SE
} else {
attributes(model)$SE
}
}


#' @export
standard_error.parameters_kurtosis <- standard_error.parameters_skewness

#' @export
standard_error.datawizard_skewness <- standard_error.parameters_skewness

#' @export
standard_error.datawizard_kurtosis <- standard_error.parameters_skewness
25 changes: 25 additions & 0 deletions tests/testthat/test-skewness_kurtosis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
skip_if_not_installed("datawizard")
Comment thread
jmgirard marked this conversation as resolved.

test_that("standard_error returns the SE column of skewness and kurtosis output", {
out <- datawizard::skewness(mtcars[c("mpg", "cyl", "disp")])
expect_identical(standard_error(out), out$SE)
out <- datawizard::kurtosis(mtcars$mpg)
expect_identical(standard_error(out), out$SE)
})

test_that("standard_error works for the datawizard_* classes", {
s <- datawizard::skewness(mtcars$mpg)
class(s) <- c("datawizard_skewness", "data.frame")
expect_identical(standard_error(s), s$SE)

k <- datawizard::kurtosis(mtcars$mpg)
class(k) <- c("datawizard_kurtosis", "data.frame")
expect_identical(standard_error(k), k$SE)
})

test_that("standard_error reads the SE attribute of old objects", {
s <- 0.67
attr(s, "SE") <- 0.39
class(s) <- c("parameters_skewness", "numeric")
expect_identical(standard_error(s), 0.39)
})
Loading