Questions tagged [pairwise]
273 questions
1
vote
2 answers
Use unique pairs of column values to generate dyad identifiers in the dataframe
I want to generate a set of dyad identifiers for a bilateral trade flow dataframe (that is coded in from, to, and amount traded format) such that I could use these identifiers for further statistical analysis.
My example data is provided at below,…

Chris T.
- 1,699
- 7
- 23
- 45
1
vote
4 answers
Convert pairwise distance table to list of distance for individuals in only two columns
I want to convert a pairwise distance table (observations in 2 columns) into a table with individuals listed instead (observations in 1 column). Essentially the info on pairwise relationships will be lost (which is irrelevant to my analysis anyways)…

Deon Bakkes
- 81
- 7
1
vote
0 answers
R correlation: conditional handling for paired vectors with missing data
I'm running a correlation on a large dataset (3500 obs x 1000 var). The problem that I'm facing is a large amount of missing data and I only want to include pairwise observations that meet a certain condition.
In the case where a pair of vectors has…

vincenzo345
- 21
- 1
1
vote
1 answer
Type Error when using TukeyHSD for multi comparison
I am trying to apply TukeyHSD from statsmodels but receive the following error message.
---------------------------------------------------------------------------
TypeError Traceback (most recent call…

Sepatau
- 103
- 2
- 9
1
vote
2 answers
Select the most common value of a column based on matched pairs from two columns using `ddply`
I'm trying to use ddply (a plyr function) to sort and identify the most frequent interaction type between any unique pairs of user from a social media data of the following form
from <- c('A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D',…

Chris T.
- 1,699
- 7
- 23
- 45
1
vote
0 answers
Using pairwise_count to create a relation matrix in R
I have a data set structured like this:
df <- c()
df$Var1 <- c("cat", "dog", "pig", "cat", "cat", "pig")
df$Var2 <- c("A", "B", "C", "B", "C", "A")
df <- as.data.frame(df)
Var1. Var2.
cat. A
dog. B
pig. C
cat. B
cat. C
pig. …

Silvia
- 405
- 4
- 17
1
vote
2 answers
Getting pairwise differences
I am trying to get pairwise differences for price between localities. My data look like this:
table=NULL
table$id= 1:9
table$locality= c("A", "B", "C")
table$price= rnorm(9, 444, 322)
table$concat=paste(table$id,…

Rodrigo
- 121
- 8
1
vote
0 answers
Speed up pairwise fuzzy string matching in Python
I have a collection of 40,000 strings and want to compare their similarity pairwise using fuzz.token_set_ratio(), but my brain is not wired correctly to do this in an efficient way, even after looking into vectorization.
Here is an example:
from…

JBN
- 67
- 4
1
vote
0 answers
Bradley Terry model for pairwise preference data in r
Background
For my thesis, I have conducted a pairwise cafeteria experiment in which pairs of fruit are presented to birds and it is recorded which they chose. From the research, I have found that the appropriate model to analyse this data is a…

Lwes
- 11
- 1
1
vote
3 answers
(fast) pairwise comparison of matrix columns whose elements have "a/b" format
I have a big character matrix (15000 x 150), and with the following format:
A B C D
[1,] "0/0" "0/1" "0/0" "1/1"
[2,] "1/1" "1/1" "0/1" "0/1"
[3,] "1/2" "0/3" "1/1" "2/2"
[4,] "0/0" "0/0" "2/2" "0/0"
[5,] "0/0" "0/0" …

chas
- 1,565
- 5
- 26
- 54
1
vote
2 answers
using sklearn pairwise_distances to compute distance correlation between X and y
I am currently trying various methods:
1. Correlation.
2. Mutual Information.
3. Distance Correlation
to find the strength of relationship between the variables in X and the dependent variable in y.
Correlation is the fastest and simplest(1 hour on…

Shuvayan Das
- 1,198
- 3
- 20
- 40
1
vote
1 answer
Subsetting a pairwise matrix with wlidcard
I would like to subset part of a large pairwise matrix into smaller matrices.
e.g.
TF1 TF2 TF3 TG1 TG2 TG3
TF1 0 2 1 450 460 450
TF2 2 0 1 452 462 462
TF3 1 2 0 451 461 451
TG1 450 452 450 0 2 0
TG2 460 462 462 2 0 …

babyl
- 11
- 1
1
vote
1 answer
How do I create all unique pairwise combinations of my sample dataset
I have a list of 388 sample codes and I want all unique pairwise combinations.
I've tried several options in r but it still doesn't give me what I want.
This is a part of my sample…

Anneleen Rutten
- 49
- 1
- 2
1
vote
2 answers
Plot a re-leveled pairwise distance matrix in ggplot2
Loading libraries and creating a reproducible example
#Load libraries
set.seed(123)
library(tidyr)
library(ggplot2)
#Creating a fake pairwise matrix
locs <- 5
tmp <- matrix(runif(n = locs*locs),nrow = locs,ncol = locs)
tmp[upper.tri(tmp,diag = T)]…

Sardimus
- 156
- 8
1
vote
0 answers
Fastest pairwise distance implementation python/c++
I am looking for the fastest implementation of pairwise distance between two sets of vectors (two 2D arrays) in c++/python.
What have I done? I ran the code from here on my server. In python, I found that the pairwise distance function from scikit…

Vivek Bagaria
- 169
- 8