Skip to content

Commit a264c44

Browse files
committed
select did not return pcor in summary but fisher. Added transformation
-- this addresses #93
1 parent a48c3c5 commit a264c44

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ custom.css
1414
/doc/
1515
/Meta/
1616
/src/Makevars
17+
/config.log

R/select.explore.R

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ select.explore <- function(object,
104104
BF_cut = 3,
105105
alternative = "two.sided",
106106
...){
107-
# rename
107+
## rename
108108
x <- object
109109

110-
# hyp probability
110+
## hyp probability
111111
hyp_prob <- BF_cut / (BF_cut + 1)
112112

113-
# posterior samples
114-
post_samp <- x$post_samp
113+
## posterior samples
114+
post_samp <- x$post_samp
115115

116-
# prior samples
117-
prior_samp <- x$prior_samp
116+
## prior samples
117+
prior_samp <- x$prior_samp
118118

119119

120120

@@ -129,7 +129,7 @@ select.explore <- function(object,
129129

130130
# prior
131131
prior_sd <- apply(prior_samp$fisher_z[,,(51:x$iter)], 1:2, sd)
132-
prior_dens <- dnorm(0, 0, mean(prior_sd[upper.tri(diag(3))]))
132+
prior_dens <- dnorm(0, 0, mean(prior_sd[upper.tri(diag(nrow(prior_sd)))]))
133133

134134
# BF
135135
BF_10_mat <- prior_dens / post_dens
@@ -146,9 +146,9 @@ select.explore <- function(object,
146146
diag(Adj_10) <- 0
147147

148148
# returned object
149-
returned_object = list(pcor_mat_zero = post_mean * Adj_10,
150-
pcor_mat = round(post_mean, 3),
151-
pcor_sd = round(post_sd, 3),
149+
returned_object = list(pcor_mat_zero = tanh(post_mean) * Adj_10,
150+
pcor_mat = round(tanh(post_mean), 3),
151+
pcor_sd_fisher = round(post_sd, 3),
152152
Adj_10 = Adj_10,
153153
Adj_01 = Adj_01,
154154
BF_10 = BF_10_mat,
@@ -168,7 +168,7 @@ select.explore <- function(object,
168168
# posterior
169169
post_sd <- apply(post_samp$fisher_z[,,(51:x$iter)], 1:2, sd)
170170
post_mean <- apply(post_samp$fisher_z[,,(51:x$iter)], 1:2, mean)
171-
#x$pcor_mat
171+
#x$pcor_mat
172172
post_dens <- dnorm(0, post_mean, post_sd )
173173

174174
# prior
@@ -196,9 +196,9 @@ select.explore <- function(object,
196196

197197
# returned object
198198
returned_object = list(
199-
pcor_mat_zero = post_mean * Adj_20,
200-
pcor_mat = round(post_mean, 3),
201-
pcor_sd = round(post_sd, 3),
199+
pcor_mat_zero = tanh(post_mean) * Adj_20,
200+
pcor_mat = round(tanh(post_mean), 3),
201+
pcor_sd_fisher = round(post_sd, 3),
202202
Adj_20 = Adj_20,
203203
Adj_02 = Adj_02,
204204
BF_20 = BF_20_mat,
@@ -217,7 +217,7 @@ select.explore <- function(object,
217217

218218
# posterior
219219
post_sd <- apply(post_samp$fisher_z[,,(51:x$iter)], 1:2, sd)
220-
post_mean <- x$pcor_mat
220+
post_mean <- apply(post_samp$fisher_z[,,(51:x$iter)], 1:2, mean)
221221
post_dens <- dnorm(0, post_mean, post_sd )
222222

223223
# prior
@@ -245,9 +245,9 @@ select.explore <- function(object,
245245

246246
# returned object
247247
returned_object = list(
248-
pcor_mat_zero = post_mean * Adj_20,
249-
pcor_mat = round(post_mean, 3),
250-
pcor_sd = round(post_sd, 3),
248+
pcor_mat_zero = tanh(post_mean) * Adj_20,
249+
pcor_mat = round(tanh(post_mean), 3),
250+
pcor_sd_fisher = round(post_sd, 3),
251251
Adj_20 = Adj_20,
252252
Adj_02 = Adj_02,
253253
BF_20 = BF_20_mat,
@@ -291,7 +291,7 @@ select.explore <- function(object,
291291

292292
# posterior
293293
post_sd <- apply(post_samp$fisher_z[,,(51:x$iter)], 1:2, sd)
294-
post_mean <- x$pcor_mat
294+
post_mean <- apply(post_samp$fisher_z[,,(51:x$iter)], 1:2, mean)
295295
post_dens <- dnorm(0, post_mean, post_sd)
296296

297297
# prior
@@ -339,8 +339,8 @@ select.explore <- function(object,
339339
pos_mat = pos_mat,
340340
null_mat = null_mat,
341341
alternative = alternative,
342-
pcor_mat = round(post_mean, 3),
343-
pcor_sd = round(post_sd, 3),
342+
pcor_mat = round(tanh(post_mean), 3),
343+
pcor_sd_fisher = round(post_sd, 3),
344344
call = match.call(),
345345
prob = hyp_prob,
346346
type = x$type,
@@ -502,27 +502,27 @@ summary.select.explore <- function(object,
502502
if(x$alternative == "two.sided"){
503503

504504
post_mean <- x$pcor_mat[upper.tri(x$pcor_mat)]
505-
post_sd <- x$pcor_sd[upper.tri(x$pcor_sd)]
505+
post_sd <- x$pcor_sd_fisher[upper.tri(x$pcor_sd_fisher)]
506506
prob_H1 <- x$BF_10[upper.tri(x$BF_10)] / (x$BF_10[upper.tri(x$BF_10)] + 1)
507507
prob_H0 <- 1 - prob_H1
508508
summ <- data.frame(
509509
Relation = mat_names,
510510
Post.mean = post_mean,
511-
Post.sd = post_sd,
511+
Post.sd.fisher = post_sd,
512512
Pr.H0 = round(prob_H0, 3),
513513
Pr.H1 = round(prob_H1, 3)
514514
)
515515

516516
} else if (x$alternative == "greater"){
517517

518518
post_mean <- x$pcor_mat[upper.tri(x$pcor_mat)]
519-
post_sd <- x$pcor_sd[upper.tri(x$pcor_sd)]
519+
post_sd <- x$pcor_sd_fisher[upper.tri(x$pcor_sd_fisher)]
520520
prob_H1 <- x$BF_20[upper.tri(x$BF_20)] / (x$BF_20[upper.tri(x$BF_20)] + 1)
521521
prob_H0 <- 1 - prob_H1
522522
summ <- data.frame(
523523
Relation = mat_names,
524524
Post.mean = post_mean,
525-
Post.sd = post_sd,
525+
Post.sd.fisher = post_sd,
526526
Pr.H0 = round(prob_H0, 3),
527527
Pr.H1 = round(prob_H1, 3)
528528
)
@@ -532,13 +532,13 @@ summary.select.explore <- function(object,
532532
} else if (x$alternative == "less" | x$alternative == "greater"){
533533

534534
post_mean <- x$pcor_mat[upper.tri(x$pcor_mat)]
535-
post_sd <- x$pcor_sd[upper.tri(x$pcor_sd)]
535+
post_sd <- x$pcor_sd_fisher[upper.tri(x$pcor_sd_fisher)]
536536
prob_H1 <- x$BF_20[upper.tri(x$BF_20)] / (x$BF_20[upper.tri(x$BF_20)] + 1)
537537
prob_H0 <- 1 - prob_H1
538538
summ <- data.frame(
539539
Relation = mat_names[upper.tri(mat_names)],
540540
Post.mean = post_mean,
541-
Post.sd = post_sd,
541+
Post.sd.fisher = post_sd,
542542
Pr.H0 = round(prob_H0, 3),
543543
Pr.H1 = round(prob_H1, 3)
544544
)
@@ -549,12 +549,12 @@ summary.select.explore <- function(object,
549549

550550
summ <- cbind.data.frame( x$post_prob[,1],
551551
x$pcor_mat[upper.tri(x$pcor_mat)],
552-
x$pcor_sd[upper.tri(x$pcor_sd)],
552+
x$pcor_sd_fisher[upper.tri(x$pcor_sd_fisher)],
553553
round(x$post_prob[,2:4], 3))
554554

555555
colnames(summ) <- c("Relation",
556556
"Post.mean",
557-
"Post.sd",
557+
"Post.sd.fisher",
558558
"Pr.H0",
559559
"Pr.H1",
560560
"Pr.H2")

0 commit comments

Comments
 (0)