-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 20.8 KB
/
.Rhistory
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(tidyverse)
df <- fread("C:/Users/dal18007/Downloads/SMVMetaData30.txt", header=FALSE)
df <- df %>% filter(ir <= 200)
df <- df %>% filter(ir <= 100)
head(df)
unique(df$ir)
y <- cbind(df$y1, df$y2, df$y3)
X <- cbind(df$bmi, df$age, df$black)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
df <- df %>% filter(ir <= 50)
colnames(df) <- c("ir", "k", "i", "y1", "y2", "y3", "trt", "bmi", "age", "black")
y <- cbind(df$y1, df$y2, df$y3)
X <- cbind(df$bmi, df$age, df$black)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
library(data.table)
library(tidyverse)
df <- fread("C:/Users/dal18007/Downloads/SMVMetaData30.txt", header=FALSE)
df <- df %>% filter(ir <= 50)
colnames(df) <- c("ir", "k", "i", "y1", "y2", "y3", "trt", "bmi", "age", "black")
y <- cbind(df$y1, df$y2, df$y3)
X <- cbind(df$bmi, df$age, df$black)
colnames(df) <- c("ir", "k", "i", "y1", "y2", "y3", "trt", "bmi", "age", "black")
df <- df %>% filter(ir <= 50)
y <- cbind(df$y1, df$y2, df$y3)
X <- cbind(df$bmi, df$age, df$black)
str(y)
str(X)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
o
head(Outcome)
o[1]
o[2]
as.double(c(1,2,3))
as.integer(c(1,2,3))
library(BayesMeta)
devtools::document()
library(BayesMeta)
library(BayesMeta)
library(BayesMeta)
library(BayesMeta)
library(data.table)
library(tidyverse)
df <- fread("C:/Users/dal18007/Downloads/SMVMetaData30.txt", header=FALSE)
colnames(df) <- c("ir", "k", "i", "y1", "y2", "y3", "trt", "bmi", "age", "black")
df <- df %>% filter(ir <= 50)
y <- cbind(df$y1, df$y2, df$y3)
X <- cbind(df$bmi, df$age, df$black)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(data.table)
library(tidyverse)
df <- fread("C:/Users/dal18007/Downloads/SMVMetaData30.txt", header=FALSE)
colnames(df) <- c("ir", "k", "i", "y1", "y2", "y3", "trt", "bmi", "age", "black")
df <- df %>% filter(ir <= 50)
y <- cbind(df$y1, df$y2, df$y3)
X <- cbind(df$bmi, df$age, df$black)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
(3+2) * 3
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
fit <- bayes.mvmeta(y, df$k, df$i, df$trt, X, 30, verbose=TRUE)
library(BayesMeta)
df <- fread("C:/Users/dal18007/Downloads/SMVMetaData30.txt", header=FALSE)
colnames(df) <- c("ir", "k", "i", "y1", "y2", "y3", "trt", "bmi", "age", "black")
head(df)
load("C:/Users/dal18007/Desktop/Rpackages/meta_fit.RData")
print(fit)
library(BayesMeta)
data(df)
groupinfo <- list(c(0,1), c(2,3), c(4)) # define the variance structure
fit <- bayes.nmr(df$y, df$sd, x, df$ids, df$iarm, df$npt, groupinfo, prior = list(c01=1.0e05, c02=4, nu=3), mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
x <- df[,6:10]
groupinfo <- list(c(0,1), c(2,3), c(4)) # define the variance structure
fit <- bayes.nmr(df$y, df$sd, x, df$ids, df$iarm, df$npt, groupinfo, prior = list(c01=1.0e05, c02=4, nu=3), mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
setwd("C:/Users/dal18007/Desktop/Rpackages")
save(fit, file="meta_fit.RData")
print(fit)
dim(fit$mcmc.draws$beta)
unique(df$iarm)
ss <- sucra(fit)
devtools::document()
setwd("C:/Users/dal18007/Desktop/Rpackages/BayesMeta")
setwd("C:/Users/dal18007/Desktop/Rpackages/BayesMeta")
devtools::document()
library(BayesMeta)
ss <- sucra(fit)
library(BayesMeta)
ss <- sucra(fit)
ss
library(BayesMeta)
ss <- sucra(fit)
ss
plot(ss)
library(BayesMeta)
plot(ss)
plot(0, type="n")
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
help(devAskNewPage(ask = FALSE))
help(devAskNewPage)
library(BayesMeta)
plot(ss)
plot.new()
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
plot()
plot(0)
library(BayesMeta)
plot(ss)
plot(0)
library(BayesMeta)
plot(ss)
plot(0)
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
library(BayesMeta)
plot(ss)
help(rgb)
library(BayesMeta)
plot(ss)
plot(ss)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 1, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
data("cholesterol")
Outcome <- cbind(cholesterol$ldlcm, cholesterol$hdlcm, cholesterol$tgm)
SD <- cbind(cholesterol$ldlcsd, cholesterol$hdlcsd, cholesterol$tgsd)
Trial <- cholesterol$Trial
Treat <- cholesterol$Trt
Npt <- cholesterol$npt
XCovariate <- cbind(cholesterol$bl_ldlc, cholesterol$bl_hdlc, cholesterol$bl_tg, cholesterol$age, cholesterol$Dur, cholesterol$white, cholesterol$male, cholesterol$DM)
WCovariate <- cbind(1, cholesterol$Trt)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 1, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
help("bayes.parobs")
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 1, mcmc=list(ndiscard=10000,nskip=1,nkeep=20000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
zstar_prop <- 14.3513
(exp(2.0 * zstar_prop) - 1.0) / (exp(2.0 * zstar_prop) + 1.0);
zstar_prop <- -13.4995
(exp(2.0 * zstar_prop) - 1.0) / (exp(2.0 * zstar_prop) + 1.0);
zstar_prop <- 8.5
(exp(2.0 * zstar_prop) - 1.0) / (exp(2.0 * zstar_prop) + 1.0);
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2, mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
veclinv(c(0.5000, -1.0000, -0.7335), 3)
library(BayesMeta)
library(BayesMeta)
library(BayesMeta)
library(BayesMeta)
data("cholesterol")
Outcome <- cbind(cholesterol$ldlcm, cholesterol$hdlcm, cholesterol$tgm)
SD <- cbind(cholesterol$ldlcsd, cholesterol$hdlcsd, cholesterol$tgsd)
Trial <- cholesterol$Trial
Treat <- cholesterol$Trt
Npt <- cholesterol$npt
XCovariate <- cbind(cholesterol$bl_ldlc, cholesterol$bl_hdlc, cholesterol$bl_tg, cholesterol$age, cholesterol$Dur, cholesterol$white, cholesterol$male, cholesterol$DM)
WCovariate <- cbind(1, cholesterol$Trt)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
veclinv
library(BayesMeta)
veclinv(c(0.5000 -1.0000 -0.7328))
veclinv(c(0.5000 -1.0000 -0.7328), 3)
veclinv(c(0.5000, -1.0000, -0.7328), 3)
diag(pR) <- 1
pR <- veclinv(c(0.5000, -1.0000, -0.7328), 3)
diag(pR) <- 1
R <- pRho_to_Rho(pR)
R
chol(R)
library(BayesMeta)
data("cholesterol")
Outcome <- cbind(cholesterol$ldlcm, cholesterol$hdlcm, cholesterol$tgm)
SD <- cbind(cholesterol$ldlcsd, cholesterol$hdlcsd, cholesterol$tgsd)
Trial <- cholesterol$Trial
Treat <- cholesterol$Trt
Npt <- cholesterol$npt
XCovariate <- cbind(cholesterol$bl_ldlc, cholesterol$bl_hdlc, cholesterol$bl_tg, cholesterol$age, cholesterol$Dur, cholesterol$white, cholesterol$male, cholesterol$DM)
WCovariate <- cbind(1, cholesterol$Trt)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
pR <- veclinv(c(0.5000, -1.0000, -0.7463), 3)
diag(pR) <- 1
R <- pRho_to_Rho(pR)
chol(R)
R
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
v <- 4
x <- matrix(rnorm(4*4), 4, 4)
x <- crossprod(x)
xx <- replicate(rwish(v, x), 10000)
xx <- replicate(n = 10000, rwish(v, x))
dim(xx)
apply(xx, c(1,2), mean)
v * x
xx <- replicate(n = 40000, rwish(v, x))
apply(xx, c(1,2), mean)
v * x
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
0.5 * std::log((1.0-0.7854) / (1.0 + 0.7854))
0.5 * log((1.0-0.7854) / (1.0 + 0.7854))
0.5 * (log(1.0-0.7854) - log(1.0 + 0.7854))
atanh(-0.7854)
(exp(2.0 * 1.1) - 1.0) / (exp(2.0 * 1.1) + 1.0)
tanh(1.1)
exp(0.1)
exp(0.01)
exp(0.001)
exp(-0.1)
exp(-0.5)
exp(-0.9)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
load("C:/Users/dal18007/Desktop/Rpackages/meta_fit.RData")
plot(sucra(fit))
library(BayesMeta)
plot(sucra(fit))
library(BayesMeta)
plot(sucra(fit))
plot(sucra(fit), lwd=1)
library(BayesMeta)
plot(sucra(fit), lwd=1)
plot(sucra(fit), lwd=1)
library(BayesMeta)
library(BayesMeta)
plot(sucra(fit))
library(BayesMeta)
plot(sucra(fit))
library(BayesMeta)
plot(sucra(fit))
library(BayesMeta)
plot(sucra(fit))
plot(sucra(fit))
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
1/cosh(3.4)^2
4 * exp(2 * 3.4) / (1 + exp(2 * 3.4))^2
data("cholesterol")
Outcome <- cbind(cholesterol$ldlcm, cholesterol$hdlcm, cholesterol$tgm)
SD <- cbind(cholesterol$ldlcsd, cholesterol$hdlcsd, cholesterol$tgsd)
Trial <- cholesterol$Trial
Treat <- cholesterol$Trt
Npt <- cholesterol$npt
XCovariate <- cbind(cholesterol$bl_ldlc, cholesterol$bl_hdlc, cholesterol$bl_tg, cholesterol$age, cholesterol$Dur, cholesterol$white, cholesterol$male, cholesterol$DM)
WCovariate <- cbind(1, cholesterol$Trt)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
r <- rnorm(4)
rho <- matrix(rnorm(4*4), 4, 4)
rho <- crossprod(rho)
V <- diag(1/sqrt(diag(rho)))
rho <- V %*% rho %*% V
rho
R <- chol(rho)
sum((r/sig2) * solve(rho, r/sig2))
rho <- V %*% rho %*%
sig2 <- 1:4 / runif(4)
sum((r/sig2) * solve(rho, r/sig2))
rho <- matrix(rnorm(4*4), 4, 4)
rho <- crossprod(rho)
V <- diag(1/sqrt(diag(rho)))
rho <- V %*% rho %*% rho
sig2 <- 1:4 / runif(4)
sum((r/sig2) * solve(rho, r/sig2))
R <- chol(rho)
R
help(solve)
sum((r/sig2) * solve(rho, r/sig2))
R <- chol(rho)
rtilde <- backsolve(R, r, transpose = TRUE)
sum((rtilde / sig2)^2)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
library(BayesMeta)
data("cholesterol")
Outcome <- cbind(cholesterol$ldlcm, cholesterol$hdlcm, cholesterol$tgm)
SD <- cbind(cholesterol$ldlcsd, cholesterol$hdlcsd, cholesterol$tgsd)
Trial <- cholesterol$Trial
Treat <- cholesterol$Trt
Npt <- cholesterol$npt
XCovariate <- cbind(cholesterol$bl_ldlc, cholesterol$bl_hdlc, cholesterol$bl_tg, cholesterol$age, cholesterol$Dur, cholesterol$white, cholesterol$male, cholesterol$DM)
WCovariate <- cbind(1, cholesterol$Trt)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$delta[1,])
plot(fit$mcmc.draws$delta[1,1,],type = 'l')
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
127, 0.9825,
0.6127, 1.0000, 0.7491,
0.9825, 0.7491, 1.0000)3, 3)
Rho <- matrix(c(1.0000, 0.6127, 0.9825,
0.6127, 1.0000, 0.7491,
0.9825, 0.7491, 1.0000)3, 3)
Rho <- matrix(c(1.0000, 0.6127, 0.9825,
0.6127, 1.0000, 0.7491,
0.9825, 0.7491, 1.0000), 3, 3)
chol(Rho)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=10000,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$delta[1,1,], type = 'l')
plot(fit$mcmc.draws$delta[1,2,], type = 'l')
plot(fit$mcmc.draws$delta[1,3,], type = 'l')
plot(fit$mcmc.draws$delta[1,3,3000:10000], type = 'l')
plot(fit$mcmc.draws$Rho[1,2,], type = 'l')
plot(fit$mcmc.draws$Rho[1,2,3000:10000], type = 'l')
plot(fit$mcmc.draws$theta[1,], type = 'l')
plot(fit$mcmc.draws$theta[2,], type = 'l')
XCovariate
apply(XCovariate, 2, sd)
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$theta[1,], type = 'l')
plot(fit$mcmc.draws$theta[2,], type = 'l')
plot(fit$mcmc.draws$Rho[1,2,], type = 'l')
plot(fit$mcmc.draws$Rho[1,3,], type = 'l')
plot(fit$mcmc.draws$Rho[2,3,], type = 'l')
plot(fit$mcmc.draws$R[1,], type = 'l')
plot(fit$mcmc.draws$R[1,1,], type = 'l')
plot(fit$mcmc.draws$R[1,2,], type = 'l')
plot(fit$mcmc.draws$R[1,3,], type = 'l')
plot(fit$mcmc.draws$R[1,4,], type = 'l')
plot(fit$mcmc.draws$R[2,1,], type = 'l')
plot(fit$mcmc.draws$R[2,2,], type = 'l')
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$theta[1,], type = 'l')
dim(XCovariate)
plot(fit$mcmc.draws$theta[9,], type = 'l')
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$theta[1,], type = 'l')
rowMeans(fit$mcmc.draws$theta)
rowMeans(fit$mcmc.draws$theta)
apply(fit$mcmc.draws$theta, 1, sd)
apply(fit$mcmc.draws$Omegainv, c(1,2), mean)
dim(fit$mcmc.draws$R)
plot(fit$mcmc.draws$R[1,1,], type = 'l')
plot(fit$mcmc.draws$R[1,2,], type = 'l')
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$R[1,2,], type = 'l')
plot(fit$mcmc.draws$R[1,2,3000:10000], type = 'l')
library(BayesMeta)
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 2,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$theta[1,], type = 'l')
plot(fit$mcmc.draws$R[1,1,], type = 'l')
fit <- bayes.parobs(Outcome, SD, scale(XCovariate, scale=TRUE, center=TRUE), WCovariate, Treat, Trial, Npt, 3,
mcmc=list(ndiscard=2500,nskip=1,nkeep=10000), verbose=TRUE)
plot(fit$mcmc.draws$theta[1,], type = 'l')
plot(fit$mcmc.draws$R[1,1,], type = 'l')