dist.2D: 2-D Grid of Three Variables

Description Usage Arguments Details Value Examples

View source: R/manual R codes.r

Description

Make the 2-D matrix to store the probabilities of all 2X2 tables when N patients treated, columns and rows are A-arm selection fraction and sucess rate separately. .

Usage

1
dist.2D(S, A, p)

Arguments

S

the same structure with Xsm,storing the number of favorable outcomes at all possible 2X2 tables when a series of N patients to be treated.

A

the same structure with Xsm,storing the number of A-arm treatment at all possible 2X2 tables when a series of N patients to be treated

p

the same structure with Xsm,storing the probabilities of all possible 2X2 tables when a series of N patients to be treated.

Details

S,A,p are special list structure, each of which represents one variable based on all possible combinations of 2X2 tables when N patients treated. And the length of list equals to N+1.

Value

a list of matrices consisted of probabilities with rows corresponding to the probabilities vary along with A-arm fraction selection and columns corresponding to the probabilities vary along with overall success rates.

Examples

 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
library(combinat)
N <- 20
out<-serialTables(N)
ABSF<-sapply(out$Z, unlist)  
#'  
A.cnt <- relist((ABSF[,1]+ABSF[,2]),out$sk)
A.fraction<-apply(ABSF,1,A.frac)
A.fraction[1] <- 0.5
Success.cnt <- relist(ABSF[,1]+ABSF[,3],out$sk)
Success.fraction <-success.fraction<-apply(ABSF,1,success.frac)
Success.fraction[1] <- 0.5

E.st_prob.A<-apply(ABSF,1,E.st_utinity)
#Probability to select the A-arm based on utinity function of E.st: E.st_utinity()
a<-0.8
#ture success rate of A-arm treatment
b<-0.6
#ture success rate of B-arm treatment
E.table.probability<-table.prob(relist(E.st_prob.A,out$sk),p=c(a,b))
#exact probability per 2X2 table based on utinity function of E.st: E.st_utinity()
grid.exp.ls<-dist.2D(Success.cnt,A.cnt,E.table.probability)
str(grid.exp.ls)

w=0.5
#homogeneous optimistic attitude with w=0.5
T.st_prob.A<-apply(ABSF,1,T.st_utinity,w=0.5)
#Probability to select the A-arm based on utinity function of T.st: T.st_utinity()
a<-0.8
#ture success rate of A-arm treatment
b<-0.6
#ture success rate of B-arm treatment
T.table.probability<-table.prob(relist(T.st_prob.A,out$sk),p=c(a,b))
#exact probability per 2X2 table based on utinity function of T.st: T.st_utinity()
grid.target.ls<-dist.2D(Success.cnt,A.cnt,T.table.probability) 
str(grid.target.ls)

ryamada22/SelfDecABP documentation built on May 28, 2019, 10:44 a.m.