The time series analysis functions/packages don't seem to like my data

View: New views
13 Messages — Rating Filter:   Alert me  

The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have hundreds of megabytes of price data time series, and perl
scripts that extract it to tab delimited files (I have C++ programs
that must analyse this data too, so I get Perl to extract it rather
than have multiple connections to the DB).

I can read the data into an R object without any problems.

thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
= FALSE, na.strings="")
thedata

The above statements give me precisely what I expect.  The last few
lines of output are:
8190 2009-06-16 49.30
8191 2009-06-17 48.40
8192 2009-06-18 47.72
8193 2009-06-19 48.83
8194 2009-06-22 46.85
8195 2009-06-23 47.11
8196 2009-06-24 46.97
8197 2009-06-25 47.43

I have loaded Rmetrics and PerformanceAnalytics, among other packages.
 I tried as.timeseries, but R2.9.1 tells me there is no such function.
I tried as.ts(thedata), but that only replaces the date field by the
row label in 'thedata'.

If I apply the performance analytics drawdowns function to either
thedata or thedate$V2, I get errors:
> table.Drawdowns(thedata,top = 10)
Error in 1 + na.omit(x) : non-numeric argument to binary operator
> table.Drawdowns(thedata$V2, top = 10)
Error in if (thisSign == priorSign) { :
  missing value where TRUE/FALSE needed
>

thedata$V2 by itself does give me the price data from the file.

I am a relative novice in using R for timeseries, so I wouldn't be
surprised it I missed something that would be obvious to someone more
practiced in using R, but I don't see what that could be from the
documentation of the functions I am looking at using.  I have no
shortage of data, and I don't want to write C++ code, or perl code, to
do all the kinds of calculations provided in, Rmetrics and
performanceanalytics, but getting my data into the functions these
packages provide is killing me!

What did I miss?

Thanks

Ted

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Mark Knecht :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:

> I have hundreds of megabytes of price data time series, and perl
> scripts that extract it to tab delimited files (I have C++ programs
> that must analyse this data too, so I get Perl to extract it rather
> than have multiple connections to the DB).
>
> I can read the data into an R object without any problems.
>
> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
> = FALSE, na.strings="")
> thedata
>
> The above statements give me precisely what I expect.  The last few
> lines of output are:
> 8190 2009-06-16 49.30
> 8191 2009-06-17 48.40
> 8192 2009-06-18 47.72
> 8193 2009-06-19 48.83
> 8194 2009-06-22 46.85
> 8195 2009-06-23 47.11
> 8196 2009-06-24 46.97
> 8197 2009-06-25 47.43
>
> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
> I tried as.ts(thedata), but that only replaces the date field by the
> row label in 'thedata'.
>
> If I apply the performance analytics drawdowns function to either
> thedata or thedate$V2, I get errors:
>> table.Drawdowns(thedata,top = 10)
> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>> table.Drawdowns(thedata$V2, top = 10)
> Error in if (thisSign == priorSign) { :
>  missing value where TRUE/FALSE needed
>>
>
> thedata$V2 by itself does give me the price data from the file.
>
> I am a relative novice in using R for timeseries, so I wouldn't be
> surprised it I missed something that would be obvious to someone more
> practiced in using R, but I don't see what that could be from the
> documentation of the functions I am looking at using.  I have no
> shortage of data, and I don't want to write C++ code, or perl code, to
> do all the kinds of calculations provided in, Rmetrics and
> performanceanalytics, but getting my data into the functions these
> packages provide is killing me!
>
> What did I miss?
>
> Thanks
>
> Ted
>
> ______________________________________________
> R-help@... 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.
>

Could you supply some portion of the results when you run the example
on your data? The example goes like:

data(edhec)
R=edhec[,"Funds.of.Funds"]
findDrawdowns(R)
sortDrawdowns(findDrawdowns(R))

How are you using the function with your data?

- Mark

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mark

Thanks for replying.

Here is a short snippet that reproduces the problem:

library(PerformanceAnalytics)
thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
= FALSE, na.strings="")
thedata
x = as.timeseries(thedata)
x
table.Drawdowns(thedata,top = 10)
table.Drawdowns(thedata$V2, top = 10)

The object 'thedata' has exactly what I expected. the line 'thedata'
prints the correct contents of the file with each row prepended by a
line number.  The last few lines are:

8191 2009-06-17 48.40
8192 2009-06-18 47.72
8193 2009-06-19 48.83
8194 2009-06-22 46.85
8195 2009-06-23 47.11
8196 2009-06-24 46.97
8197 2009-06-25 47.43

The number of lines (8197), dates (and their format) and prices are correct.

The last four lines produce the following output:
> x = as.timeseries(thedata)
Error: could not find function "as.timeseries"
> x
Error: object 'x' not found
> table.Drawdowns(thedata,top = 10)
Error in 1 + na.omit(x) : non-numeric argument to binary operator
> table.Drawdowns(thedata$V2, top = 10)
Error in if (thisSign == priorSign) { :
  missing value where TRUE/FALSE needed
>

Are the functions in your example in Rmetrics or PerformanceAnalytics?
(like I said, I am just beginning this exploration, and I started with
table.Drawdowns because it produces information that I need first)
And given that my data is in tab delimited files, and can be read
using read.csv, how do I feed my data into your four statements?

My guess is I am missing something in coercing my data in (the data
frame?) thedata into a timeseries array of the sort the time series
analysis functions need: and one of the things I find a bit confusing
is that some of the documentation for this mentions S3 classes and
some mentions S4 classes (I don't know if that means I have to make
multiple copies of my data to get the output I need).  I could coerce
thedata$V2 into a numeric vector, but I'd rather not separate the
prices from their dates unless that is necessary (how would one
produce monthly, annual or annualized rates of return if one did
that?).

Thanks

Ted

On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:

> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>> I have hundreds of megabytes of price data time series, and perl
>> scripts that extract it to tab delimited files (I have C++ programs
>> that must analyse this data too, so I get Perl to extract it rather
>> than have multiple connections to the DB).
>>
>> I can read the data into an R object without any problems.
>>
>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>> = FALSE, na.strings="")
>> thedata
>>
>> The above statements give me precisely what I expect.  The last few
>> lines of output are:
>> 8190 2009-06-16 49.30
>> 8191 2009-06-17 48.40
>> 8192 2009-06-18 47.72
>> 8193 2009-06-19 48.83
>> 8194 2009-06-22 46.85
>> 8195 2009-06-23 47.11
>> 8196 2009-06-24 46.97
>> 8197 2009-06-25 47.43
>>
>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>> I tried as.ts(thedata), but that only replaces the date field by the
>> row label in 'thedata'.
>>
>> If I apply the performance analytics drawdowns function to either
>> thedata or thedate$V2, I get errors:
>>> table.Drawdowns(thedata,top = 10)
>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>> table.Drawdowns(thedata$V2, top = 10)
>> Error in if (thisSign == priorSign) { :
>>  missing value where TRUE/FALSE needed
>>>
>>
>> thedata$V2 by itself does give me the price data from the file.
>>
>> I am a relative novice in using R for timeseries, so I wouldn't be
>> surprised it I missed something that would be obvious to someone more
>> practiced in using R, but I don't see what that could be from the
>> documentation of the functions I am looking at using.  I have no
>> shortage of data, and I don't want to write C++ code, or perl code, to
>> do all the kinds of calculations provided in, Rmetrics and
>> performanceanalytics, but getting my data into the functions these
>> packages provide is killing me!
>>
>> What did I miss?
>>
>> Thanks
>>
>> Ted
>>
>> ______________________________________________
>> R-help@... 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.
>>
>
> Could you supply some portion of the results when you run the example
> on your data? The example goes like:
>
> data(edhec)
> R=edhec[,"Funds.of.Funds"]
> findDrawdowns(R)
> sortDrawdowns(findDrawdowns(R))
>
> How are you using the function with your data?
>
> - Mark
>

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by David Winsemius :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 3, 2009, at 7:34 PM, Ted Byers wrote:

> Hi Mark
>
> Thanks for replying.
>
> Here is a short snippet that reproduces the problem:
>
> library(PerformanceAnalytics)
> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
> = FALSE, na.strings="")
> thedata
> x = as.timeseries(thedata)
> x
> table.Drawdowns(thedata,top = 10)
> table.Drawdowns(thedata$V2, top = 10)
>
> The object 'thedata' has exactly what I expected. the line 'thedata'
> prints the correct contents of the file with each row prepended by a
> line number.  The last few lines are:
>
> 8191 2009-06-17 48.40
> 8192 2009-06-18 47.72
> 8193 2009-06-19 48.83
> 8194 2009-06-22 46.85
> 8195 2009-06-23 47.11
> 8196 2009-06-24 46.97
> 8197 2009-06-25 47.43
>
> The number of lines (8197), dates (and their format) and prices are  
> correct.
>
> The last four lines produce the following output:
>> x = as.timeseries(thedata)
> Error: could not find function "as.timeseries"

That is not telling you that there is no such function but rather that  
you have not loaded the package that contains it. To find out what  
package ( which you have installed on your machine) contains a  
function, you type one of these equivalents:

??"as.timeseries"

help.search("as.timeseries")

If the needed package is not installed on your machine then you need  
to use one of the R search sites. I use:
http://search.r-project.org/nmz.html

In my installation there is a function named as.timeSeries in the  
package timeSeries. Not sure if that is the function you want.  
(Spelling must be exact in R.) If it is, then try:

library(timeSeries)

>> x
> Error: object 'x' not found

Not surprising, since the effort to create "x" failed.


>> table.Drawdowns(thedata,top = 10)
> Error in 1 + na.omit(x) : non-numeric argument to binary operator

Not sure whether this is due to earlier errors or something that is  
wrong with your data. Most probably the latter, and since you have not  
reduced it to a reproducible example, no one can tell from a distance.  
If you were expecting the operation of giving "thedata" to  
as.timeseries() to have a lasting effect on "thedata", you need to re-
read the introductory material on R that is readily available. That's  
not how the language works.

>> table.Drawdowns(thedata$V2, top = 10)
> Error in if (thisSign == priorSign) { :
>  missing value where TRUE/FALSE needed
>>
>
> Are the functions in your example in Rmetrics or PerformanceAnalytics?
> (like I said, I am just beginning this exploration, and I started with
> table.Drawdowns because it produces information that I need first)
> And given that my data is in tab delimited files, and can be read
> using read.csv, how do I feed my data into your four statements?
>
> My guess is I am missing something in coercing my data in (the data
> frame?) thedata into a timeseries array of the sort the time series
> analysis functions need: and one of the things I find a bit confusing
> is that some of the documentation for this mentions S3 classes and
> some mentions S4 classes (I don't know if that means I have to make
> multiple copies of my data to get the output I need).  I could coerce
> thedata$V2 into a numeric vector, but I'd rather not separate the
> prices from their dates unless that is necessary (how would one
> produce monthly, annual or annualized rates of return if one did
> that?).
>
> Thanks
>
> Ted
>
> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...>  
> wrote:
>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...>  
>> wrote:
>>> I have hundreds of megabytes of price data time series, and perl
>>> scripts that extract it to tab delimited files (I have C++ programs
>>> that must analyse this data too, so I get Perl to extract it rather
>>> than have multiple connections to the DB).
>>>
>>> I can read the data into an R object without any problems.
>>>
>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t",  
>>> header
>>> = FALSE, na.strings="")
>>> thedata
>>>
>>> The above statements give me precisely what I expect.  The last few
>>> lines of output are:
>>> 8190 2009-06-16 49.30
>>> 8191 2009-06-17 48.40
>>> 8192 2009-06-18 47.72
>>> 8193 2009-06-19 48.83
>>> 8194 2009-06-22 46.85
>>> 8195 2009-06-23 47.11
>>> 8196 2009-06-24 46.97
>>> 8197 2009-06-25 47.43
>>>
>>> I have loaded Rmetrics and PerformanceAnalytics, among other  
>>> packages.
>>>  I tried as.timeseries, but R2.9.1 tells me there is no such  
>>> function.
>>> I tried as.ts(thedata), but that only replaces the date field by the
>>> row label in 'thedata'.
>>>
>>> If I apply the performance analytics drawdowns function to either
>>> thedata or thedate$V2, I get errors:
>>>> table.Drawdowns(thedata,top = 10)
>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>> table.Drawdowns(thedata$V2, top = 10)
>>> Error in if (thisSign == priorSign) { :
>>>  missing value where TRUE/FALSE needed
>>>>
>>>
>>> thedata$V2 by itself does give me the price data from the file.
>>>
>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>> surprised it I missed something that would be obvious to someone  
>>> more
>>> practiced in using R, but I don't see what that could be from the
>>> documentation of the functions I am looking at using.  I have no
>>> shortage of data, and I don't want to write C++ code, or perl  
>>> code, to
>>> do all the kinds of calculations provided in, Rmetrics and
>>> performanceanalytics, but getting my data into the functions these
>>> packages provide is killing me!
>>>
>>> What did I miss?
>>>
>>> Thanks
>>>
>>> Ted
>>>
>>> ______________________________________________
>>> R-help@... 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.
>>>
>>
>> Could you supply some portion of the results when you run the example
>> on your data? The example goes like:
>>
>> data(edhec)
>> R=edhec[,"Funds.of.Funds"]
>> findDrawdowns(R)
>> sortDrawdowns(findDrawdowns(R))
>>
>> How are you using the function with your data?
>>
>> - Mark
>>
>
> ______________________________________________
> R-help@... 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

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Gabor Grothendieck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

# 1. You can directly read your data into a zoo series like this:

Lines <- "8190 2009-06-16 49.30
8191 2009-06-17 48.40
8192 2009-06-18 47.72
8193 2009-06-19 48.83
8194 2009-06-22 46.85
8195 2009-06-23 47.11
8196 2009-06-24 46.97
8197 2009-06-25 47.43"

library(zoo)
z <- read.zoo(textConnection(Lines), index = 2)

# and from that you can readily convert it to
# other time series formats if need be.

# 2. Read ?table.Drawdowns.  It asks for __returns__, not raw
# data as input.

library(PerformanceAnalytics)
table.Drawdowns(diff(log(z$V3)))

That gives me an error and looking into it it seems
likely that table.Drawdowns fails when there is only one
drawdown.

library(help = PerformanceAnalytics)

will give you the author's email address to whom you
can report the problem.

On Fri, Jul 3, 2009 at 7:34 PM, Ted Byers<r.ted.byers@...> wrote:

> Hi Mark
>
> Thanks for replying.
>
> Here is a short snippet that reproduces the problem:
>
> library(PerformanceAnalytics)
> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
> = FALSE, na.strings="")
> thedata
> x = as.timeseries(thedata)
> x
> table.Drawdowns(thedata,top = 10)
> table.Drawdowns(thedata$V2, top = 10)
>
> The object 'thedata' has exactly what I expected. the line 'thedata'
> prints the correct contents of the file with each row prepended by a
> line number.  The last few lines are:
>
> 8191 2009-06-17 48.40
> 8192 2009-06-18 47.72
> 8193 2009-06-19 48.83
> 8194 2009-06-22 46.85
> 8195 2009-06-23 47.11
> 8196 2009-06-24 46.97
> 8197 2009-06-25 47.43
>
> The number of lines (8197), dates (and their format) and prices are correct.
>
> The last four lines produce the following output:
>> x = as.timeseries(thedata)
> Error: could not find function "as.timeseries"
>> x
> Error: object 'x' not found
>> table.Drawdowns(thedata,top = 10)
> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>> table.Drawdowns(thedata$V2, top = 10)
> Error in if (thisSign == priorSign) { :
>  missing value where TRUE/FALSE needed
>>
>
> Are the functions in your example in Rmetrics or PerformanceAnalytics?
> (like I said, I am just beginning this exploration, and I started with
> table.Drawdowns because it produces information that I need first)
> And given that my data is in tab delimited files, and can be read
> using read.csv, how do I feed my data into your four statements?
>
> My guess is I am missing something in coercing my data in (the data
> frame?) thedata into a timeseries array of the sort the time series
> analysis functions need: and one of the things I find a bit confusing
> is that some of the documentation for this mentions S3 classes and
> some mentions S4 classes (I don't know if that means I have to make
> multiple copies of my data to get the output I need).  I could coerce
> thedata$V2 into a numeric vector, but I'd rather not separate the
> prices from their dates unless that is necessary (how would one
> produce monthly, annual or annualized rates of return if one did
> that?).
>
> Thanks
>
> Ted
>
> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:
>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>>> I have hundreds of megabytes of price data time series, and perl
>>> scripts that extract it to tab delimited files (I have C++ programs
>>> that must analyse this data too, so I get Perl to extract it rather
>>> than have multiple connections to the DB).
>>>
>>> I can read the data into an R object without any problems.
>>>
>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>>> = FALSE, na.strings="")
>>> thedata
>>>
>>> The above statements give me precisely what I expect.  The last few
>>> lines of output are:
>>> 8190 2009-06-16 49.30
>>> 8191 2009-06-17 48.40
>>> 8192 2009-06-18 47.72
>>> 8193 2009-06-19 48.83
>>> 8194 2009-06-22 46.85
>>> 8195 2009-06-23 47.11
>>> 8196 2009-06-24 46.97
>>> 8197 2009-06-25 47.43
>>>
>>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>>> I tried as.ts(thedata), but that only replaces the date field by the
>>> row label in 'thedata'.
>>>
>>> If I apply the performance analytics drawdowns function to either
>>> thedata or thedate$V2, I get errors:
>>>> table.Drawdowns(thedata,top = 10)
>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>> table.Drawdowns(thedata$V2, top = 10)
>>> Error in if (thisSign == priorSign) { :
>>>  missing value where TRUE/FALSE needed
>>>>
>>>
>>> thedata$V2 by itself does give me the price data from the file.
>>>
>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>> surprised it I missed something that would be obvious to someone more
>>> practiced in using R, but I don't see what that could be from the
>>> documentation of the functions I am looking at using.  I have no
>>> shortage of data, and I don't want to write C++ code, or perl code, to
>>> do all the kinds of calculations provided in, Rmetrics and
>>> performanceanalytics, but getting my data into the functions these
>>> packages provide is killing me!
>>>
>>> What did I miss?
>>>
>>> Thanks
>>>
>>> Ted
>>>
>>> ______________________________________________
>>> R-help@... 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.
>>>
>>
>> Could you supply some portion of the results when you run the example
>> on your data? The example goes like:
>>
>> data(edhec)
>> R=edhec[,"Funds.of.Funds"]
>> findDrawdowns(R)
>> sortDrawdowns(findDrawdowns(R))
>>
>> How are you using the function with your data?
>>
>> - Mark
>>
>
> ______________________________________________
> R-help@... 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.
>

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David,

Thanks for replying.

On Fri, Jul 3, 2009 at 8:08 PM, David Winsemius<dwinsemius@...> wrote:

>
> On Jul 3, 2009, at 7:34 PM, Ted Byers wrote:
>
>> Hi Mark
>>
>> Thanks for replying.
>>
>> Here is a short snippet that reproduces the problem:
>>
>> library(PerformanceAnalytics)
>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>> = FALSE, na.strings="")
>> thedata
>> x = as.timeseries(thedata)
>> x
>> table.Drawdowns(thedata,top = 10)
>> table.Drawdowns(thedata$V2, top = 10)
>>
>> The object 'thedata' has exactly what I expected. the line 'thedata'
>> prints the correct contents of the file with each row prepended by a
>> line number.  The last few lines are:
>>
>> 8191 2009-06-17 48.40
>> 8192 2009-06-18 47.72
>> 8193 2009-06-19 48.83
>> 8194 2009-06-22 46.85
>> 8195 2009-06-23 47.11
>> 8196 2009-06-24 46.97
>> 8197 2009-06-25 47.43
>>
>> The number of lines (8197), dates (and their format) and prices are
>> correct.
>>
>> The last four lines produce the following output:
>>>
>>> x = as.timeseries(thedata)
>>
>> Error: could not find function "as.timeseries"
>
> That is not telling you that there is no such function but rather that you
> have not loaded the package that contains it. To find out what package (
> which you have installed on your machine) contains a function, you type one
> of these equivalents:
>
> ??"as.timeseries"
>
> help.search("as.timeseries")
>
I did  this, which is why I tried as.timeseries in the first place.

> If the needed package is not installed on your machine then you need to use
> one of the R search sites. I use:
> http://search.r-project.org/nmz.html
>
> In my installation there is a function named as.timeSeries in the package
> timeSeries. Not sure if that is the function you want. (Spelling must be
> exact in R.) If it is, then try:
>
> library(timeSeries)
>
timeSeries was already installed.  And using library(timeSeries)
succeeds but does not help.

>>> x
>>
>> Error: object 'x' not found
>
> Not surprising, since the effort to create "x" failed.
>
Right,.  I wasn't surprised by this.

>
>>> table.Drawdowns(thedata,top = 10)
>>
>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>
> Not sure whether this is due to earlier errors or something that is wrong
> with your data. Most probably the latter, and since you have not reduced it
> to a reproducible example, no one can tell from a distance. If you were
> expecting the operation of giving "thedata" to as.timeseries() to have a
> lasting effect on "thedata", you need to re-read the introductory material
> on R that is readily available. That's not how the language works.
>
This only thing missing from my example is the data file itself.  I
have no problems providing that too, but I didn't think that was
permitted (and it is too large to embed within a message.

No, I did not expect "thedata" to be modified by as.timeseries.  I
just thought I'd try to see if table.Drawdowns would accept a data
frame.  And my call to " table.Drawdowns(thedata$V2, top = 10)" was to
see if it would even accept a numeric vector (which is what I'd
expected the price data to be represented as).

Thanks

Ted

>>> table.Drawdowns(thedata$V2, top = 10)
>>
>> Error in if (thisSign == priorSign) { :
>>  missing value where TRUE/FALSE needed
>>>
>>
>> Are the functions in your example in Rmetrics or PerformanceAnalytics?
>> (like I said, I am just beginning this exploration, and I started with
>> table.Drawdowns because it produces information that I need first)
>> And given that my data is in tab delimited files, and can be read
>> using read.csv, how do I feed my data into your four statements?
>>
>> My guess is I am missing something in coercing my data in (the data
>> frame?) thedata into a timeseries array of the sort the time series
>> analysis functions need: and one of the things I find a bit confusing
>> is that some of the documentation for this mentions S3 classes and
>> some mentions S4 classes (I don't know if that means I have to make
>> multiple copies of my data to get the output I need).  I could coerce
>> thedata$V2 into a numeric vector, but I'd rather not separate the
>> prices from their dates unless that is necessary (how would one
>> produce monthly, annual or annualized rates of return if one did
>> that?).
>>
>> Thanks
>>
>> Ted
>>
>> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:
>>>
>>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>>>>
>>>> I have hundreds of megabytes of price data time series, and perl
>>>> scripts that extract it to tab delimited files (I have C++ programs
>>>> that must analyse this data too, so I get Perl to extract it rather
>>>> than have multiple connections to the DB).
>>>>
>>>> I can read the data into an R object without any problems.
>>>>
>>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>>>> = FALSE, na.strings="")
>>>> thedata
>>>>
>>>> The above statements give me precisely what I expect.  The last few
>>>> lines of output are:
>>>> 8190 2009-06-16 49.30
>>>> 8191 2009-06-17 48.40
>>>> 8192 2009-06-18 47.72
>>>> 8193 2009-06-19 48.83
>>>> 8194 2009-06-22 46.85
>>>> 8195 2009-06-23 47.11
>>>> 8196 2009-06-24 46.97
>>>> 8197 2009-06-25 47.43
>>>>
>>>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>>>> I tried as.ts(thedata), but that only replaces the date field by the
>>>> row label in 'thedata'.
>>>>
>>>> If I apply the performance analytics drawdowns function to either
>>>> thedata or thedate$V2, I get errors:
>>>>>
>>>>> table.Drawdowns(thedata,top = 10)
>>>>
>>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>>>
>>>>> table.Drawdowns(thedata$V2, top = 10)
>>>>
>>>> Error in if (thisSign == priorSign) { :
>>>>  missing value where TRUE/FALSE needed
>>>>>
>>>>
>>>> thedata$V2 by itself does give me the price data from the file.
>>>>
>>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>>> surprised it I missed something that would be obvious to someone more
>>>> practiced in using R, but I don't see what that could be from the
>>>> documentation of the functions I am looking at using.  I have no
>>>> shortage of data, and I don't want to write C++ code, or perl code, to
>>>> do all the kinds of calculations provided in, Rmetrics and
>>>> performanceanalytics, but getting my data into the functions these
>>>> packages provide is killing me!
>>>>
>>>> What did I miss?
>>>>
>>>> Thanks
>>>>
>>>> Ted
>>>>
>>>> ______________________________________________
>>>> R-help@... 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.
>>>>
>>>
>>> Could you supply some portion of the results when you run the example
>>> on your data? The example goes like:
>>>
>>> data(edhec)
>>> R=edhec[,"Funds.of.Funds"]
>>> findDrawdowns(R)
>>> sortDrawdowns(findDrawdowns(R))
>>>
>>> How are you using the function with your data?
>>>
>>> - Mark
>>>
>>
>> ______________________________________________
>> R-help@... 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
>
>

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Mark Knecht :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 4:34 PM, Ted Byers<r.ted.byers@...> wrote:

> Hi Mark
>
> Thanks for replying.
>
> Here is a short snippet that reproduces the problem:
>
> library(PerformanceAnalytics)
> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
> = FALSE, na.strings="")
> thedata
> x = as.timeseries(thedata)
> x
> table.Drawdowns(thedata,top = 10)
> table.Drawdowns(thedata$V2, top = 10)
>
> The object 'thedata' has exactly what I expected. the line 'thedata'
> prints the correct contents of the file with each row prepended by a
> line number.  The last few lines are:
>
> 8191 2009-06-17 48.40
> 8192 2009-06-18 47.72
> 8193 2009-06-19 48.83
> 8194 2009-06-22 46.85
> 8195 2009-06-23 47.11
> 8196 2009-06-24 46.97
> 8197 2009-06-25 47.43
>
> The number of lines (8197), dates (and their format) and prices are correct.
>
> The last four lines produce the following output:
>> x = as.timeseries(thedata)
> Error: could not find function "as.timeseries"
>> x
> Error: object 'x' not found
>> table.Drawdowns(thedata,top = 10)
> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>> table.Drawdowns(thedata$V2, top = 10)
> Error in if (thisSign == priorSign) { :
>  missing value where TRUE/FALSE needed
>>
>
> Are the functions in your example in Rmetrics or PerformanceAnalytics?
> (like I said, I am just beginning this exploration, and I started with
> table.Drawdowns because it produces information that I need first)
> And given that my data is in tab delimited files, and can be read
> using read.csv, how do I feed my data into your four statements?
>
> My guess is I am missing something in coercing my data in (the data
> frame?) thedata into a timeseries array of the sort the time series
> analysis functions need: and one of the things I find a bit confusing
> is that some of the documentation for this mentions S3 classes and
> some mentions S4 classes (I don't know if that means I have to make
> multiple copies of my data to get the output I need).  I could coerce
> thedata$V2 into a numeric vector, but I'd rather not separate the
> prices from their dates unless that is necessary (how would one
> produce monthly, annual or annualized rates of return if one did
> that?).
>
> Thanks
>
> Ted
>
> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:
>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>>> I have hundreds of megabytes of price data time series, and perl
>>> scripts that extract it to tab delimited files (I have C++ programs
>>> that must analyse this data too, so I get Perl to extract it rather
>>> than have multiple connections to the DB).
>>>
>>> I can read the data into an R object without any problems.
>>>
>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>>> = FALSE, na.strings="")
>>> thedata
>>>
>>> The above statements give me precisely what I expect.  The last few
>>> lines of output are:
>>> 8190 2009-06-16 49.30
>>> 8191 2009-06-17 48.40
>>> 8192 2009-06-18 47.72
>>> 8193 2009-06-19 48.83
>>> 8194 2009-06-22 46.85
>>> 8195 2009-06-23 47.11
>>> 8196 2009-06-24 46.97
>>> 8197 2009-06-25 47.43
>>>
>>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>>> I tried as.ts(thedata), but that only replaces the date field by the
>>> row label in 'thedata'.
>>>
>>> If I apply the performance analytics drawdowns function to either
>>> thedata or thedate$V2, I get errors:
>>>> table.Drawdowns(thedata,top = 10)
>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>> table.Drawdowns(thedata$V2, top = 10)
>>> Error in if (thisSign == priorSign) { :
>>>  missing value where TRUE/FALSE needed
>>>>
>>>
>>> thedata$V2 by itself does give me the price data from the file.
>>>
>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>> surprised it I missed something that would be obvious to someone more
>>> practiced in using R, but I don't see what that could be from the
>>> documentation of the functions I am looking at using.  I have no
>>> shortage of data, and I don't want to write C++ code, or perl code, to
>>> do all the kinds of calculations provided in, Rmetrics and
>>> performanceanalytics, but getting my data into the functions these
>>> packages provide is killing me!
>>>
>>> What did I miss?
>>>
>>> Thanks
>>>
>>> Ted
>>>
>>> ______________________________________________
>>> R-help@... 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.
>>>
>>
>> Could you supply some portion of the results when you run the example
>> on your data? The example goes like:
>>
>> data(edhec)
>> R=edhec[,"Funds.of.Funds"]
>> findDrawdowns(R)
>> sortDrawdowns(findDrawdowns(R))
>>
>> How are you using the function with your data?
>>
>> - Mark
>>
>

Sorry, findDrawdowns is part of PerformanceAnalytics. I've added that
to this code so you can just copy it and run it all.

require(PerformanceAnalytics)
data(edhec)
class(edhec)
R=edhec[,"Funds.of.Funds"]
class(R)
findDrawdowns(R)
sortDrawdowns(findDrawdowns(R))

This is a subject that interests me. My data is read in using read.csv
which I think may provide similar problems should I ever want to use
this so I'm interested in how I solve it. I'm a newbie so be VERY
careful about anything I say!

What I see is that edhec is of class zoo, as is R. Here's what I did to check:

> require(PerformanceAnalytics)
> data(edhec)
> class(edhec)
[1] "zoo"
> R=edhec[,"Funds.of.Funds"]



> class(R)
[1] "zoo"
> findDrawdowns(R)
<SNIP>

> sortDrawdowns(findDrawdowns(R))
<SNIP>


Note that R, class zoo, has dates as the names and then a single column of data:

>
> R
Jan 1997 Feb 1997 Mar 1997 Apr 1997 May 1997 Jun 1997 Jul 1997 Aug
1997 Sep 1997 Oct 1997 Nov 1997 Dec 1997 Jan 1998 Feb 1998 Mar 1998
Apr 1998
  0.0317   0.0106  -0.0077   0.0009   0.0275   0.0225   0.0435
0.0051   0.0334  -0.0099  -0.0034   0.0089  -0.0036   0.0256   0.0373
 0.0125
May 1998 Jun 1998 Jul 1998 Aug 1998 Sep 1998 Oct 1998 Nov 1998 Dec
1998 Jan 1999 Feb 1999 Mar 1999 Apr 1999 May 1999 Jun 1999 Jul 1999
Aug 1999
 -0.0072   0.0021  -0.0007  -0.0616  -0.0037  -0.0002   0.0220
0.0222   0.0202  -0.0063   0.0213   0.0400   0.0119   0.0282   0.0088
 0.0028
<SNIP>
>

> names(R)
  [1] "1997-01-31" "1997-02-28" "1997-03-31" "1997-04-30" "1997-05-31"
"1997-06-30" "1997-07-31" "1997-08-31" "1997-09-30" "1997-10-31"
 [11] "1997-11-30" "1997-12-31" "1998-01-31" "1998-02-28" "1998-03-31"
"1998-04-30" "1998-05-31" "1998-06-30" "1998-07-31" "1998-08-31"
 [21] "1998-09-30" "1998-10-31" "1998-11-30" "1998-12-31" "1999-01-31"
"1999-02-28" "1999-03-31" "1999-04-30" "1999-05-31" "1999-06-30"
<SNIP>

> as.matrix(R)
                 R
1997-01-31  0.0317
1997-02-28  0.0106
1997-03-31 -0.0077
1997-04-30  0.0009
1997-05-31  0.0275
1997-06-30  0.0225
1997-07-31  0.0435
1997-08-31  0.0051
1997-09-30  0.0334
1997-10-31 -0.0099
1997-11-30 -0.0034
1997-12-31  0.0089
1998-01-31 -0.0036
1998-02-28  0.0256
1998-03-31  0.0373
1998-04-30  0.0125

<SNIP>

So the question, as of yet unanswered by me, is how to coerce the data
into that format. If we can then we will see if it works with dollar
data as opposed to the fractional stuff in the edhec file.

I'll be looking at this but don't expect much. I'm out in the deep end
at this point.

Cheers,
Mark

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gabor,  Thanks.

On Fri, Jul 3, 2009 at 8:25 PM, Gabor
Grothendieck<ggrothendieck@...> wrote:

> # 1. You can directly read your data into a zoo series like this:
>
> Lines <- "8190 2009-06-16 49.30
> 8191 2009-06-17 48.40
> 8192 2009-06-18 47.72
> 8193 2009-06-19 48.83
> 8194 2009-06-22 46.85
> 8195 2009-06-23 47.11
> 8196 2009-06-24 46.97
> 8197 2009-06-25 47.43"
>

OK.  Now I have to read up on zoo too.  I was going to get to that, as
I saw it mentioned in a couple views related to analyzing financial
data.

I apologize if this is a naive question, but if I am reading my data
successfully using:

thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
= FALSE, na.strings="")

can my "thedata" be used in the same way as your "Lines"?  Or would
that be a different function call?

What is your "Lines" anyway: a vector containing a series of strings?
a matrix of strings? one long string distributed over a series of
lines?

> library(zoo)
> z <- read.zoo(textConnection(Lines), index = 2)
>
> # and from that you can readily convert it to
> # other time series formats if need be.
>
> # 2. Read ?table.Drawdowns.  It asks for __returns__, not raw
> # data as input.
>
OOPS, so I'll need an extra step.  It is trivial to convert my data to
daily deltas.  I was more concerned at the moment with just getting my
time series data into a form the time series functions require.

Thank you.  This is quite useful.

Cheers

Ted

> library(PerformanceAnalytics)
> table.Drawdowns(diff(log(z$V3)))
>
> That gives me an error and looking into it it seems
> likely that table.Drawdowns fails when there is only one
> drawdown.
>
> library(help = PerformanceAnalytics)
>
> will give you the author's email address to whom you
> can report the problem.
>
> On Fri, Jul 3, 2009 at 7:34 PM, Ted Byers<r.ted.byers@...> wrote:
>> Hi Mark
>>
>> Thanks for replying.
>>
>> Here is a short snippet that reproduces the problem:
>>
>> library(PerformanceAnalytics)
>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>> = FALSE, na.strings="")
>> thedata
>> x = as.timeseries(thedata)
>> x
>> table.Drawdowns(thedata,top = 10)
>> table.Drawdowns(thedata$V2, top = 10)
>>
>> The object 'thedata' has exactly what I expected. the line 'thedata'
>> prints the correct contents of the file with each row prepended by a
>> line number.  The last few lines are:
>>
>> 8191 2009-06-17 48.40
>> 8192 2009-06-18 47.72
>> 8193 2009-06-19 48.83
>> 8194 2009-06-22 46.85
>> 8195 2009-06-23 47.11
>> 8196 2009-06-24 46.97
>> 8197 2009-06-25 47.43
>>
>> The number of lines (8197), dates (and their format) and prices are correct.
>>
>> The last four lines produce the following output:
>>> x = as.timeseries(thedata)
>> Error: could not find function "as.timeseries"
>>> x
>> Error: object 'x' not found
>>> table.Drawdowns(thedata,top = 10)
>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>> table.Drawdowns(thedata$V2, top = 10)
>> Error in if (thisSign == priorSign) { :
>>  missing value where TRUE/FALSE needed
>>>
>>
>> Are the functions in your example in Rmetrics or PerformanceAnalytics?
>> (like I said, I am just beginning this exploration, and I started with
>> table.Drawdowns because it produces information that I need first)
>> And given that my data is in tab delimited files, and can be read
>> using read.csv, how do I feed my data into your four statements?
>>
>> My guess is I am missing something in coercing my data in (the data
>> frame?) thedata into a timeseries array of the sort the time series
>> analysis functions need: and one of the things I find a bit confusing
>> is that some of the documentation for this mentions S3 classes and
>> some mentions S4 classes (I don't know if that means I have to make
>> multiple copies of my data to get the output I need).  I could coerce
>> thedata$V2 into a numeric vector, but I'd rather not separate the
>> prices from their dates unless that is necessary (how would one
>> produce monthly, annual or annualized rates of return if one did
>> that?).
>>
>> Thanks
>>
>> Ted
>>
>> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:
>>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>>>> I have hundreds of megabytes of price data time series, and perl
>>>> scripts that extract it to tab delimited files (I have C++ programs
>>>> that must analyse this data too, so I get Perl to extract it rather
>>>> than have multiple connections to the DB).
>>>>
>>>> I can read the data into an R object without any problems.
>>>>
>>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>>>> = FALSE, na.strings="")
>>>> thedata
>>>>
>>>> The above statements give me precisely what I expect.  The last few
>>>> lines of output are:
>>>> 8190 2009-06-16 49.30
>>>> 8191 2009-06-17 48.40
>>>> 8192 2009-06-18 47.72
>>>> 8193 2009-06-19 48.83
>>>> 8194 2009-06-22 46.85
>>>> 8195 2009-06-23 47.11
>>>> 8196 2009-06-24 46.97
>>>> 8197 2009-06-25 47.43
>>>>
>>>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>>>> I tried as.ts(thedata), but that only replaces the date field by the
>>>> row label in 'thedata'.
>>>>
>>>> If I apply the performance analytics drawdowns function to either
>>>> thedata or thedate$V2, I get errors:
>>>>> table.Drawdowns(thedata,top = 10)
>>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>>> table.Drawdowns(thedata$V2, top = 10)
>>>> Error in if (thisSign == priorSign) { :
>>>>  missing value where TRUE/FALSE needed
>>>>>
>>>>
>>>> thedata$V2 by itself does give me the price data from the file.
>>>>
>>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>>> surprised it I missed something that would be obvious to someone more
>>>> practiced in using R, but I don't see what that could be from the
>>>> documentation of the functions I am looking at using.  I have no
>>>> shortage of data, and I don't want to write C++ code, or perl code, to
>>>> do all the kinds of calculations provided in, Rmetrics and
>>>> performanceanalytics, but getting my data into the functions these
>>>> packages provide is killing me!
>>>>
>>>> What did I miss?
>>>>
>>>> Thanks
>>>>
>>>> Ted
>>>>
>>>> ______________________________________________
>>>> R-help@... 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.
>>>>
>>>
>>> Could you supply some portion of the results when you run the example
>>> on your data? The example goes like:
>>>
>>> data(edhec)
>>> R=edhec[,"Funds.of.Funds"]
>>> findDrawdowns(R)
>>> sortDrawdowns(findDrawdowns(R))
>>>
>>> How are you using the function with your data?
>>>
>>> - Mark
>>>
>>
>> ______________________________________________
>> R-help@... 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.
>>
>

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mark,

Thanks.

Your example works fine.  But I see you're struggling with the same
issue that I am.  I also see the format of the dates in the dataset
you use in your example is the same format that my dates are in.

I just read it, so I haven't had a chance to investigate, but you
might take a look at Gabor's response to me to see if read.zoo can
help move data from a file (or whatever is returned by read.csv) into
a zoo series.

Cheers,

Ted

On Fri, Jul 3, 2009 at 8:40 PM, Mark Knecht<markknecht@...> wrote:

> On Fri, Jul 3, 2009 at 4:34 PM, Ted Byers<r.ted.byers@...> wrote:
>> Hi Mark
>>
>> Thanks for replying.
>>
>> Here is a short snippet that reproduces the problem:
>>
>> library(PerformanceAnalytics)
>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>> = FALSE, na.strings="")
>> thedata
>> x = as.timeseries(thedata)
>> x
>> table.Drawdowns(thedata,top = 10)
>> table.Drawdowns(thedata$V2, top = 10)
>>
>> The object 'thedata' has exactly what I expected. the line 'thedata'
>> prints the correct contents of the file with each row prepended by a
>> line number.  The last few lines are:
>>
>> 8191 2009-06-17 48.40
>> 8192 2009-06-18 47.72
>> 8193 2009-06-19 48.83
>> 8194 2009-06-22 46.85
>> 8195 2009-06-23 47.11
>> 8196 2009-06-24 46.97
>> 8197 2009-06-25 47.43
>>
>> The number of lines (8197), dates (and their format) and prices are correct.
>>
>> The last four lines produce the following output:
>>> x = as.timeseries(thedata)
>> Error: could not find function "as.timeseries"
>>> x
>> Error: object 'x' not found
>>> table.Drawdowns(thedata,top = 10)
>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>> table.Drawdowns(thedata$V2, top = 10)
>> Error in if (thisSign == priorSign) { :
>>  missing value where TRUE/FALSE needed
>>>
>>
>> Are the functions in your example in Rmetrics or PerformanceAnalytics?
>> (like I said, I am just beginning this exploration, and I started with
>> table.Drawdowns because it produces information that I need first)
>> And given that my data is in tab delimited files, and can be read
>> using read.csv, how do I feed my data into your four statements?
>>
>> My guess is I am missing something in coercing my data in (the data
>> frame?) thedata into a timeseries array of the sort the time series
>> analysis functions need: and one of the things I find a bit confusing
>> is that some of the documentation for this mentions S3 classes and
>> some mentions S4 classes (I don't know if that means I have to make
>> multiple copies of my data to get the output I need).  I could coerce
>> thedata$V2 into a numeric vector, but I'd rather not separate the
>> prices from their dates unless that is necessary (how would one
>> produce monthly, annual or annualized rates of return if one did
>> that?).
>>
>> Thanks
>>
>> Ted
>>
>> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:
>>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>>>> I have hundreds of megabytes of price data time series, and perl
>>>> scripts that extract it to tab delimited files (I have C++ programs
>>>> that must analyse this data too, so I get Perl to extract it rather
>>>> than have multiple connections to the DB).
>>>>
>>>> I can read the data into an R object without any problems.
>>>>
>>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>>>> = FALSE, na.strings="")
>>>> thedata
>>>>
>>>> The above statements give me precisely what I expect.  The last few
>>>> lines of output are:
>>>> 8190 2009-06-16 49.30
>>>> 8191 2009-06-17 48.40
>>>> 8192 2009-06-18 47.72
>>>> 8193 2009-06-19 48.83
>>>> 8194 2009-06-22 46.85
>>>> 8195 2009-06-23 47.11
>>>> 8196 2009-06-24 46.97
>>>> 8197 2009-06-25 47.43
>>>>
>>>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>>>> I tried as.ts(thedata), but that only replaces the date field by the
>>>> row label in 'thedata'.
>>>>
>>>> If I apply the performance analytics drawdowns function to either
>>>> thedata or thedate$V2, I get errors:
>>>>> table.Drawdowns(thedata,top = 10)
>>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>>> table.Drawdowns(thedata$V2, top = 10)
>>>> Error in if (thisSign == priorSign) { :
>>>>  missing value where TRUE/FALSE needed
>>>>>
>>>>
>>>> thedata$V2 by itself does give me the price data from the file.
>>>>
>>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>>> surprised it I missed something that would be obvious to someone more
>>>> practiced in using R, but I don't see what that could be from the
>>>> documentation of the functions I am looking at using.  I have no
>>>> shortage of data, and I don't want to write C++ code, or perl code, to
>>>> do all the kinds of calculations provided in, Rmetrics and
>>>> performanceanalytics, but getting my data into the functions these
>>>> packages provide is killing me!
>>>>
>>>> What did I miss?
>>>>
>>>> Thanks
>>>>
>>>> Ted
>>>>
>>>> ______________________________________________
>>>> R-help@... 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.
>>>>
>>>
>>> Could you supply some portion of the results when you run the example
>>> on your data? The example goes like:
>>>
>>> data(edhec)
>>> R=edhec[,"Funds.of.Funds"]
>>> findDrawdowns(R)
>>> sortDrawdowns(findDrawdowns(R))
>>>
>>> How are you using the function with your data?
>>>
>>> - Mark
>>>
>>
>
> Sorry, findDrawdowns is part of PerformanceAnalytics. I've added that
> to this code so you can just copy it and run it all.
>
> require(PerformanceAnalytics)
> data(edhec)
> class(edhec)
> R=edhec[,"Funds.of.Funds"]
> class(R)
> findDrawdowns(R)
> sortDrawdowns(findDrawdowns(R))
>
> This is a subject that interests me. My data is read in using read.csv
> which I think may provide similar problems should I ever want to use
> this so I'm interested in how I solve it. I'm a newbie so be VERY
> careful about anything I say!
>
> What I see is that edhec is of class zoo, as is R. Here's what I did to check:
>
>> require(PerformanceAnalytics)
>> data(edhec)
>> class(edhec)
> [1] "zoo"
>> R=edhec[,"Funds.of.Funds"]
>
>
>
>> class(R)
> [1] "zoo"
>> findDrawdowns(R)
> <SNIP>
>
>> sortDrawdowns(findDrawdowns(R))
> <SNIP>
>
>
> Note that R, class zoo, has dates as the names and then a single column of data:
>
>>
>> R
> Jan 1997 Feb 1997 Mar 1997 Apr 1997 May 1997 Jun 1997 Jul 1997 Aug
> 1997 Sep 1997 Oct 1997 Nov 1997 Dec 1997 Jan 1998 Feb 1998 Mar 1998
> Apr 1998
>  0.0317   0.0106  -0.0077   0.0009   0.0275   0.0225   0.0435
> 0.0051   0.0334  -0.0099  -0.0034   0.0089  -0.0036   0.0256   0.0373
>  0.0125
> May 1998 Jun 1998 Jul 1998 Aug 1998 Sep 1998 Oct 1998 Nov 1998 Dec
> 1998 Jan 1999 Feb 1999 Mar 1999 Apr 1999 May 1999 Jun 1999 Jul 1999
> Aug 1999
>  -0.0072   0.0021  -0.0007  -0.0616  -0.0037  -0.0002   0.0220
> 0.0222   0.0202  -0.0063   0.0213   0.0400   0.0119   0.0282   0.0088
>  0.0028
> <SNIP>
>>
>
>> names(R)
>  [1] "1997-01-31" "1997-02-28" "1997-03-31" "1997-04-30" "1997-05-31"
> "1997-06-30" "1997-07-31" "1997-08-31" "1997-09-30" "1997-10-31"
>  [11] "1997-11-30" "1997-12-31" "1998-01-31" "1998-02-28" "1998-03-31"
> "1998-04-30" "1998-05-31" "1998-06-30" "1998-07-31" "1998-08-31"
>  [21] "1998-09-30" "1998-10-31" "1998-11-30" "1998-12-31" "1999-01-31"
> "1999-02-28" "1999-03-31" "1999-04-30" "1999-05-31" "1999-06-30"
> <SNIP>
>
>> as.matrix(R)
>                 R
> 1997-01-31  0.0317
> 1997-02-28  0.0106
> 1997-03-31 -0.0077
> 1997-04-30  0.0009
> 1997-05-31  0.0275
> 1997-06-30  0.0225
> 1997-07-31  0.0435
> 1997-08-31  0.0051
> 1997-09-30  0.0334
> 1997-10-31 -0.0099
> 1997-11-30 -0.0034
> 1997-12-31  0.0089
> 1998-01-31 -0.0036
> 1998-02-28  0.0256
> 1998-03-31  0.0373
> 1998-04-30  0.0125
>
> <SNIP>
>
> So the question, as of yet unanswered by me, is how to coerce the data
> into that format. If we can then we will see if it works with dollar
> data as opposed to the fractional stuff in the edhec file.
>
> I'll be looking at this but don't expect much. I'm out in the deep end
> at this point.
>
> Cheers,
> Mark
>

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, I should have read the read.zoo documentation before replying
to thank Gabor for his repsonse.

Here is how it starts:

"read.zoo(zoo) R Documentation

Reading and Writing zoo Series
Description
read.zoo and write.zoo are convenience functions for reading and
writing "zoo" series from/to text files. They are convenience
interfaces to read.table and write.table, respectively.

Usage
read.zoo(file, format = "", tz = "", FUN = NULL,
  regular = FALSE, index.column = 1, aggregate = FALSE, ...)"

Clearly this should solve both our problems.

Cheers,

Ted

On Fri, Jul 3, 2009 at 8:40 PM, Mark Knecht<markknecht@...> wrote:

> On Fri, Jul 3, 2009 at 4:34 PM, Ted Byers<r.ted.byers@...> wrote:
>> Hi Mark
>>
>> Thanks for replying.
>>
>> Here is a short snippet that reproduces the problem:
>>
>> library(PerformanceAnalytics)
>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>> = FALSE, na.strings="")
>> thedata
>> x = as.timeseries(thedata)
>> x
>> table.Drawdowns(thedata,top = 10)
>> table.Drawdowns(thedata$V2, top = 10)
>>
>> The object 'thedata' has exactly what I expected. the line 'thedata'
>> prints the correct contents of the file with each row prepended by a
>> line number.  The last few lines are:
>>
>> 8191 2009-06-17 48.40
>> 8192 2009-06-18 47.72
>> 8193 2009-06-19 48.83
>> 8194 2009-06-22 46.85
>> 8195 2009-06-23 47.11
>> 8196 2009-06-24 46.97
>> 8197 2009-06-25 47.43
>>
>> The number of lines (8197), dates (and their format) and prices are correct.
>>
>> The last four lines produce the following output:
>>> x = as.timeseries(thedata)
>> Error: could not find function "as.timeseries"
>>> x
>> Error: object 'x' not found
>>> table.Drawdowns(thedata,top = 10)
>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>> table.Drawdowns(thedata$V2, top = 10)
>> Error in if (thisSign == priorSign) { :
>>  missing value where TRUE/FALSE needed
>>>
>>
>> Are the functions in your example in Rmetrics or PerformanceAnalytics?
>> (like I said, I am just beginning this exploration, and I started with
>> table.Drawdowns because it produces information that I need first)
>> And given that my data is in tab delimited files, and can be read
>> using read.csv, how do I feed my data into your four statements?
>>
>> My guess is I am missing something in coercing my data in (the data
>> frame?) thedata into a timeseries array of the sort the time series
>> analysis functions need: and one of the things I find a bit confusing
>> is that some of the documentation for this mentions S3 classes and
>> some mentions S4 classes (I don't know if that means I have to make
>> multiple copies of my data to get the output I need).  I could coerce
>> thedata$V2 into a numeric vector, but I'd rather not separate the
>> prices from their dates unless that is necessary (how would one
>> produce monthly, annual or annualized rates of return if one did
>> that?).
>>
>> Thanks
>>
>> Ted
>>
>> On Fri, Jul 3, 2009 at 6:39 PM, Mark Knecht<markknecht@...> wrote:
>>> On Fri, Jul 3, 2009 at 2:48 PM, Ted Byers<r.ted.byers@...> wrote:
>>>> I have hundreds of megabytes of price data time series, and perl
>>>> scripts that extract it to tab delimited files (I have C++ programs
>>>> that must analyse this data too, so I get Perl to extract it rather
>>>> than have multiple connections to the DB).
>>>>
>>>> I can read the data into an R object without any problems.
>>>>
>>>> thedata = read.csv("K:\\Work\\SignalTest\\BP.csv", sep = "\t", header
>>>> = FALSE, na.strings="")
>>>> thedata
>>>>
>>>> The above statements give me precisely what I expect.  The last few
>>>> lines of output are:
>>>> 8190 2009-06-16 49.30
>>>> 8191 2009-06-17 48.40
>>>> 8192 2009-06-18 47.72
>>>> 8193 2009-06-19 48.83
>>>> 8194 2009-06-22 46.85
>>>> 8195 2009-06-23 47.11
>>>> 8196 2009-06-24 46.97
>>>> 8197 2009-06-25 47.43
>>>>
>>>> I have loaded Rmetrics and PerformanceAnalytics, among other packages.
>>>>  I tried as.timeseries, but R2.9.1 tells me there is no such function.
>>>> I tried as.ts(thedata), but that only replaces the date field by the
>>>> row label in 'thedata'.
>>>>
>>>> If I apply the performance analytics drawdowns function to either
>>>> thedata or thedate$V2, I get errors:
>>>>> table.Drawdowns(thedata,top = 10)
>>>> Error in 1 + na.omit(x) : non-numeric argument to binary operator
>>>>> table.Drawdowns(thedata$V2, top = 10)
>>>> Error in if (thisSign == priorSign) { :
>>>>  missing value where TRUE/FALSE needed
>>>>>
>>>>
>>>> thedata$V2 by itself does give me the price data from the file.
>>>>
>>>> I am a relative novice in using R for timeseries, so I wouldn't be
>>>> surprised it I missed something that would be obvious to someone more
>>>> practiced in using R, but I don't see what that could be from the
>>>> documentation of the functions I am looking at using.  I have no
>>>> shortage of data, and I don't want to write C++ code, or perl code, to
>>>> do all the kinds of calculations provided in, Rmetrics and
>>>> performanceanalytics, but getting my data into the functions these
>>>> packages provide is killing me!
>>>>
>>>> What did I miss?
>>>>
>>>> Thanks
>>>>
>>>> Ted
>>>>
>>>> ______________________________________________
>>>> R-help@... 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.
>>>>
>>>
>>> Could you supply some portion of the results when you run the example
>>> on your data? The example goes like:
>>>
>>> data(edhec)
>>> R=edhec[,"Funds.of.Funds"]
>>> findDrawdowns(R)
>>> sortDrawdowns(findDrawdowns(R))
>>>
>>> How are you using the function with your data?
>>>
>>> - Mark
>>>
>>
>
> Sorry, findDrawdowns is part of PerformanceAnalytics. I've added that
> to this code so you can just copy it and run it all.
>
> require(PerformanceAnalytics)
> data(edhec)
> class(edhec)
> R=edhec[,"Funds.of.Funds"]
> class(R)
> findDrawdowns(R)
> sortDrawdowns(findDrawdowns(R))
>
> This is a subject that interests me. My data is read in using read.csv
> which I think may provide similar problems should I ever want to use
> this so I'm interested in how I solve it. I'm a newbie so be VERY
> careful about anything I say!
>
> What I see is that edhec is of class zoo, as is R. Here's what I did to check:
>
>> require(PerformanceAnalytics)
>> data(edhec)
>> class(edhec)
> [1] "zoo"
>> R=edhec[,"Funds.of.Funds"]
>
>
>
>> class(R)
> [1] "zoo"
>> findDrawdowns(R)
> <SNIP>
>
>> sortDrawdowns(findDrawdowns(R))
> <SNIP>
>
>
> Note that R, class zoo, has dates as the names and then a single column of data:
>
>>
>> R
> Jan 1997 Feb 1997 Mar 1997 Apr 1997 May 1997 Jun 1997 Jul 1997 Aug
> 1997 Sep 1997 Oct 1997 Nov 1997 Dec 1997 Jan 1998 Feb 1998 Mar 1998
> Apr 1998
>  0.0317   0.0106  -0.0077   0.0009   0.0275   0.0225   0.0435
> 0.0051   0.0334  -0.0099  -0.0034   0.0089  -0.0036   0.0256   0.0373
>  0.0125
> May 1998 Jun 1998 Jul 1998 Aug 1998 Sep 1998 Oct 1998 Nov 1998 Dec
> 1998 Jan 1999 Feb 1999 Mar 1999 Apr 1999 May 1999 Jun 1999 Jul 1999
> Aug 1999
>  -0.0072   0.0021  -0.0007  -0.0616  -0.0037  -0.0002   0.0220
> 0.0222   0.0202  -0.0063   0.0213   0.0400   0.0119   0.0282   0.0088
>  0.0028
> <SNIP>
>>
>
>> names(R)
>  [1] "1997-01-31" "1997-02-28" "1997-03-31" "1997-04-30" "1997-05-31"
> "1997-06-30" "1997-07-31" "1997-08-31" "1997-09-30" "1997-10-31"
>  [11] "1997-11-30" "1997-12-31" "1998-01-31" "1998-02-28" "1998-03-31"
> "1998-04-30" "1998-05-31" "1998-06-30" "1998-07-31" "1998-08-31"
>  [21] "1998-09-30" "1998-10-31" "1998-11-30" "1998-12-31" "1999-01-31"
> "1999-02-28" "1999-03-31" "1999-04-30" "1999-05-31" "1999-06-30"
> <SNIP>
>
>> as.matrix(R)
>                 R
> 1997-01-31  0.0317
> 1997-02-28  0.0106
> 1997-03-31 -0.0077
> 1997-04-30  0.0009
> 1997-05-31  0.0275
> 1997-06-30  0.0225
> 1997-07-31  0.0435
> 1997-08-31  0.0051
> 1997-09-30  0.0334
> 1997-10-31 -0.0099
> 1997-11-30 -0.0034
> 1997-12-31  0.0089
> 1998-01-31 -0.0036
> 1998-02-28  0.0256
> 1998-03-31  0.0373
> 1998-04-30  0.0125
>
> <SNIP>
>
> So the question, as of yet unanswered by me, is how to coerce the data
> into that format. If we can then we will see if it works with dollar
> data as opposed to the fractional stuff in the edhec file.
>
> I'll be looking at this but don't expect much. I'm out in the deep end
> at this point.
>
> Cheers,
> Mark
>

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Mark Knecht :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 5:54 PM, Ted Byers<r.ted.byers@...> wrote:

> Sorry, I should have read the read.zoo documentation before replying
> to thank Gabor for his repsonse.
>
> Here is how it starts:
>
> "read.zoo(zoo) R Documentation
>
> Reading and Writing zoo Series
> Description
> read.zoo and write.zoo are convenience functions for reading and
> writing "zoo" series from/to text files. They are convenience
> interfaces to read.table and write.table, respectively.
>
> Usage
> read.zoo(file, format = "", tz = "", FUN = NULL,
>  regular = FALSE, index.column = 1, aggregate = FALSE, ...)"
>
> Clearly this should solve both our problems.
>
> Cheers,
>
> Ted
>

Possibly but I think the big issue is the findDrawdowns function is
looking for minus signs to signal the drawdown. I down think it's
doing calculations from a simple equity curve.

All of these functions (findDrawdowns, table.Drawdowns, etc.) all say
they will accept a data.frame.

My guess is the issue isn't so much dates, names, or anything else as
much as making sure you have a column of percentage rise and fall
numbers expressed like

0.03
0.02
-0.025
0.10

Even findDrawdowns(edhec[,5]) does the right thing. Copying it to R
wasn't necessary. edhec has lots of columns. You can pick and one of
them and get a table.

- Mark

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 9:05 PM, Mark Knecht<markknecht@...> wrote:

> On Fri, Jul 3, 2009 at 5:54 PM, Ted Byers<r.ted.byers@...> wrote:
>> Sorry, I should have read the read.zoo documentation before replying
>> to thank Gabor for his repsonse.
>>
>> Here is how it starts:
>>
>> "read.zoo(zoo) R Documentation
>>
>> Reading and Writing zoo Series
>> Description
>> read.zoo and write.zoo are convenience functions for reading and
>> writing "zoo" series from/to text files. They are convenience
>> interfaces to read.table and write.table, respectively.
>>
>> Usage
>> read.zoo(file, format = "", tz = "", FUN = NULL,
>>  regular = FALSE, index.column = 1, aggregate = FALSE, ...)"
>>
>> Clearly this should solve both our problems.
>>
>> Cheers,
>>
>> Ted
>>
>
> Possibly but I think the big issue is the findDrawdowns function is
> looking for minus signs to signal the drawdown. I down think it's
> doing calculations from a simple equity curve.
>
> All of these functions (findDrawdowns, table.Drawdowns, etc.) all say
> they will accept a data.frame.
>
> My guess is the issue isn't so much dates, names, or anything else as
> much as making sure you have a column of percentage rise and fall
> numbers expressed like
>
> 0.03
> 0.02
> -0.025
> 0.10
>
But this is trivial.  I have to read the documentation further to see
if it wants rates of return as a fraction (or percentages), or if
daily deltas will do.  Either way, it is trivial to get such numbers
(in my case in the perl script I use to draw the data from my
database.

> Even findDrawdowns(edhec[,5]) does the right thing. Copying it to R
> wasn't necessary. edhec has lots of columns. You can pick and one of
> them and get a table.
>
This is good to know as it makes some of the analyses I need to do
easier.  I can create a single file with a number of series that need
to be compared WRT drawdowns, VaR, &c.

Cheers,

Ted

______________________________________________
R-help@... 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.

Re: The time series analysis functions/packages don't seem to like my data

by Mark Knecht :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jul 3, 2009 at 6:32 PM, Ted Byers<r.ted.byers@...> wrote:

> On Fri, Jul 3, 2009 at 9:05 PM, Mark Knecht<markknecht@...> wrote:
>> On Fri, Jul 3, 2009 at 5:54 PM, Ted Byers<r.ted.byers@...> wrote:
>>> Sorry, I should have read the read.zoo documentation before replying
>>> to thank Gabor for his repsonse.
>>>
>>> Here is how it starts:
>>>
>>> "read.zoo(zoo) R Documentation
>>>
>>> Reading and Writing zoo Series
>>> Description
>>> read.zoo and write.zoo are convenience functions for reading and
>>> writing "zoo" series from/to text files. They are convenience
>>> interfaces to read.table and write.table, respectively.
>>>
>>> Usage
>>> read.zoo(file, format = "", tz = "", FUN = NULL,
>>>  regular = FALSE, index.column = 1, aggregate = FALSE, ...)"
>>>
>>> Clearly this should solve both our problems.
>>>
>>> Cheers,
>>>
>>> Ted
>>>
>>
>> Possibly but I think the big issue is the findDrawdowns function is
>> looking for minus signs to signal the drawdown. I down think it's
>> doing calculations from a simple equity curve.
>>
>> All of these functions (findDrawdowns, table.Drawdowns, etc.) all say
>> they will accept a data.frame.
>>
>> My guess is the issue isn't so much dates, names, or anything else as
>> much as making sure you have a column of percentage rise and fall
>> numbers expressed like
>>
>> 0.03
>> 0.02
>> -0.025
>> 0.10
>>
> But this is trivial.  I have to read the documentation further to see
> if it wants rates of return as a fraction (or percentages), or if
> daily deltas will do.  Either way, it is trivial to get such numbers
> (in my case in the perl script I use to draw the data from my
> database.
>
>> Even findDrawdowns(edhec[,5]) does the right thing. Copying it to R
>> wasn't necessary. edhec has lots of columns. You can pick and one of
>> them and get a table.
>>
> This is good to know as it makes some of the analyses I need to do
> easier.  I can create a single file with a number of series that need
> to be compared WRT drawdowns, VaR, &c.
>
> Cheers,
>
> Ted
>

You don't have to put it in your data/frame if you don't want. you can
jsut create a variable, write the data into it and send it to the
function. The function won't care. (I don't think...) After all, R
wasn't in edhec.

______________________________________________
R-help@... 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.