correlation

Power Spectrum and Autocorrelation of Data in Numpy

北城以北 提交于 2019-12-06 05:45:52
I am interested in computing the power spectrum of a system of particles (~100,000) in 3D space with Python. What I have found so far is a group of functions in Numpy ( fft , fftn ,..) which compute the discrete Fourier transform, of which the square of the absolute value is the power spectrum. My question is a matter of how my data are being represented - and truthfully may be fairly simple to answer. The data structure I have is an array which has a shape of ( n ,2), n being the number of particles I have, and each column representing either the x, y, and z coordinate of the n particles. The

Spatial Autocorrelation Analysis (Global Moran's I) in R

淺唱寂寞╮ 提交于 2019-12-06 04:59:43
问题 I have a list of points I want to check for autocorrelation using Moran's I and by dividing area of interest by 4 x 4 quadrats. Now every example I found on Google (e. g. http://www.ats.ucla.edu/stat/r/faq/morans_i.htm) uses some kind of measured value as the first input for the Moran's I function, no matter which library is used (I looked into the ape and spdep packages). However, all I have are the points themselves I want to check the correlation for. The problem is, as funny (or sad) as

Find the best lag from the numpy.correlate output

天大地大妈咪最大 提交于 2019-12-06 04:47:04
问题 I am using the following code to do auto-correlation on data_1 and data_2: result = numpy.correlate(data_1, data_2, mode='full') The result is also the time series. I also normalized result to result1: result1 = StandardScaler().fit_transform(result.astype('float32').reshape(-1, 1)) Then here is the plot, data_1 is black, data_2 is red, result1 is green: I know there is a lag between data_1 and data_2 , so I am wondering what's the best way to find the lag? Thanks! 回答1: numpy.correlate does

Correlation matrix with dplyr, tidyverse and broom - P-value matrix

ぃ、小莉子 提交于 2019-12-06 04:11:36
all. I want to obtain the p-value from a correlation matrix using dplyr and/or broom packages and testing multiple variables at the same time . I'm aware of other methods, but dplyr seems easier and more intuitive for me. In addition, dplyr will need to correlate each variable to obtain the specific p-value, what makes the process easier and faster. I checked other links, but they did not work for this question ( example 1 , example 2 , example 3 ) When I use this code, the correlation coefficients are reported. However, the P-values are not. agreg_base_tipo_a %>% dplyr::select(S2.RT, BIS

how to place colorlegend (corrplot) in graphic

依然范特西╮ 提交于 2019-12-06 03:49:20
I am using corrplot to create a correlation heatmap, but I don't like the default legend - it is too big. So I was trying to use the colorlegend() to add the legend after I create the plot (and disable the default legend with cl.pos="n" ). Only problem is that I can't figure out how to change the position of the legend - it ends up on the lower left. Ideally, I could place it on the top right, but I looked through the options for colorlegend and plot and can't figure this out. For example: # load libraries and create color scale library(corrplot) library(RColorBrewer) scalebluered <-

Row-wise cor() on subset of columns using dplyr::mutate()

孤人 提交于 2019-12-06 01:21:43
set.seed(8) df <- data.frame( A=sample(c(1:3), 10, replace=T), B=sample(c(1:3), 10, replace=T), C=sample(c(1:3), 10, replace=T), D=sample(c(1:3), 10, replace=T), E=sample(c(1:3), 10, replace=T), F=sample(c(1:3), 10, replace=T)) Would like to pass a subset of columns into a dplyr mutate() and make a row-wise calculation, for instance cor() to get correlation between column A-C and D-F, but cannot figure out how. Found SO inspiration here , here and here , but nevertheless failed to produce an acceptable code. For instance, I tried this: require(plyr) require(dplyr) df %>% rowwise() %>% mutate(c

Easily input a correlation matrix in R

谁说我不能喝 提交于 2019-12-06 00:10:43
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 7 years ago . I have a R script I'm running now that is currently using 3 correlated variables. I'd like to add a 4th, and am wondering if there's a simple way to input matrix data, particularly for correlation matrices---some Matlab-like technique to enter a correlation matrix, 3x3 or 4x4, in R without the linear to matrix reshape I've been using. In Matlab, you can use the semicolon as an

Cannonical Correlation Analysis

≡放荡痞女 提交于 2019-12-06 00:02:55
I have just started working using CCA in Matlab. I have two vectors X and Y of dimension 60x1920 and 60x1536 with the number of samples being 60 and variables in the different set of vectors being 1920 and 1536 respectively. I want to know do CCA for reducing them to the subspace and then do feature matching. I am using this commands. %% DO CCA [A,B,r,U,V] = canoncorr(X,Y); The output I get is this : Name Size Bytes Class Attributes A 1920x58 890880 double B 1536x58 712704 double U 60x58 27840 double V 60x58 27840 double r 1x58 464 double Can anyone please tell me what these variables mean. I

Time series - correlation and lag time

被刻印的时光 ゝ 提交于 2019-12-05 22:37:25
I am studying the correlation between a set of input variables and a response variable, price. These are all in time series. 1) Is it necessary that I smooth out the curve where the input variable is cyclical (autoregressive)? If so, how? 2) Once a correlation is established, I would like to quantify exactly how the input variable affects the response variable. Eg: "Once X increases >10% then there is an 2% increase in y 6 months later." Which python libraries should I be looking at to implement this - in particular to figure out the lag time between two correlated occurrences ? Example: I

Bayesian Correlation with PyMC3

一笑奈何 提交于 2019-12-05 21:45:04
I'm trying to convert this example of Bayesian correlation for PyMC2 to PyMC3, but get completely different results. Most importantly, the mean of the multivariate Normal distribution quickly goes to zero, whereas it should be around 400 (as it is for PyMC2). Consequently, the estimated correlation quickly goes towards 1, which is wrong as well. The full code is available in this notebook for PyMC2 and in this notebook for PyMC3 . The relevant code for PyMC2 is def analyze(data): # priors might be adapted here to be less flat mu = pymc.Normal('mu', 0, 0.000001, size=2) sigma = pymc.Uniform(