Description Usage Arguments Value See Also Examples
Take input data, create a network matrix (when input network matrix not provided) and evaluate the summary measures
previously defined with functions def_sW and def_sA.
This function is called internally by tmlenet for the evaluation of the summary measures.
The R6 class object named DatNet.ObsP0 that is returned by this function can be supplied as an input to the
tmlenet function.
When DatNet.ObsP0 is used as an input to tmlenet, the rest of the input arguments already provided to
this function can be omitted from the tmlenet function call.
1 2 |
data |
Same as |
Kmax |
Same as |
sW |
Same as |
sA |
Same as |
IDnode |
(Optional) Same as |
NETIDnode |
(Optional) Same as |
sep |
Optional friend ID character separator for friends listed in |
NETIDmat |
(Optional) Same as |
verbose |
Set to |
A named list that contains:
sW.matrix - Matrix of evaluated summary measures for sW.
sA.matrix - Matrix of evaluated summary measures for sA.
NETIDmat - Network ID matrix that can be used for NETIDmat input argument to tmlenet.
DatNet.ObsP0 - R6 object of class DatNet.sWsA that stores all the summary measures and the network information.
This object be passed to tmlenet as an argument, in which case the arguments already provided to eval.summaries no
longer need to be specified to tmlenet.
tmlenet for estimation of network effects and def_sW for defining the summary measures.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #***************************************************************************************
# Define some summary measures for sW
#***************************************************************************************
sW <- def_sW(W1, W2, W3) +
def_sW(netW1 = W1[[1:Kmax]]) +
def_sW(netW2 = W2[[1:Kmax]]) +
def_sW(mean.netW2 = mean(W2[[1:Kmax]]), replaceNAw0 = TRUE) +
def_sW(sum.netW3 = sum(W3[[1:Kmax]]), replaceNAw0 = TRUE)
#***************************************************************************************
# Define some summary measures for sA
#***************************************************************************************
sA <- def_sA(A = A, netA = A[[0:Kmax]]) +
def_sA(sum.netAW2 = sum((1-A[[1:Kmax]])*W2[[1:Kmax]]), replaceNAw0 = TRUE)
#***************************************************************************************
# Evaluate the summary measures applied to the (O)bserved data (data.frame) and network
#***************************************************************************************
# load observed data:
data(df_netKmax6)
# load the network ID matrix:
data(NetInd_mat_Kmax6)
res <- eval.summaries(sW = sW, sA = sA, Kmax = 6, data = df_netKmax6,
NETIDmat = NetInd_mat_Kmax6, verbose = TRUE)
#***************************************************************************************
# Contents of the list returned by eval.summaries():
#***************************************************************************************
names(res)
# observed data matrix with (sW,sA) summary measures:
head(res$DatNet.ObsP0$dat.sWsA)
# matrix of network IDs:
head(res$NETIDmat)
# Observed data summary measures (sW,sA) and network
# stored as "DatNet.sWsA" R6 class object:
res$DatNet.ObsP0
class(res$DatNet.ObsP0)
#***************************************************************************************
# Using DatNet.ObsP0 as input to tmlenet():
#***************************************************************************************
options(tmlenet.verbose = FALSE) # set to TRUE to print status messages
res_K6 <- tmlenet(data = df_netKmax6, NETIDmat = NetInd_mat_Kmax6,
Kmax = 6,
sA = sA, sW = sW,
Qform = "Y ~ sum.netW3 + sum.netAW2",
hform.g0 = "netA ~ netW2 + sum.netW3 + nF",
hform.gstar = "netA ~ sum.netW3",
Ynode = "Y",
intervene1.sA = def_new_sA(A = 1L))
# res_K6 <- tmlenet(DatNet.ObsP0 = res$DatNet.ObsP0,
# Qform = "Y ~ sum.netW3 + sum.netAW2",
# hform.g0 = "netA ~ netW2 + sum.netW3 + nF",
# hform.gstar = "netA ~ sum.netW3",
# Ynode = "Y",
# intervene1.sA = def_new_sA(A = 0L))
# f_gstar1 = 0L)
# Anodes = "A",
res_K6$EY_gstar1$estimates
res_K6$EY_gstar1$IC.vars
res_K6$EY_gstar1$IC.CIs
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.