There is probably a greater density of potential users on the SIG- Finance mailing list.

I still think you attribute special powers to that function that the authors never build into it. It does not predict the future. It doesn't even simulate the future. It just reformats into a matrix the data it is given in the form of a list. It does no calculations:

> create_cashflows_matrix
function (group, include_price = FALSE)
{
n_of_cf <- summary(factor(group$CASHFLOWS$ISIN, levels = group $ISIN))
    n_of_bonds <- length(n_of_cf)
    max_cf <- max(n_of_cf)
    pos_cf <- c(0, cumsum(n_of_cf))
CASHFLOWMATRIX <- mapply(function(i) c(group$CASHFLOWS $CF[(pos_cf[i] +
        1):pos_cf[i + 1]], rep(0, max_cf - n_of_cf[i])), 1:n_of_bonds)
    if (include_price == TRUE) {
CASHFLOWMATRIX <- rbind(-(group[["PRICE"]] + group[["ACCRUED"]]),
            CASHFLOWMATRIX)
    }
    colnames(CASHFLOWMATRIX) <- group$ISIN
    CASHFLOWMATRIX
}

--
David Winsemius

On Mar 20, 2009, at 1:52 PM, Chirantan Kundu wrote:

Actually I was looking for someone who has some experience in using
the package. Anyway, thanks for your input.

On Fri, Mar 20, 2009 at 10:51 PM, David Winsemius
<dwinsem...@comcast.net> wrote:
How could I (or anyone for that matter) possibly answer that question?

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


On Mar 20, 2009, at 1:07 PM, Chirantan Kundu wrote:

Thanks for the help. RATING & NAME are not required for this call as
par documentation. About the CASHFLOWS I'm not sure as I'm going to
call create_cashflows_matrix which is supposed to return me the
cashflow matrix. Do I still need to have the CASHFLOWSlist in the
structure?

On Fri, Mar 20, 2009 at 9:48 PM, David Winsemius <dwinsem...@comcast.net >
wrote:

Besides needing a grouped structure and not calling that function with a group name, your sub-structure does not seem complete when compared with
the
AAA group within the example dataset;

str(allbonds)  # your structure

List of 1
 $ mybonds:List of 7
 ..$ ISIN        : chr [1:2] "IN0020080019" "IN0020020163"
 ..$ MATURITYDATE:Class 'Date'  num [1:2] 14244 14974
 ..$ STARTDATE   :Class 'Date'  num [1:2] 11323 11688
 ..$ COUPONRATE  : num [1:2] 8.24 7.95
 ..$ PRICE       : num [1:2] 50 100
 ..$ ACCRUED     : num [1:2] 5 2
 ..$ TODAY       :Class 'Date'  num [1:2] 14323 14323

str(corpbonds$AAA)

List of 10
$ ISIN : chr [1:20] "XS0078921441" "XS0079017637" "XS0090078907"
"XS0119246626" ...
$ MATURITYDATE:Class 'Date' num [1:20] 14476 15212 16680 15631 14203
...
$ STARTDATE :Class 'Date' num [1:20] 10093 10099 10471 11248 11281
...
 $ COUPONRATE  : num [1:20] 0.0563 0.0575 0.0512 0.0587 0.0575 ...
$ RATING : Factor w/ 10 levels "A","A-","A+",..: 7 7 7 7 7 7 7 7 7
7
...
 $ NAME        : Factor w/ 249 levels "4.88 BP CAPITAL MARKETS PLC
31-MAR-09",..: 109 109 109 109 109 109 229 153 109 149 ...
 $ PRICE       : num [1:20] 108 113 112 115 108 ...
 $ ACCRUED     : num [1:20] 1.328 1.262 1.039 0.451 5.671 ...
 $ CASHFLOWS   :List of 3
 ..$ ISIN: chr [1:126] "XS0078921441" "XS0078921441" "XS0078921441"
"XS0078921441" ...
 ..$ CF  : num [1:126] 5.61 5.61 5.62 105.62 5.78 ...
..$ DATE:Class 'Date' num [1:126] 13381 13745 14111 14476 13388 ...
 $ TODAY       :Class 'Date'  num 13102

On Mar 20, 2009, at 12:05 PM, David Winsemius wrote:


On Mar 20, 2009, at 10:15 AM, Chirantan Kundu wrote:

Here it goes -

library(termstrc)
ISIN <- vector()
ISIN[1]<-"IN0020080019"
ISIN[2]<-"IN0020020163"
MATURITYDATE<-as.Date(c("20081231","20101231"),"%Y%m%d")
STARTDATE<-as.Date(c("20010101","20020101"),format="%Y%m%d")
COUPONRATE<-c(8.24,7.95)
PRICE<-(50,100)
ACCRUED<-c(5,2)
TODAY<-c(Sys.Date(),Sys.Date())
mybonds <- list(ISIN,MATURITYDATE,STARTDATE,
COUPONRATE,PRICE,ACCRUED,TODAY)
names(mybonds) <- c("ISIN","MATURITYDATE","STARTDATE","COUPONRATE",
"PRICE","ACCRUED","TODAY")
allbonds <- list(mybonds)
names(allbonds)<-c("mybonds")
create_cashflows_matrix(allbonds)


I also tried -

library(termstrc)
data(corpbonds)
create_cashflows_matrix(corpbonds)

Your collection of bonds need to be organized in groups and the call to create_cashflows_matrix needs to call those groups by name. In the case
of
the corpbonds dataset, this call gets you output:

create_cashflows_matrix( corpbonds$AAA )

--
David Winsemius


Both result into the same error - Error in as.vector(x, mode) :
invalid 'mode' argument.
Regards.

On Fri, Mar 20, 2009 at 7:09 PM, David Winsemius
<dwinsem...@comcast.net>
wrote:

Got code?

On Mar 20, 2009, at 8:15 AM, Chirantan Kundu wrote:

I'm trying to use the package termstrc. However I cannot figure out
how to invoke helper functions like create_cashflows_matrix &
create_maturities_matrix. Even when I try to invoke those with the data supplied with the package (say, corpbonds), it throws error saying "Error in as.vector(x, mode) : invalid 'mode' argument". Can
anybody provide some working example for these?
I'm on Windows XP and using R-2.7.2 + termstrc 1.1.


PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


____________________________________
Visit us at http://www.2pirad.com


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


____________________________________
Visit us at http://www.2pirad.com


David Winsemius, MD
Heritage Laboratories
West Hartford, CT


____________________________________
Visit us at http://www.2pirad.com


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to