rr_rating | R Documentation |
The data(gedii_rr)
of package gediismtrx
provides a matrix of
round robin scores for advice seeking, social affinity and psychological safety. This
method provides utility functionalities to convert the round robin matrix into either an
edge list, a network object or a matrix. It performs several transformations if required,
i.e. collapses directed ties to undirected ties or imputes NA values. If directed ties are
converted to undirected ties, several methods can be specified for conversion such as using
only the max or minmum value, the sum, product or mean scores. Also can aggregate network
ties and convert value ties into binary ones, dichotomizing the network at a certain
threshold.
The order in which these operations are carried out is: first, imputation, second, to-undirected ties, and last dichotomization.
rr_rating(
x,
directed = T,
dich.at = NULL,
to.undir = "weight",
as.type = "edgelist",
impute.na = "without",
shuffle = F
)
x |
round-robin matrix |
directed |
logical. If set to |
dich.at |
numeric. Dichotomizes the matrix at the specified value (included). |
to.undir |
string or number. Specifies the method for collapsing directed to undirected edge list. Possible values are "min", "max", "mean", "recip", "weight". See details. |
as.type |
string. The round-robin rating can be retrieved in different formats: as
|
impute.na |
string. Indicates how NAs should be imputed
|
shuffle |
logical. Default is |
Round robin ratings are directional where person A rates person B while person B can
of course rate person A differently. On some occasions, there directional weights (or scores)
need to be collapsed, i.e. the directional ties are converted into undirectional ones based upon
certain rules to be controlled by the two parameters directed
and to.undir
.
The to.undir
controls how directed ties are converted to unidirectional ties. The parameter
takes the following values:
Will retain the minimum weight of two given ties between node pairs. If the weight of A->B = 2 and the weight of B->A = 4, then 2 will be retained for both ties.
Will retain the maximum weight of two given ties between node pairs. If the weight of A->B = 2 and the weight of B->A = 4, then 4 will be retained for both ties.
Will retain the mean weight of two ties between node pairs. Note that NAs (i.e. missing ratings in the matrix) will first be replaced by the overall mean value of all ratings of the matrix. If the weight of A->B = 2 and the weight of B->A = 3, the mean value for the node pair A-B is (2+3)/2 2.5.
Retains only ties which have a reciprocal weight, i.e. both involved parties gave the same rating to each other. If weight of A->B = 2 and B->A is 2, then 2 will be retained; otherwise the weight of the A-B pair will be replaced with 0
Will retain the original scores. No transformation is applied.
Multiplies scores of dyad. A->B=2 and B->A=5 produces 2x5=10
Sums scores of dyad. A->B=2 and B->A=5 produces 2+5=7
Absolute difference between two dyad scores. A->B=2 and B->A=5 produces abs(2-5)=3
The dich.at
dichotomizes the matrix and sets all ties with dich.at>=number
to 1 and 0
otherwise. This maintains directionality of ties.
At the same time, directed
controls if the resulting edge list maintains directed edges
or undirected. In the latter case, mreverse
is applied to obtain an undirected
list of edges with their corresponding scores. A warning is issued if a undirected edge list is
requested but no method for to.undir
specified. Similar, if a method other than "weight"
is specified for to.undir
, which implies to collapse the directed to an undirected edge list,
a warning will be issued that the directionality of the weights will not be maintained.
The impute.na
parameter controls how NAs in round-robin matrix are imputed. It takes the following
values:
In case a ego did not respond and there is no rating of alters, the NAs are replaced with ratings of alter. This means we replaced all NAs in row i with the transpose of ratings given in col(i). In case two ratings are absent, NA remains.
Same as 'recip' with the difference that remaining NAs will be replaced with mean value of all entries
Replaces all NA entries with mean value of matrix
Depends on to.undir options set. For 'sum' and 'diff' will use 0 for NA replacement to have no effect. For 'prod' will use 1 for NA replacement in order to have no effect.
Default value. Will not impute any NAs and thus does not modify matrix
The as.type
allows to select between different return types, either an edgelist, a statnet
network object or a sociomatrix.
If shuffle=T
changes the order of column and rownames at random. Can be used for
manually constructing a QAP permutation test. In detail: retrieves existing colnames (rownames) from
matrix and draws equal size sample. The random ordered column (row) names are then re-assigned before
ordering the matrix rownames and colnames, i.e. changing effectively the order of the column (row)
values.
tibble. In case an directed=T
, a tibble with three columns: head, tail, edge, weight.
In case directed=F
a tibble with two columns only: edge, weight.
#construct matrix
rrmat <- matrix(c(1,0,1,2,0,0,1,1,1,2,3,4,5,2,3,4), ncol=4)
#retain only reciprocal ties of same weight
rr_rating(rrmat, directed=F, to.undir="recip")
#retain min value of ties
rr_rating(rrmat, directed=F, to.undir="min")
#retain "max" values of ties
rr_rating(rrmat, directed=F, to.undir="max")
#dichotomize matrix at weight 3 or above
rr_rating(rrmat, directed=T, dich.at=3)
#retain "mean" values
rr_rating(rrmat, directed=F, to.undir="mean")
#impute NAs. replace row=2 of NAs with col=2 values
rrmat <- matrix(c(1,NA,1,2,0,NA,1,1,1,NA,0,4,5,NA,3,4), ncol=4)
rr_rating(rrmat, impute.na="recip", as.type="matrix")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.