#################################################################### ####### ####### ####### Recover the livebids from the Proxybids ####### ####### ####### #################################################################### #################################################################### #### find the bid increment for a given auction price #### #################################################################### ## function bid.incr(price) bid.incr <- function(price) { bidint <- c(0,0.99,4.99,24.99,99.99,249.99,499.99,999.99,2499.99,4999.99) ## interval of prices inc <- c(0.05,0.25,0.5,1,2.5,5,10,25,50,100) ## increments of price for particular interval inc[findInterval(price,bidint)] } ############################################################ ########## make livebids ########### ############################################################ ## function recover.livebids(bids,bidder,openbid,winningbid) ## This function reconstructs the sequence of livebids by ## inputing the raw bids,bidder IDs and opening bid recover.livebids <- function(bids,bidder,openbid,winningbid) { nbid <- length(bids) if (nbid==1) { live <- openbid live } else { if (nbid==2) {live <- numeric(nbid) live[1] <- openbid live[nbid] <- winningbid live} else { live <- numeric(nbid) maxbid <- bids[1] live[1] <- openbid live[nbid] <- winningbid currentprice <- bids[1] maxbidder <- bidder[1] for (i in 2:(nbid-1)) { newbid <- bids[i] newbidder <- bidder[i] if (newbid > maxbid) { if (!(identical(newbidder,maxbidder))) { incr <- bid.incr(maxbid) if (newbid < maxbid+incr) currentprice <- newbid else currentprice <- maxbid+incr maxbid <- newbid maxbidder <- newbidder } else {maxbid <- newbid maxbidder <- maxbidder } } else {if (newbid < maxbid) { incr <- bid.incr(newbid) if (newbid+incr>=maxbid) currentprice <- maxbid else currentprice <- newbid+incr maxbid <- maxbid maxbidder <- maxbidder } else { if (!(identical(newbidder,maxbidder))) {currentprice <- maxbid maxbid <- maxbid maxbidder <- maxbidder } else {currentprice <- currentprice maxbid <- maxbid maxbidder <- maxbidder } } } live[i] <- currentprice } live } } }