[R-SIG-Finance] Applying quarterly weights on daily returns

Murali Menon feanor0 at hotmail.com
Tue Jun 10 11:08:16 CEST 2008


Hi,

Thanks, that does the trick. Didn't know about the rowsum() magic.

Not sure I understand how tsig * lag(rets) works. tsig is a bigger matrix
(one extra row) than lag(rets), right? So should not there by some recycling
of column elements of lag(rets)?

Cheers,
Murali


> Date: Mon, 9 Jun 2008 12:55:54 -0400
> From: ggrothendieck at gmail.com
> To: feanor0 at hotmail.com
> Subject: Re: [R-SIG-Finance] Applying quarterly weights on daily returns
> CC: r-sig-finance at stat.math.ethz.ch
>
> If I understand it then you want to lag rets by one day, mulitply that
> by tsig and then sum over the quarter and mulitply that by wts:
>
> z <- tsig * lag(rets)
> rowsum(z, as.yearqtr(time(z))) * wts
>
> The rowsum output is a matrix and wts is zoo so
> this depends on them having the same shapes.
>
> On Mon, Jun 9, 2008 at 12:19 PM, Murali Menon  wrote:
>>
>>
>> Folks,
>>
>> I have quarterly weights (4 quarters) and 300 days of daily trading signals and returns for 3 assets.
>>
>> library(zoo)
>> set.seed(123)
>>
>> wts <- abs(zoo(matrix(rnorm(36), ncol = 3), yearqtr(1970 + (0 : 3) / 4)) )
>>
>> rets <- zoo(matrix(rnorm(900), ncol = 3) / 100, order.by = as.Date(1 : 300))
>>
>> tsig <- zoo(rbinom(300, 2, 0.5) - 1, order.by = as.Date(1 : 300))
>>
>> In each quarter, the return would be like:
>>
>> rowSums(head(tsig, -1) * tail(rets, -1) * wts(of that quarter))
>>
>> Where the trading signal is applied today, but its return is observed tomorrow.
>>
>> How to apply quarterly series on a daily series, though?
>>
>> Please advise.
>>
>> Thanks,
>>
>> Murali
>> _________________________________________________________________
>> Instantly invite friends from Facebook and other social networks to join yo
>> https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>>

_________________________________________________________________
Now you can invite friends from Facebook and other groups to join you on Wi
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_AddNow_Now


More information about the R-SIG-Finance mailing list