Displaying 2 results from an estimated 2 matches for "my_corr".
Did you mean:
max_corr
2008 Feb 22
1
efficient writing of calculation involving each element of 2 data frames.
...double precision number. Let
the column names be V1, V2.
Now I want to calculate the correlation of the 2 sets of data, for the last
100 days for every day available in the data.frames.
My code looks like this :
# Let df1, and df2 be the 2 data frames with the required data
## begin code snippet
my_corr <- c();
for ( i_end in 100:nrow(df1)) {
i_start <- i_end - 99;
my_corr[i_start] <-
cor(x=df1[i_start:i_end,"V2"],y=df2[i_start:i_end,"V2"])
}
## end of code snippet
This runs very slowly, and takes more than an hour to run if I have to
calculate correla...
2008 Feb 22
2
Corrected : Efficient writing of calculation involving each element of 2 data frames
...double precision number. Let
the column names be V1, V2.
Now I want to calculate the correlation of the 2 sets of data, for the last
100 days for every day available in the data.frames.
My code looks like this :
# Let df1, and df2 be the 2 data frames with the required data
## begin code snippet
my_corr <- c();
for ( i_start in 100:nrow(df1))
my_corr[i_start-99] <-
cor(x=df1[(i_start-99):i_start,"V2"],y=df2[(i_start-99):i_start,"V2"])
## end of code snippet
This runs very slowly, and takes more than an hour to run if I have to
calculate correlation between 10 data...