-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiM_Bretthorst_UMS_calls.r
194 lines (170 loc) · 5.86 KB
/
DiM_Bretthorst_UMS_calls.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
### (C) 2005-2023 by Leo Guertler
### R-code supplement
### to the book
###
### "Subjektive Ansichten und objektive Betrachtungen"
###
### written by Gürtler & Huber (2023)
###
### All R-code is published under the GPL v3 license:
###
### https://www.gnu.org/licenses/gpl-3.0.en.html
###
### except for 'borrowed' code - see links and references.
### For this R-code the original license of the respective
### authors is valid.
###
### R-code published on
###
### https://osdn.net/projects/mixedmethod-rcode
### https://github.com/abcnorio/mixedmethod-rcode
### NOTE !!!
#
# An enhanced and more recent version of "The difference in means" can be found on https://github.com/abcnorio/diffinmeans
rm(list=ls())
source("DiM_Bretthorst_UMS.r")
################################################################################
# On the difference in means
# paper: G.L. Bretthorst "On the difference of means" (1993)
#
# R code based on Mathematica code by Urban Studer (90's, Zürich/ CH)
################################################################################
#works
res.SIB.NRFmf <- SucRatesIntBounds(Si=20, Ni=47, Sii=13, Nii=28, smin=0, snames=c("male","female"))
res.SIB.NRFmf
DiM.res.NRFmf <- DiffinMeans(inval=res.SIB.NRFmf, out=FALSE)
str(DiM.res.NRFmf)
UMSprint(results=DiM.res.NRFmf)
DiM.res.NRFmf$OR.df
DiM.res.NRFmf$prob.df
UMSplot(inval=res.SIB.NRFmf,pdfout=FALSE)
################################################################################
#EXAMPLE FOR FAILURE
# does not work with these values
res.SIB.NRFtotal <- SucRatesIntBounds(Si=(20+13), Ni=(47+28), Sii=(338 %/% 4), Nii=338, smin=0, snames=c("male","female"))
res.SIB.NRFtotal
DiM.res.NRF <- DiffinMeans(inval=res.SIB.NRFtotal, out=FALSE)
str(DiM.res.NRF)
UMSprint(results=DiM.res.NRFtotal)
#WATCH THE PLOT - BECOMES OBVIOUS (ie. the result), but should work nevertheless
UMSplot(inval=res.SIB.NRFtotal,pdfout=FALSE)
res.SIB.NRFmf <- SucRatesIntBounds(Si=20, Ni=47, Sii=13, Nii=28, smin=0, snames=c("male","female"))
res.SIB.NRFmf
DiM.res.NRFmf <- DiffinMeans(inval=res.SIB.NRFmf, out=TRUE, BROB=FALSE)
DiM.res.NRFmf
str(DiM.res.NRFmf)
UMSprint(results=DiM.res.NRFmf)
DiM.res.NRFmf.brob <- DiffinMeans(inval=res.SIB.NRFmf, out=TRUE, BROB=TRUE)
DiM.res.NRFmf.brob
str(DiM.res.NRFmf.brob)
UMSprint(results=DiM.res.NRFmf.brob)
#normally does not work
res.SIB.NRFtotal <- SucRatesIntBounds(Si=(20+13), Ni=(47+28), Sii=(338 %/% 4), Nii=338, smin=0, snames=c("male","female"))
res.SIB.NRFtotal
inval <- res.SIB.NRFtotal
DiM.res.NRF <- DiffinMeans(inval=res.SIB.NRFtotal, out=FALSE)
DiM.res.NRF <- DiffinMeans(inval=res.SIB.NRFtotal, out=FALSE, BROB=TRUE)
DiM.res.NRF
UMSprint(results=DiM.res.NRF,SRIB=res.SIB.NRFtotal)
UMSplot(inval=res.SIB.NRFtotal)
################################################################################
# example values for success rates and integration bounds
# Studer 1998, p.47
UMS.SRIB1 <- SucRatesIntBounds(Si=11, Ni=15, Sii=10, Nii=16, smin=0, snames=c("voluntary","non-voluntary"))
UMS.SRIB1
DiM.res.SIB1 <- DiffinMeans(inval=UMS.SRIB1, out=FALSE)
str(DiM.res.SIB1)
UMSprint(results=DiM.res.SIB1, SRIB=UMS.SRIB1)
UMSplot(inval=UMS.SRIB1,pdfout=FALSE)
################################################################################
# example values for success rates and integration bounds
# Studer 1998, p.48
UMS.SRIB <- SucRatesIntBounds(Si=20, Ni=31, Sii=17, Nii=27, smin=0, snames=c("voluntary","non-voluntary"))
str(UMS.SRIB)
DiM.res.SIB <- DiffinMeans(inval=UMS.SRIB, out=FALSE)
str(DiM.res.SIB)
UMSprint(results=DiM.res.SIB, SRIB=UMS.SRIB)
UMSplot(inval=UMS.SRIB,pdfout=FALSE)
################################################################################
# Gregory, 200x, p.xxx
inval <- list(Si=NULL,
Ni = 12,
Sii=NULL,
Nii = 8,
smin = 0,
Di = 10.3167,
si = 2.1771,
Dii = 8.5875,
sii = 1.28,
L = 7,
H = 12,
sL = 1,
sH = 4,
snames = c("river.1","river.2")
)
DiM.PG <- DiffinMeans(inval=inval, out=FALSE)
DiM.PG$prob.df
DiM.PG$OR.df
# Studer 1998, p.47
inval <- list(Si=NULL,
Ni = 15,
Sii=NULL,
Nii = 16,
smin = 0,
Di = 0.70588,
si = 0.1074,
Dii = 0.61111,
sii = 0.11184,
L = 0.05,
H = 0.95,
sL = 0.052,
sH = 0.118,
snames = c("voluntary","non-voluntary")
)
DiM.UMS <- DiffinMeans(inval=inval, out=FALSE)
DiM.UMS$prob.df
DiM.UMS$OR.df
UMSprint(results=DiM.UMS)
# Bretthorst, 1993, p.189 (from Jaynes, 1976 + 1983)
inval <- list(Si=NULL,
Ni = 4,
Sii=NULL,
Nii = 9,
smin = 0,
Di = 50,
si = 6.48,
Dii = 42,
sii = 7.48,
L = 34,
H = 58,
sL = 3,
sH = 10,
snames = c("Jaynes.1","Jaynes.2")
)
DiM.ETJ <- DiffinMeans(inval=inval, out=TRUE, BROB=FALSE)
DiM.ETJ$prob.df
DiM.ETJ$OR.df
results <- DiM.ETJ
UMSprint(results=DiM.ETJ)
################################################################################
######################################################
#GENERAL call and preparation
# Studer 1998, p.47
# Bretthorst, 1993, p.189 (from Jaynes, 1976 + 1983)
inval <- list(
Si=NULL, #UMS specific -> successes group1
Ni = 4, #N group1
Sii=NULL, #UMS specific -> successes group2
Nii = 9, #N group2
smin = 0, #UMS specific -> bounds on the mean -> only for SucRatesIntBounds()
Di = 50, #mean group1
si = 6.48, #sd group1
Dii = 42, #mean group2
sii = 7.48, #sd group2
L = 34, #mean lower bound
H = 58, #mean upper bound
sL = 3, #variance lower bound
sH = 10, #variance upper bound
snames = c("Jaynes.1","Jaynes.2")
)
######################################################