correlation

How to efficiently find correlation and discard points outside 3-sigma range in MATLAB?

I have a data file m.txt that looks something like this (with a lot more points): 286.842995 3.444398 3.707202 338.227797 3.597597 283.740414 3.514729 3.512116 3.744235 3.365461 3.384880 Some of the values (like 338.227797) are very different from the values I generally expect (smaller numbers). So, I am thinking that I will remove...

Cross-correlation coefficient

I have two waveforms in the time domain, of which I need to measure the cross-correlation coefficient in MATLAB. I have tried max(abs(xcorr(m,n,'coeff'))) but it doesn't seem to be working properly. Also I need to measure the cross correlation coefficient for different sections of the waveform, e.g. measure the cross correlation coeffic...

[R] GLM with autoregressive term to correct for serial correlation

Hi I have a stationary time series to which I want to fit a linear model with an autoregressive term to correct for serial correlation, i.e. using the formula At = c1*Bt + c2*Ct + ut, where ut = r*ut-1 + et (ut is an AR(1) term to correct for serial correlation in the error terms) Does anyone know what to use in R to model this? Than...

Ready implementation of multivariate Spearman rank correlation

I'm looking for a way to calculate multivariate version of Spearman rank correlation $\rho$. Are there any ready to use Python implementation I can use? ...

How to do: Correlation with "blocks" (or - "repeated measures" ?!) ?

Hello dear R people, I have the following setup to analyse: We have about 150 subjects, and for each subject we performed a pair of tests (under different conditions) 18 times. The 18 different conditions of the test are complementary, in such a way so that if we where to average over the tests (for each subject), we would get no correl...

WCF Workflow Service single instance correlation

Using visual studio 2010 RC/.Net 4.0 I have a wcf workflow service with three receive activities defined, basically StartProcessing, StopProcessing, and GetProcessingStatus. This is a long running service that continues to poll an external service for data once StartProcessing is called, until StopProcessing is called. My problem is wi...

Pearson correlation in PHP

I'm trying to implement the calculation of correlation coefficient of people between two sets of data in php. I'm just trying to do the porting python script that can be found at this url http://answers.oreilly.com/topic/1066-how-to-find-similar-users-with-python/ my implementation is the following: class LB_Similarity_PearsonCorrelati...

HT create a new vector in data frame that takes correlation of existing vectors

I have a time series of two indexes, with each row representing the closing price on the same day. I'd like to go to row 30 and lookback over the last 30 'days' and calculate the pearson correlation. And then store that value in a new vector. Then, repeat the calculation for the entire time series. It is a trivial task in Excel, so I'm...

using Excel VBA, given the daily price of 50 stocks, choose 10 stocks such that they have the minumum correlation

The high-level goal is to choose 10 stocks that have the lowest correlation among one another, out of a pool of 50, so that I can have a well-diversified portfolio. I have managed to write some VBA macro to download the past 3 years of daily price data from Yahoo finance, and then compute the 50x50 correlation matrix (using the Correl f...

Text-correlation in MySQL

Hi guys, I have three coloumns in my table, all containing text. I want to calculate a correlation between coloumn A and B, and A and C. How can I do this, and can I do it within MySQL? For example, I can have the values ('Hello world', 'ello world', 'Good bye'), ('Hello world', 'H e l l o', 'Bye world') Cheers Nik ...

Is there an image phase correlation library available for Python?

A project that involves image processing, i.e. to calculate the angular shift of the same image when shifted by a medium of certain Refractive Index. We have to build an app that correlates the 2 images (phase/2D correlation?) and then plot using Chaco and Mayavi (2 libraries in Python). Is there any other existing template software (FOS...

MySQL: Complex Join Statement involving two tables and a third correlation table

I have two tables that were built for two disparate systems. I have records in one table (called "leads") that represent customers, and records in another table (called "manager") that are the exact same customers but "manager" uses different fields (For example, "leads" contains an email address, and "manager" contains two fields fo...

Phase correlation

How can rotation angle be determined by phase correlation(using fft) of 2 images? The algorithm given in http://en.wikipedia.org/wiki/Phase_correlation returns linear shift, not angular. It also mentions images have to be converted to log-polar coordinates to compute rotation. How is this conversion achieved in python? And post conversio...

Eta/Eta-squared routines in R

Apart from graphical estimation of linearity (gaze-at-scatterplot method), which is utilized before applying some technique from GLM family, there are several ways to do this estimation arithmetically (i.e. without graphs). Right now, I'll focus on Fisher's eta-squared - correlation ratio: arithmetically, it's equal to squared Pearson's...

Calculating correlation coefficient using PostgreSQL?

I have worked out how to calculate the correlation coefficient between two fields if both are in the same table: SELECT corr(column1, column2) FROM table WHERE <my filters>; ...but I can't work out how to do it when the columns are from different tables (I need to apply the same filters to both tables). Any hints, please? ...

Alternative to distance metric in nearest neighbor algorithm?

Hi, I came across an implementation of the nearest neighbor algorithm for finding matches between certain keypoints in two similar images. The keypoints were generated by the SIFT algorithm. The points are described by a 128 dimension vector, and there are many such points in both images. The matching algorithm uses the nearest neighbor...

comparing Matlab vs CUDA correlation and reduction on a 2D array

I am trying to compare cross-correlation using FFT vs using windowing method. My Matlab code is: isize = 20; n = 7; for i = 1:n %%7x7 xcorr for j = 1:n xcout(i,j) = sum(sum(ffcorr1 .* ref(i:i+isize-1,j:j+isize-1))); %%ref is 676 element array and ffcorr1 is a 400 element array end end similar CUDA kernel: __global__ void xc_...

How can I extract peak values from auto-correlated data in MATLAB?

I have information (20,000 frames of data) about an audio track that I have auto-correlated using: [r,lags] = xcorr(XX,XX,'biased'); And it looks like this: Which hopefully is so far so good. Ideally I would like to be able to take the frame number that corresponds to the highest part of the second peak. I've read around and tried ...

Matlab: correlation number

I have a 2 vectors of numbers of either 1 or -1. What are the standard tools on Matlab that would help me calculate a correlation number between the two vectors? Thanks in advance! ...

R: How to calculate correlation - cor() - for only a subset of columns?

I have a dataframe and would like to calculate the correlation (with Spearman, data is categorical and ranked) but only for a subset of columns. I tried with all, but R's cor() function only accepts numerical data (x must be numeric, says the error message), even if Spearman is used. One brute approach is to delete the non-numerical col...