% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Rfunctions.R
\name{blinding.test}
\alias{blinding.test}
\alias{test.stan}
\title{Unblinding bias correction}
\usage{
blinding.test(W, T, G, method = "adjust", impute = TRUE)
}
\arguments{
\item{W}{Numeric surrogate outcome.}

\item{T}{Binary treatment indicator.}

\item{G}{Binary response indicator.}

\item{method}{fitting/test method.}

\item{impute}{missing data or DNK response imputation.}
}
\value{
An object of class `rctme_fit`.
}
\description{
Unblinding bias correction
}
\examples{
\dontrun{
if (requireNamespace("rstan", quietly = TRUE)) {
sigma = 1.2
sig.theta = 1.0
beta0 = 0
beta1 = 1
beta2 = 2
ntreat = nsham = 100
Tind  = c(rep(1, ntreat), rep(0,nsham))  #treatment group indicator
u1v   = rep(u1,ntreat)
u2v   = rep(u2,nsham)
uv    = c(u1v,u2v)
tauv  = uv - rep(u2, ntreat+nsham)
r = rnorm(ntreat + nsham, mean = 0, sd = sigma)
x = uv + r #actual endpoint outcome
q = 1/(1 + exp(-(beta0 + beta1*Tind + beta2*(tauv+r))))
bernGen = function(qq){rbinom(1,1,qq)}
I = sapply(q,bernGen)
rsham = rnorm(ntreat + nsham, mean = 0, sd = sig.theta)
w = x + (theta + rsham)*I
lm0 = lm(w~Tind)
tau1 = lm0$coef[2]; tau1
u12 = tapply(w,Tind,FUN=mean,na.rm=TRUE)
lm1 = lm(w~Tind+I)
tau2 = lm1$coef[2]; tau2
mydata <- data.frame(y=w,group=Tind,guess=I)
out1 <- blinding.test(W = mydata$y, T = mydata$group, G = mydata$guess,
                      method='BI',impute=TRUE)
out1 # Blinding Index test

out2 <- blinding.test(W = mydata$y, T = mydata$group, G = mydata$guess,
                      method='classic',impute=TRUE)
out2 # classic estimate (t-test like)

out3 <- blinding.test(W = mydata$y, T = mydata$group, G = mydata$guess,
                      method='adjusted',impute=TRUE)
out3 # ANOVA or linear regression using G as a covariate

out4 <- blinding.test(W = mydata$y, T = mydata$group, G = mydata$guess,
                      method='EM',impute=TRUE)
out4 # MLE using EM-algorithm

out5 <- blinding.test(W = mydata$y, T = mydata$group, G = mydata$guess,
                      method='Bayes',impute=TRUE)
out5 # MLE using Bayes MCMC
}
}

}
