-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeedback.AllNorm.R
70 lines (44 loc) · 1.5 KB
/
feedback.AllNorm.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#This file is part of ElicitN.
#Copyright 2011 Rebecca Fisher and Rebecca O'Leary.
#ElicitN is free software: you can redistribute it and/or modify it under
#the terms of the GNU General Public License as published by the Free Software
#Foundation, either version 3 of the License, or any later version.
#This program is distributed in the hope that it will be useful, but WITHOUT ANY
#WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
#PARTICULAR PURPOSE. See the GNU General Public License
#(http://www.gnu.org/licenses/) for more details.
feedback.AllNorm <- function(mu, sig,Sureness,new.alpha, MhatK, which.dist) {
#if for say cryptic have no info
if (which.dist==0){
lower=0
upper=0
mode=0
new.lower=0
new.upper=0
Ksp=0
} else {
#IF LOG-NORMAL
if (which.dist=="LN") {
mode <- exp(mu-sig^2)
ci <- qlnorm(c(1-Sureness, .5, Sureness, 1-new.alpha, new.alpha), mean=mu, sd=sig)
Ksp <-rlnorm(10000,mu,sig)
#IF NORMAL
} else if (which.dist=="normal"){
mode <- mu
ci <- qnorm(c(1-Sureness, .5, Sureness, 1-new.alpha, new.alpha), mean=mu, sd=sig)
Ksp <-rnorm(10000,mu,sig)
#ELSE MIRROR LOG-NORMAL
} else {
modeLN <- exp(mu-sig^2)
mode <- MhatK$Mhatold-(MhatK$Mhat-modeLN)
Ksp <-rlnorm(10000,mu,sig)
ci <- qlnorm(c(1-Sureness, .5, Sureness, 1-new.alpha, new.alpha), mean=mu, sd=sig)
}
lower=ci[1]
upper=ci[3]
new.lower=ci[4]
new.upper=ci[5]
}
return(list(lower=lower, upper=upper, mode=mode,
new.alpha=new.alpha, new.lower=new.lower, new.upper=new.upper, Ksp=Ksp))
}