Displaying 1 result from an estimated 1 matches for "matrix_ret1".
Did you mean:
matrix_ret
2008 Oct 07
1
FW: Reading Data
...returns=(p[2]/p[1])-1
}
#print(p)
#print(I)
return(returns)
}
##The original Funda##
matrix_ret=matrix(0,length(q_ins),length(q_sd))
for(i in 1:length(q_sd))
{
for(j in 1:length(q_ins))
{
matrix_ret[j,i]=returns(q_ins[j],q_sd[i],q_ed[i])
}
}
#Removing NA from the matrix
matrix_ret1=sapply(X=matrix_ret, FUN=function(x)
ifelse(is.na(x),0.00,x))
matrix_ret=matrix(matrix_ret1,length(q_ins),length(q_sd))
wt_ret=matrix(0,length(q_sd),1)
for(i in 1:length(q_sd))
{
for(j in 1:length(q_ins))
{
wt_ret[i]=wt_ret[i]+(wt[j]*matrix_ret[j,i])
}
}
result=cbind(q_ed,wt_ret)
Rahu...