Description Usage Arguments Details Value Note Author(s) References Examples
This helper function formats the LinksPair datasets so it can be used in some types of spatial analyses. The spdep (Spatial Dependence) uses a sparse matrix (actually a data.frame
) to represent neigbours.
1 | CreateSpatialNeighbours(linksPairsDoubleEntered)
|
linksPairsDoubleEntered |
A
|
There is one row per unique pair of subjects, respecting order. This has twice as many rows as Links79Pair
and Links79PairExpanded
(which have one row per unique pair of subjects, irrespective of order).
CreateSpatialNeighbours
accepts any paired relationships in a data.frame
, as long as it contains the columns SubjectTag_S1
, SubjectTag_S2
, and R
. See Links79Pair
for more details about these columns.
An S3 spatial.neighbours
object to work with functions in the spdep package.
SubjectTag_S1
is renamed 'from
'.
SubjectTag_S2
is renamed 'to
'.
R
is renamed 'weight
'.
The attribute region.id
specifies each unique SubjectTag.
The attribue n
specifies the number of unique subjects.
Notice the British variant of 'neighbours' is used, to be consistent with the spatial.neighbour
class in the spdep
package.
Will Beasley and David Bard
Bard, D.E., Beasley, W.H., Meredith, K., & Rodgers, J.L. (2012). Biometric Analysis of Complex NLSY Pedigrees: Introducing a Conditional Autoregressive Biometric (CARB) Mixed Model. Behavior Genetics Association 42nd Annual Meeting. [Slides]
Bivand, R., Pebesma, E., & Gomez-Rubio, V. (2013). Applied Spatial Data Analysis with R. New York: Springer. (Especially Chapter 9.)
Banerjee, S., Carlin, B.P., & Gelfand, A.E. (2004). Hierarchical Modeling and Analysis for Spatial Data. Boca Raton: CRC Press.
Lawson, A.B (2013). Bayesian Disease Mapping: Hierarchical Modeling in Spatial Epidemiology, Second Edition. Boca Raton: CRC Press.
The spdep package documentation: spdep: Spatial dependence: weighting schemes, statistics and models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | dsLinksAll <- Links79Pair
dsLinksGen1Housemates <- dsLinksAll[dsLinksAll$RelationshipPath=="Gen1Housemates", ]
dsLinksGen2Siblings <- dsLinksAll[dsLinksAll$RelationshipPath=="Gen2Siblings", ]
spGen1 <- CreateSpatialNeighbours(dsLinksGen1Housemates)
spGen2 <- CreateSpatialNeighbours(dsLinksGen2Siblings)
head(spGen2)
#Returns:
# from to weight
#3 201 202 0.50
#6 301 302 0.50
#7 301 303 0.50
#9 302 303 0.50
#24 401 403 0.25
#28 801 802 0.50
table(spGen2$weight)
#Returns:
#0.25 0.375 0.5 0.75 1
#3442 610 6997 12 27
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.