[R-SIG-Finance] treynor black (1973)

ssmith88 at umd.edu ssmith88 at umd.edu
Thu Oct 8 03:52:53 CEST 2009


Not familiar with the theory, but i googled it and made this as an exercise.  I assumed you had all the inputs already though you'll probably want to start from raw price data.  Shouldn't be too hard to write something to find the inputs from the price data and then follow with this function.  Note this is sloppy as all variables are saved globally, you can clean it as you like.  Also, not sure if there is a package for this already or not. Hope this helps, there's an example below.       


treynorBlack<-function(mret,mvar,beta,alpha,var)
{
#n mispriced assets
#beta,alpha,var are vectors of length n
#mvar and mret are the market variance/return
num<<-numeric(length(beta))

for(i in 1:(length(beta)))
{
num[i]=(alpha[i])/(var[i])
}
denom<<-sum(num)
weights<<-numeric(length(beta))
for(i in 1:length(beta))
{
weights[i]<<-num[i]/denom
}
activeAlpha<<-weights%*%alpha
activeBeta<<-weights%*%beta
activeVar<<-weights%*%var
w<<-(activeAlpha/activeVar)/(mret/mvar)
activeFraction<<-w/(1+w*(1-activeBeta))
passiveFraction<<-1-activeFraction
}


> beta1<-c(1.5,1.2,.7)
> alpha1<-c(.01,.005,.02)
> var1<-c(.15,.17,.25)
> mret<-.09
> mret1<-.09
> mvar1<-.18
> treynorBlack(mret=mret1,mvar=mvar1,beta=beta1,alpha=alpha1,var=var1)
> activeFraction
[1,] 0.1395909
> passiveFraction
[1,] 0.860409
> weights
0.3786192 0.1670379 0.4543430



More information about the R-SIG-Finance mailing list