\name{asp.trimTables} \alias{asp.trimTables} \title{ This function deletes records in the database, used to eliminate potential partial records after a StatShop database crashed. } \usage{ asp.trimTables(cycle, chain) } \arguments{ \item{cycle}{An integer, records for this cycle and following cycles will be deleted from database.} \item{chain}{Records will be deleted from this chain.} } \description{ If an MCMC run crashes in the middle (say due to a power outage), the database could be in an inconsistent state with data for the cycle written for some models but not others. Recommended best practice is to delete the last two cycles in any cycle which was running when StatShop crashes in the middle. The \code{getCycles} function is useful for determining where the calibrator was at the time of the crash. This function deletes all records in the database where \code{CYCLE >= \kbd{cycle}} and \code{CHAIN = \kbd{chain}}. It also adjusts the \code{chain_data_table} so that resuming Chain \kbd{chain} will start with Cycle \kbd{cycle}. } \section{Side Effects}{ WARNING: This function will destructively modify the StatShop database, the results cannot be undone. } \seealso{ \code{\link{asp.dbConnect}}, \code{\link{asp.repairAllTables}}, \code{\link{getCycles}} } \examples{\dontrun{ ###Connect to database asp.dbConnect(user="ralmond",dbname="MCMC") asp.repairAllTables() ###Check status of chains getCycles() ### You will want to run this next part manually. ### Adjust the chain a couple of cycles back to be sure all is ### cleanly written. For example, if # > getCycles() # chain_first_cycle chain_last_cycle # 1 1 3000 # 2 1 1270 # 3 1 -1 ## Then you might use: asp.trimTables(1268,chain=2) ## Again for sanity check. getCycles() ## Continuting StatShop will resume with Chain 2, Cycle 1268. } } \keyword{database} \keyword{utilities}