pp.randportbeta <- function (rp, pricevec, betavec) { # placed in the public domain 2012 by Burns Statistics pricevec <- drop(pricevec) if(length(dim(pricevec))) stop("need prices at a single time") betavec <- drop(betavec) if(length(dim(betavec))) stop("need betas at a single time") rpw <- valuation(rp, prices=pricevec, weight=TRUE, collapse=FALSE) ans <- numeric(length(rpw)) for(i in seq(along=ans)) { tw <- rpw[[i]] ans[i] <- sum(tw * betavec[names(tw)]) } attr(ans, "call") <- match.call() ans }