correlation

Customize correlation plot r

强颜欢笑 提交于 2019-12-25 01:34:54
问题 Hi I want to customize the plot to something like this: -I want to have some straight line inside the plot and want to change the legend to something in the left side rather than the normal legend in right side. Also add some texts beside the variables (categorize). I have tried ggcorrplot, ggcorr, corrplot, ggplot to make this, but still can't find the solution. Anyone can help? Thanks. Sample plot-How to make it? ggcorr(data = NULL, cor_matrix = corr, nbreaks = 4, hjust = 1, size = 3, color

How to set a value's for calculating Eucludeian distance and correlation

主宰稳场 提交于 2019-12-24 20:26:20
问题 Here is my word vector : google test stackoverflow yahoo I have assigned a value for these words as follows : google : 1 test : 2 stackoverflow : 3 yahoo : 4 Here are some sample users and their words : user1 google, test , stackoverflow user2 test , google user3 test , yahoo user4 stackoverflow , yahoo user5 stackoverflow , google user6 To cater for users which do not have value contained in the word vector I assign '0' Based on this, this corresponds to : user1 1, 2 , 3 user2 2 , 1 , 0

Series of Correlation coefficient calculation

末鹿安然 提交于 2019-12-24 19:31:56
问题 I want to analyse the default data set in R (mtcars data set). I am interested in creating column of correlation coefficients according to the below rule. Correlation coefficient of only first three observations ((i.e., row 1,2,3)) between "mpg" and "wt", then leaving the first row, calculate again correlation coefficient between next three observations (i.e., row 2,3,4) between mpg and wt then leaving the first two rows, calculate again correlation coefficient between next three observations

Correlation between three variables in MATLAB

社会主义新天地 提交于 2019-12-24 16:34:04
问题 In MATLAB, I have the following: A, B, C are 1 x 101 row vectors. I know that for 'i' from 1 to 101, A(i), B(i), and C(i) are linearly correlated. How can I identify the dependence between A, B, and C? 回答1: For the degree of correlation, you can use corrcoef: data = [A(:) B(:) C(:)]; correlation = corrcoef(data); Here's a test case that shows positive/negative correlation as well as the degree of correlation, with N = 10000; A = randn(N,1); B = 3*A + randn(N,1); C = -2*A + 20*randn(N,1);

Wavelet correlation using rolling window

北慕城南 提交于 2019-12-24 12:18:04
问题 I have 3 time series which I can apply the wavelet transform to using a rolling window. The rolling window takes a single time series of length 200 and applies the waveslim::modwt function to it over the first 30 samples. This outputs 5 lists of which I am only interested in (d1,d2,d3,d4) and these each have a length of 30. A simple example can be found here: library(waveslim) J <- 4 #no. of levels in decomposition data(ar1) ar1.modwt <- modwt(ar1, "la8", J) @G. Grothendieck has kindly

matplotlib correlation matrix heatmap with grouped colors as labels

瘦欲@ 提交于 2019-12-24 10:43:54
问题 I have a correlation matrix hat I am trying to visualize with matplotlib. I can create a heatmap style figure just fine, but I am running into problems with how I want the labels. I'm not even sure if this is possible, but this is what I'm trying to do and can't seem to make it work: My correlation matrix is 150 X 150. On either the x or y (or both...this doesn't matter) axis, I would like to group the labels and then simply label them with a color, or a white label on a color background. To

loop over all possible combinations

梦想与她 提交于 2019-12-24 09:59:06
问题 I would like to include a loop in my script which finds the correlation of every possible combination of the data. This can be done manually by the following code: clear all %generate fake data LName={'Name1','Name2','Name3'}; Data={rand(12,1),rand(12,1),rand(12,1)}; %place in a structure d = [LName;Data]; Data = struct(d{:}); %find the correlation [R,P] = corrcoef(Data.Name1,Data.Name2); [R2,P2] = corrcoef(Data.Name1,Data.Name3); [R3,P3] = corrcoef(Data.Name2,Data.Name3); However, I would

Efficiency issues with finding correlations between lists inside lists

让人想犯罪 __ 提交于 2019-12-24 09:47:55
问题 If I have two small lists and I want to find the correlation between each list inside list1 with each list inside list2 , I can do this from scipy.stats import pearsonr list1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] list2 = [[10,20,30],[40,50,60],[77,78,79],[80,78,56]] corrVal = [] for i in list1: for j in list2: corrVal.append(pearsonr(i,j)[0]) print(corrVal) OUTPUT: [1.0, 1.0, 1.0, -0.90112711377916588, 1.0, 1.0, 1.0, -0.90112711377916588, 1.0, 1.0, 1.0, -0.90112711377916588, 1.0, 1.0, 1.0,

Efficiency issues with finding correlations between lists inside lists

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 09:46:17
问题 If I have two small lists and I want to find the correlation between each list inside list1 with each list inside list2 , I can do this from scipy.stats import pearsonr list1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] list2 = [[10,20,30],[40,50,60],[77,78,79],[80,78,56]] corrVal = [] for i in list1: for j in list2: corrVal.append(pearsonr(i,j)[0]) print(corrVal) OUTPUT: [1.0, 1.0, 1.0, -0.90112711377916588, 1.0, 1.0, 1.0, -0.90112711377916588, 1.0, 1.0, 1.0, -0.90112711377916588, 1.0, 1.0, 1.0,

How do you calculate a (non-self) correlation matrix in pandas with multicolumns?

淺唱寂寞╮ 提交于 2019-12-24 07:34:47
问题 Suppose I have a pandas dataframe with multicolumns, like so: import pandas as pd iterables = [['a', 'b'], ['1', '2']] my_index = pd.MultiIndex.from_product(iterables, names=['first', 'second']) df = pd.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]], columns=my_index) Then df produces first a b second 1 2 1 2 0 1 2 3 4 1 5 6 7 8 Now if I want the self-correlation of df['a'] with itself, that's straight-forward: df['a'].corr() gets me that. Note that such a correlation has shape (2, 2) . What I would