ilgt <- function (x)
{
tem = exp(x)
res = tem/(1 + tem)
return(res)
}
lgt <- function (p)
{
log(p/(1 - p))
}
## the vector of a parameter estimates if log(a),log(theta),logit(delta),beta0.
tpar <- c(log(2),log(0.5),lgt(0.5),2)
ypre <- c(0, 1)
ynew <- c(1, 0, 0)
## No covariate
XM <- NULL
## no missing visit
stp <- c(0,1,1,1,1)
dist = "G"
## The estimate of the variance covariance matrix
V <-
matrix(
c( 0.17720309, -0.240418504, 0.093562548, 0.009141980,
-0.24041850, 0.605132808, -0.160454773, -0.003978118,
0.09356255, -0.160454773, 0.095101658, 0.005661923,
0.00914198, -0.003978118, 0.005661923, 0.007574769),
nrow=4)
## the estimate of the conditional probability based on the sum summary statistics and its SE
CP.ar1.se(tpar = tpar, ypre = ypre, ynew = ynew,
XM =XM, stp = stp,
dist = dist, V = V, mc = FALSE, qfun = "sum")
## the estimate of the conditional probability based on the max summary statistics and its SE
CP.ar1.se(tpar = tpar, ypre = ypre, ynew = ynew,
XM =XM, stp = stp,
dist = dist, V = V, mc = FALSE, qfun = "max")
## CP.ar1.se calls for jCP.ar1 to compute the estimate of the conditional probability
## the estimate of the conditional probability based on the sum summary statistics
jCP.ar1(tpar = tpar, ypre = ypre, ynew = ynew,
y2m=NULL, XM =XM, stp = stp,
mod = dist, LG = FALSE, MC = FALSE, N = 40000, qfun = "sum", oth = NULL)
## jCP.ar1 calls for CP.ar1 to compute the estimate of the conditional probability
## via the adaptive quadrature (MC=F)
## the estimate of the conditional probability
u <- rep(exp(tpar[4]),length(ypre)+length(ynew))
CP1.ar1(ypre = ypre, ynew =ynew, y2m = NULL,
stp =stp, u = u, th = exp(tpar[2]), a = exp(tpar[1]),
dt= ilgt(tpar[3]), mod = dist, qfun = "sum")
## jCP.ar1 calls for CP.ar1 to compute the estimate of the conditional probability
## via the Monte Carlo method (MC=T)
## the estimate of the conditional probability
MCCP.ar1(ypre = ypre, ynew =ynew, stp = stp,
u = u, th = exp(tpar[2]), a = exp(tpar[1]), dt = ilgt(tpar[3]),
mod =dist, Ns = 1000, qfun = "sum")
Run the code above in your browser using DataLab