Skip to content

Commit 75cce49

Browse files
committed
Fix selection models
1 parent aebe77b commit 75cce49

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: parameters
33
Title: Processing of Model Parameters
4-
Version: 0.27.0
4+
Version: 0.27.0.1
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

R/methods_selection.R

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,23 @@ model_parameters.selection <- function(model,
3939

4040

4141
#' @export
42-
p_value.selection <- function(model, component = c("all", "selection", "outcome", "auxiliary"), ...) {
43-
component <- match.arg(component)
42+
p_value.selection <- function(model, component = "all", ...) {
43+
component <- insight::validate_argument(
44+
component,
45+
c("all", "selection", "outcome", "auxiliary")
46+
)
4447
s <- summary(model)
4548
rn <- row.names(s$estimate)
4649
estimates <- as.data.frame(s$estimate, row.names = FALSE)
4750
params <- data.frame(
4851
Parameter = rn,
4952
p = estimates[[4]],
50-
Component = "auxiliary",
53+
Component = "selection",
5154
stringsAsFactors = FALSE,
5255
row.names = NULL
5356
)
54-
params$Component[s$param$index$betaS] <- "selection"
55-
params$Component[s$param$index$betaO] <- "outcome"
57+
params$Component[s$param$index$errTerms] <- "auxiliary"
58+
params$Component[s$param$index$outcome] <- "outcome"
5659

5760
if (component != "all") {
5861
params <- params[params$Component == component, , drop = FALSE]
@@ -63,20 +66,23 @@ p_value.selection <- function(model, component = c("all", "selection", "outcome"
6366

6467

6568
#' @export
66-
standard_error.selection <- function(model, component = c("all", "selection", "outcome", "auxiliary"), ...) {
67-
component <- match.arg(component)
69+
standard_error.selection <- function(model, component = "all", ...) {
70+
component <- insight::validate_argument(
71+
component,
72+
c("all", "selection", "outcome", "auxiliary")
73+
)
6874
s <- summary(model)
6975
rn <- row.names(s$estimate)
7076
estimates <- as.data.frame(s$estimate, row.names = FALSE)
7177
params <- data.frame(
7278
Parameter = rn,
7379
SE = estimates[[2]],
74-
Component = "auxiliary",
80+
Component = "selection",
7581
stringsAsFactors = FALSE,
7682
row.names = NULL
7783
)
78-
params$Component[s$param$index$betaS] <- "selection"
79-
params$Component[s$param$index$betaO] <- "outcome"
84+
params$Component[s$param$index$errTerms] <- "auxiliary"
85+
params$Component[s$param$index$outcome] <- "outcome"
8086

8187
if (component != "all") {
8288
params <- params[params$Component == component, , drop = FALSE]
@@ -89,9 +95,12 @@ standard_error.selection <- function(model, component = c("all", "selection", "o
8995
#' @export
9096
simulate_model.selection <- function(model,
9197
iterations = 1000,
92-
component = c("all", "selection", "outcome", "auxiliary"),
98+
component = "all",
9399
...) {
94-
component <- match.arg(component)
100+
component <- insight::validate_argument(
101+
component,
102+
c("all", "selection", "outcome", "auxiliary")
103+
)
95104
out <- .simulate_model(model, iterations, component = component, effects = "fixed", ...)
96105

97106
class(out) <- c("parameters_simulate_model", class(out))

0 commit comments

Comments
 (0)