tmlenet (version 0.1.0)

eval.summaries: Evaluate Summary Measures sA and sW

Description

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.

Usage

eval.summaries(data, Kmax, sW, sA, IDnode = NULL, NETIDnode = NULL, sep = " ", NETIDmat = NULL, verbose = getOption("tmlenet.verbose"))

Arguments

data
Same as tmlenet input argument.
Kmax
Same as tmlenet input argument.
sW
Same as tmlenet input argument.
sA
Same as tmlenet input argument.
IDnode
(Optional) Same as tmlenet input argument.
NETIDnode
(Optional) Same as tmlenet input argument.
sep
Optional friend ID character separator for friends listed in NETIDnode column of data, default is ' '; same as tmlenet input argument optPars$sep.
NETIDmat
(Optional) Same as tmlenet input argument.
verbose
Set to TRUE to print messages on status and information to the console. Turn this on by default using options(tmlenet.verbose=TRUE).

Value

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.

See Also

tmlenet for estimation of network effects and def.sW for defining the summary measures.

Examples

Run this code
#***************************************************************************************
# Define some summary measures for sW
#***************************************************************************************
def_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
#***************************************************************************************
def_sA <- def.sA(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 = def_sW, sA = def_sA,  Kmax = 6, data = df_netKmax6,
  NETIDmat = NetInd_mat_Kmax6, verbose = TRUE)

#***************************************************************************************
# Contents of the list returned by eval.summaries():
#***************************************************************************************
names(res)
# matrix of sW summary measures:
head(res$sW.matrix)
# matrix of sA summary measures:
head(res$sA.matrix)
# 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(DatNet.ObsP0 = res$DatNet.ObsP0,
                    Qform = "Y ~ sum.netW3 + sum.netAW2",
                    hform.g0 = "netA ~ netW2 + sum.netW3 + nF",
                    hform.gstar = "netA ~ sum.netW3",
                    Anode = "A", Ynode = "Y", f_gstar1 = 0L)

res_K6$EY_gstar1$estimates
res_K6$EY_gstar1$vars
res_K6$EY_gstar1$CIs



Run the code above in your browser using DataCamp Workspace