Title: | Social Autocorrelation |
---|---|
Description: | A set of functions to quantify and visualise social autocorrelation. |
Authors: | Tom Pike |
Maintainer: | Tom Pike <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2025-03-07 03:48:24 UTC |
Source: | https://github.com/cran/social |
Calculates the social correlation matrix for a given network
social.cor.matrix(A, max.depth = nrow(A), n.pilot = 5000, n.estimate = 10000)
social.cor.matrix(A, max.depth = nrow(A), n.pilot = 5000, n.estimate = 10000)
A |
a (possibly weighted) adjacency matrix. |
max.depth |
the maximum length of the paths to use. |
n.pilot |
parameter to be passed to |
n.estimate |
parameter to be passed to |
The calculated social correlation matrix.
A = matrix(c(0,1,0,1,0, 1,0,0,1,1, 0,0,0,1,1, 1,1,1,0,0, 0,1,1,0,0), nrow=5) S = social.cor.matrix(A)
A = matrix(c(0,1,0,1,0, 1,0,0,1,1, 0,0,0,1,1, 1,1,1,0,0, 0,1,1,0,0), nrow=5) S = social.cor.matrix(A)
An example dataset for demonstrating the functions available in the social package.
data(social.example1)
data(social.example1)
The dataset consists of a list with 3 items: A
, a 30x30 adjacency matrix; S
, a 30x30 social correlation matrix derived from A
using S = social.cor.matrix(A, max.depth=5)
; and social.data
, a 30-row data frame containing two columns of numeric data, x
and y
, and a column of node IDs (node.id
, corresponding to the row and column names of A
and S
).
data(social.example1)
data(social.example1)
An example dataset for demonstrating the functions available in the social package.
data(social.example2)
data(social.example2)
The dataset consists of a list with 3 items: A
, a 30x30 adjacency matrix; S
, a 30x30 social correlation matrix derived from A
using S = social.cor.matrix(A, max.depth=5)
; and social.data
, a 30-row data frame containing two columns of numeric data, x
and y
, and a column of node IDs (node.id
, corresponding to the row and column names of A
and S
).
data(social.example2)
data(social.example2)
A plot of social data against its socially lagged values
social.plot(x, S, ...)
social.plot(x, S, ...)
x |
a numeric vector of social data. |
S |
a social correlation matrix. |
... |
further arguments to be passed to |
None
A = matrix(c(0,1,0,1,0, 1,0,0,1,1, 0,0,0,1,1, 1,1,1,0,0, 0,1,1,0,0), nrow=5) S = social.cor.matrix(A) x = rnorm(nrow(A)) social.plot(x, S, ylim=c(min(x),max(x)), xlab="x", ylab="Socially lagged x") abline(0, 1, lty=2)
A = matrix(c(0,1,0,1,0, 1,0,0,1,1, 0,0,0,1,1, 1,1,1,0,0, 0,1,1,0,0), nrow=5) S = social.cor.matrix(A) x = rnorm(nrow(A)) social.plot(x, S, ylim=c(min(x),max(x)), xlab="x", ylab="Socially lagged x") abline(0, 1, lty=2)
Calculates the social signal for a given variable (essentially just Moran's I, but using the social correlation matrix as the weights)
social.signal(x, S)
social.signal(x, S)
x |
a numeric vector of social data. |
S |
a social correlation matrix. |
A list containing the computed global social signal (Is
),
the p-value of a test of the null hypothesis that there
is no social autocorrelation under the assumption of normality (p.value
), and the
local social signal for each node (I.local
).
A = matrix(c(0,1,0,1,0, 1,0,0,1,1, 0,0,0,1,1, 1,1,1,0,0, 0,1,1,0,0), nrow=5) S = social.cor.matrix(A) x = rnorm(nrow(A)) s = social.signal(x, S)
A = matrix(c(0,1,0,1,0, 1,0,0,1,1, 0,0,0,1,1, 1,1,1,0,0, 0,1,1,0,0), nrow=5) S = social.cor.matrix(A) x = rnorm(nrow(A)) s = social.signal(x, S)
All paths between two nodes
Description
Estimate all the possible paths between two nodes in a simple graph using the stochastic method described by Roberts & Kroese (2007).
Usage
Arguments
A
a (possibly weighted) adjacency matrix.
start.node
the index of the vertex from which the paths will be calculated.
end.node
the index of the vertex to which the paths will be calculated.
max.depth
the maximum length of the paths to the returned.
n.pilot
the number of naive paths to generate (see Roberts & Kroese, 2007).
n.estimate
the number of paths to generate (see Roberts & Kroese, 2007).
Value
An estimate of all the unique paths between
start.node
andend.node
as annrow(A)
xN matrix, padded with zeros.References
Roberts, B. & Kroese, D.P. (2007) Estimating the number of s-t paths in a graph. Journal of Graph Algorithms and Applications 11(1), 195-214.
Examples