eval.summaries: Evaluate Summary Measures sA and sW

Description Usage Arguments Value See Also Examples

View source: R/tmlenet.R

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

1
2
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:

See Also

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

Examples

 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
#***************************************************************************************
# 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

tmlenet documentation built on May 29, 2017, 2:22 p.m.

Search within the tmlenet package
Search all R packages, documentation and source code