# File name: testme.s
# Created by Ruifeng Li and Edie Weller
# Last modified 08/04

  rm(alldata)
  alldata_read.table("input.dat",header=T)
# select main study data 
  cond_alldata$valid==0 
  main_alldata[cond,]
  maind_main[,"weezmost"]
  mainw_main[,c("grinding","str","syn")]
  mainz_main[,c("plant2","agecat1","agecat2","agecat3","racec","smokenow")]
# select validation data 
  cond2_alldata$valid==1 
  valid_alldata[cond2,]
  validx_valid[,"truex"]
  validw_valid[,c("grinding","str","syn")]
  validz_valid[,c("plant2","agecat1","agecat2","agecat3","racec","smokenow")]

# define random seed for starting point in the simulation
.Random.seed _c(61, 37, 19,  5,  1,  2, 42, 40, 23, 37, 39, 0)

# Example call to the program including the confounders and no simulation

sink("testme.out1") # directs output to testme.out1
                    # user can comment out if they want the file to
                    # do directly to the screen
multisurr(outcome=maind,
          surrogatesInMain=mainw,
          trueExposure=validx,
          surrogatesInValid=validw,
          includeConfounders=T,
          confoundersInMain=mainz,
          confoundersInValid=validz,
          wt1=c(1,1,1,1,1,1,1,1,1,1),
          wt2=c(1,1,1,1,1,1,1,1),
          digits=4,
          simulation=F)
sink()

# Example call to the program without the confounders
sink("testme.out2")
multisurr(outcome=maind,
          surrogatesInMain=mainw,
          trueExposure=validx,
          surrogatesInValid=validw,
          includeConfounders=F,
          confoundersInMain=mainz,
          confoundersInValid=validz,
          wt1=c(1,1,1,1),
          wt2=c(1,1),
          digits=4,
          simulation=F)
sink()

# Example call to the program with confounders and 200 simulations

sink("testme.out3")
multisurr(outcome=maind,
          surrogatesInMain=mainw,
          trueExposure=validx,
          surrogatesInValid=validw,
          includeConfounders=T,
          confoundersInMain=mainz,
          confoundersInValid=validz,
          wt1=c(1,1,1,1,1,1,1,1,1,1),
          wt2=c(1,1,1,1,1,1,1,1),
          digits=4,
          simulation=T,
          nsim=2000)
sink()

