includeInteraction | R Documentation |
This function allows the user to include or exclude an interaction effect in a Siena effects object.
includeInteraction(myeff, ..., include = TRUE, name = myeff$name[1],
type = "eval", interaction1 = rep("", 3), interaction2 = rep("", 3),
fix=FALSE, test=FALSE, random=FALSE,
initialValue=0,
character = FALSE, verbose = TRUE)
myeff |
a Siena effects object as created by |
... |
2 or 3 short names to identify the effects which should be interacted. |
include |
Boolean. default TRUE, but can be switched to FALSE to turn off an interaction. |
name |
Name of dependent variable (network or behavior) for which interactions are being defined. Defaults to the first in the effects object. |
type |
Type of effects to be interacted. |
interaction1 |
Vector of Siena objects where needed to completely identify the effect e.g. covariate name or behavior variable name. Trailing blanks may be omitted. |
interaction2 |
Vector of siena objects where needed to completely identify the effect e.g. covariate name or behavior variable name. Trailing blanks may be omitted. |
fix |
Boolean. Are the effects to be fixed at the value stored in
|
test |
Boolean. Are the effects to be tested or not (requires |
random |
For specifying that the interaction effect will vary randomly;
not relevant for |
initialValue |
Initial value for estimation. Default 0. |
character |
Boolean: are the effect names character strings or not. |
verbose |
Boolean: should the print of altered effects be produced. |
The details provided should uniquely identify up to three
effects. If so, an interaction effect will be created and included or
not in the model.
Whether interactions between two or three given effects
can be created depends on their interactionType
(which can be, for
dependent network variables, empty, ego, or dyadic; and for dependent
behavioral variables, empty or OK). Consult the section on Interaction
Effects in the manual for this. The interactionType
is shown
in the list of effects obtained from the function
effectsDocumentation
.
The short names must not be set between quotes,
unless you use character=TRUE
.
From the point of view of model building it is usually advisable, when
including an interaction effect in a model, also to include the
corresponding main effects. This is however not enforced
by includeInteraction()
.
As from version 1.3.24, effects object have a "version" attribute.
Effects objects including interaction effects are not necessarily compatible
between versions of RSiena
. Therefore it is recommended to create
such effects objects again when changing to a new version of RSiena
.
If an effects object including any interaction effects is used from an
old version of RSiena
, this will lead to a warning when running
siena07
.
An interaction effect does not have its own internal effect parameter.
The internal effect parameters of the interacting main effects are used,
whether or not these are included in the model. This implies that if an
interaction effect is included but not the corresponding main effects,
or not all of them, then nevertheless the internal effect parameters as
specified in the effects object are used for the interaction.
These can be set using function setEffect
with the desired value
of parameter
and (in this case) include=FALSE
.
The values of the internal effect parameters can be checked for a
sienaFit
object ans
produced by siena07
by looking at ans$effects
, which is the requested effects object
to which the main effects of the user-defined interactions were added,
if they were not yet included.
Interaction effects are constructed from effects with shortName
unspInt
(for networks) and behUnspInt
(for behavior)
by specifying their elements effect1
and effect2
,
and possibly effect3
. The shortName is not altered by this function.
The number of possible user-specified interaction effects is limited
by the parameters nintn
(for dependent network variables)
and behNintn
(for dependent behavior variables)
in the call of getEffects
, which determine the numbers of
effects with shortNames unspInt
and behUnspInt
.
The input names interaction1
and interaction2
do not themselves
refer to created interactions, but to dependence of the base effects on
other variables in the data set.
They are used to completely identify the effects.
Further information about Siena effects objects is given
in the help page for getEffects
.
A list of all effects in a given effects object (e.g., myeff
),
including their names of dependent variables, effect names, short names,
and values of interaction1 and interaction2 (if any),
is obtained by executing effectsDocumentation(myeff)
.
An updated version of the input effects object; if include
,
containing the interaction effect between "effect1" and "effect2" and
possibly "effect3"; if not, without this interaction effect.
The shortName of the interaction effect is "unspInt" for network effects
and "behUnspInt" for behavior effects.
If verbose=TRUE
, details of the fields altered will be printed.
Ruth Ripley, Tom Snijders
See https://www.stats.ox.ac.uk/~snijders/siena/
getEffects
, setEffect
,
includeEffects
, effectsDocumentation
mynet <- sienaDependent(array(c(s501, s502, s503), dim=c(50, 50, 3)))
alc <- varCovar(s50a)
mydata <- sienaDataCreate(mynet, alc)
myeff <- getEffects(mydata)
myeff <- includeEffects(myeff, transTrip)
myeff <- includeInteraction(myeff, recip, inPop)
myeff <- includeEffects(myeff, egoX, altX, simX, interaction1="alc")
myeff <- includeInteraction(myeff, recip, simX, interaction1=c("", "alc"))
myeff
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.