| as_covariate_rsiena | R Documentation |
This function creates a monadic or dyadic covariate object
as_covariate_rsiena(val, type="monadic", centered=TRUE,
nodeSet="Actors", warn=TRUE,
imputationValues=NULL)
val |
Covariate values, given as a vector, or matrix
(may be sparse, of type |
type |
|
centered |
Boolean: if TRUE, then the mean value is subtracted. |
nodeSet |
Name of node set: character string;
for |
warn |
Logical: determines whether a warning given if all values are
|
imputationValues |
For monadic covariates only:
Vector or matrix of covariate values of same
length or dimensions as |
This function determines the kind of covariate from the kind of arguments given:
if val is a vector,
it will be a time-constant monadic (actor) covariate;
if val is a matrix and type="monadic",
it will be a changing monadic (actor) covariate;
if val is a matrix and
type="oneMode" or "bipartite",
it will be a time-constant dyadic covariate;
if val is a 3-dimensional array or list of sparse matrices
of type "TsparseMatrix", it will be a changing dyadic covariate.
When part of a siena data object,
the created covariate is associated with the node set
nodeSet of this data object.
In practice, the node set needs to be specified only in the case of
the use of the covariate with a two-mode network.
If there are any NA values in val, and
imputationValues is given, and the covariate is monadic,
then the corresponding elements
of imputationValues are used for imputation.
If imputationValues is NULL, imputation
is by the mean value. In both cases, cases with imputed values
are not used for calculating target statistics (see the manual).
For changing covariates (monadic or dyadic), the values for wave m
are supposed in the simulations to be valid in the whole period from
wave m to wave m+1.
If the data set has M waves, this means that the values,
if any, for wave M will not be used.
These values may be given or omitted as part of val.
The function replaces coCovar, varCovar,
coDyadCovar, varDyadCovar,
which now are obsolete.
The covariate is returned as an object of class coCovar,
varCovar,
coDyadCovar, or
varDyadCovar, as the case may be. This object
can be used as an argument to make_data_rsiena.
Tom A.B. Snijders
See https://www.stats.ox.ac.uk/~snijders/siena/
make_data_rsiena, as_nodeset_rsiena;
this function replaces the functions coCovar,
varCovar, coDyadCovar, varDyadCovar.
# constant monadic covariate:
myconstcovar <- as_covariate_rsiena(s50a[,1])
senders <- as_nodeset_rsiena(50, nodeSetName="senders")
receivers <- as_nodeset_rsiena(30, nodeSetName="receivers")
senders.attribute <- as_covariate_rsiena(rep(1:10, each=5),
nodeSet="senders")
receivers.attribute <- as_covariate_rsiena(rep(1:5, each=6),
nodeSet="receivers")
# varying monadic covariate:
myvarcovar <- as_covariate_rsiena(s50a, type="monadic")
senders.covariate <- as_covariate_rsiena(s50a, nodeSet="senders",
type="monadic")
receivers.covariate <- as_covariate_rsiena(s50s[1:30,],
nodeSet="receivers", type="monadic")
# constant dyadic covariate:
mydyadvar <- as_covariate_rsiena(s503, type="oneMode")
# varying dyadic covariate:
mydyadvar <- as_covariate_rsiena(array(c(s501, s502), dim=c(50, 50, 2)),
type="oneMode")
# using sparse matrices for a constant dyadic covariate:
require(Matrix)
sps501 <- as(s501,"TsparseMatrix")
sps502 <- as(s502,"TsparseMatrix")
sps502r <- as(s502[1:30,],"TsparseMatrix")
spcDyadvar <- as_covariate_rsiena(sps501, type="oneMode")
spvDyadvar <- as_covariate_rsiena(list(sps501,sps502), type="oneMode")
spvDyadBipvar <- as_covariate_rsiena(list(sps501,sps502),
type="bipartite", nodeSet=c("senders","receivers"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.