pearson_phi: Pearson's Phi ('pearson_phi')

View source: R/pearson_phi.R

pearson_phiR Documentation

Pearson's Phi (pearson_phi)

Description

The pearson_phi function identifies the underlying homophilous preference of ego based on the distribution of alter attributes in the population (Perry et al. 2018)

Usage

pearson_phi(
  ego_id,
  ego_measure,
  alter_ego,
  alter_measure,
  prefix = NULL,
  suffix = NULL
)

Arguments

ego_id

A vector of unique ego identifiers located in an ego dataframe. If using data objects created by ego_netwrite, this should be the data frame entitled egos.

ego_measure

A vector of attributes corresponding to each ego.

alter_ego

A vector of ego identifiers located in an alter dataframe. If using data objects created by ego_netwrite, this should be the data frame entitled alters.

alter_measure

A vector of attributes corresponding to each alter

prefix

A character value indicating the desired prefix for the calculated homophily measure.

suffix

A character value indicating the desired suffix for the calculated homophily measure.

Value

pearson_phi returns a dataframe of vectors that include the ego identifier and phi value of homophilous preference.

Examples


# Run `ego_netwrite`
ngq_nw <- ego_netwrite(egos = ngq_egos,
                      ego_id = ngq_egos$ego_id,

                      alters = ngq_alters,
                      alter_id = ngq_alters$alter_id,
                      alter_ego = ngq_alters$ego_id,

                      max_alters = 10,
                      alter_alter = ngq_aa,
                      aa_ego = ngq_aa$ego_id,
                      i_elements = ngq_aa$alter1,
                      j_elements = ngq_aa$alter2,
                      directed = FALSE)


race_pphi <- pearson_phi(ego_id = ngq_nw$egos$ego_id, ego_measure = ngq_nw$egos$race,
                        alter_ego = ngq_nw$alters$ego_id, alter_measure = ngq_nw$alters$race,
                        suffix = "race")

race_pphi

ideanet documentation built on June 8, 2025, 1:07 p.m.