I am running an expt that presents a point process input x and measures a point process output y. The times of each event are recorded. The lengths of the data records of x and y are necessarily different, and can be different by a factor of 10. I would like to save these data after each experiment as a file with two columns, one for x and one for y. However, R dataframes require columns of equal length. One solution is to fill the "empty" places in y with NAs so it has the same length as x. I view that as unsatisfactory (there are in reality no missing values). Another possibility is to store x and y in separate files. I also view that as unsatisfactory (it is too easy to lose track of the y file corresponding to a given x file). Can anyone suggest a way to deal with this situation? Thanks very much for any help. Bill
On 10/23/2009 07:58 PM, William Simpson wrote:> I am running an expt that presents a point process input x and > measures a point process output y. The times of each event are > recorded. The lengths of the data records of x and y are necessarily > different, and can be different by a factor of 10. I would like to > save these data after each experiment as a file with two columns, one > for x and one for y. > > However, R dataframes require columns of equal length. One solution is > to fill the "empty" places in y with NAs so it has the same length as > x. I view that as unsatisfactory (there are in reality no missing > values). Another possibility is to store x and y in separate files. I > also view that as unsatisfactory (it is too easy to lose track of the > y file corresponding to a given x file). > > Can anyone suggest a way to deal with this situation? > >Hi Bill, xy<-list(x=1:10,y=1:100) Note that this cheerfully ignores how you are going to figure out which x goes with which y(s). Jim
The way you do it is to compute the cross-intensity function (you can google this; a key name is David Brillinger). The general problem is that of system identification for point processes. Bill On Fri, Oct 23, 2009 at 10:31 AM, Jim Lemon <jim at bitwrit.com.au> wrote:> On 10/23/2009 07:58 PM, William Simpson wrote: >> >> I am running an expt that presents a point process input x and >> measures a point process output y. The times of each event are >> recorded. The lengths of the data records of x and y are necessarily >> different, and can be different by a factor of 10. I would like to >> save these data after each experiment as a file with two columns, one >> for x and one for y. >> >> However, R dataframes require columns of equal length. One solution is >> to fill the "empty" places in y with NAs so it has the same length as >> x. I view that as unsatisfactory (there are in reality no missing >> values). Another possibility is to store x and y in separate files. I >> also view that as unsatisfactory (it is too easy to lose track of the >> y file corresponding to a given x file). >> >> Can anyone suggest a way to deal with this situation? >> >> > > Hi Bill, > > xy<-list(x=1:10,y=1:100) > > Note that this cheerfully ignores how you are going to figure out which x > goes with which y(s). > > Jim > >
Thanks Jim. BTW the times in x and y are in ascending order (time of occurrence). If I do it this way, how do I actually read the data in and store in the file? Toy code, please. Bill> > Hi Bill, > > xy<-list(x=1:10,y=1:100) > > Note that this cheerfully ignores how you are going to figure out which x > goes with which y(s). > > Jim >
On 10/23/2009 10:07 PM, William Simpson wrote:> Thanks Jim. BTW the times in x and y are in ascending order (time of > occurrence). > > If I do it this way, how do I actually read the data in and store in > the file? Toy code, please. > >Hi Bill, This seems a bit like some heartbeat data that I had to deal with some years ago. There were two output streams, one the time of each R wave and the other an asynchronous stimulus. In that case, I had to work out code to interdigitate the signals and do some processing of the resulting data. It sounds like you have two files, each recording times of input and output respectively one value to a line. If so, my first guess is: x<-as.vector(read.table("input_times.dat")) y<-as.vector(read.table("output_times.dat")) xy<-list(x,y) # to store this list in a file write.csv(xy,file="xy_23_10_2009.csv") Jim
On 10/23/2009 10:07 PM, William Simpson wrote:> Thanks Jim. BTW the times in x and y are in ascending order (time of > occurrence). > > If I do it this way, how do I actually read the data in and store in > the file? Toy code, please. > >Hi Bill, This seems a bit like some heartbeat data that I had to deal with some years ago. There were two output streams, one the time of each R wave and the other an asynchronous stimulus. In that case, I had to work out code to interdigitate the signals and do some processing of the resulting data. It sounds like you have two files, each recording times of input and output respectively one value to a line. If so, my first guess is: x<-as.vector(read.table("input_times.dat")) y<-as.vector(read.table("output_times.dat")) xy<-list(x,y) # to store this list in a file # oops, bit too quick on the keyboard dput(xy,file="xy_23_10_2009.R") Jim