Add user-created terms to tnet.growth.clogit

Additional terms can easily be implemented in tnet.growth.clogit.The simplest way is the output the regression table and add terms to this table. However, you can also develop more advanced terms by altering the source code.

If you develop a term, I would be grateful if you send me the code as I can then included in the version available on this website.

To include terms, the parts of the code that need to be changes depend on the nature of the term. There are two types of terms used by tnet.growth.clogit:

  1. Network-based terms
  2. Covariate-based terms

IF a network-based term is added ("netterm"), the following alterations must be done:

  1. Add the term to the list at line 35-42:
      for (t in effects[effects != "indegree" & 
        effects != "instrength" & 
        effects != "reciprocity" & 
        effects != "reciprocityw" & 
        effects != "triadic.closure" & 
        effects != "triadic.closure.w.min" & 
        effects != "triadic.closure.w.gm" & 
        effects != "reinforcement"]) {

    For example:

      for (t in effects[effects != "indegree" & 
        effects != "instrength" & 
        effects != "reciprocity" & 
        effects != "reciprocityw" & 
        effects != "triadic.closure" & 
        effects != "triadic.closure.w.min" & 
        effects != "triadic.closure.w.gm" & 
        effects != "reinforcement" &
        effects != "netterm"]) {
  2. Add the term to the list at line 207:
      if(length(effects[effects %in% c("reinforcement","indegree",
        "instrength","reciprocity","reciprocityw","triadic.closure",
        "triadic.closure.w.min","triadic.closure.w.gm")])>0) {

    For example:

      if(length(effects[effects %in% c("reinforcement","indegree",
        "instrength","reciprocity","reciprocityw","triadic.closure",
        "triadic.closure.w.min","triadic.closure.w.gm","netterm")])>0) {
  3. Add the module at line 322. The first line should contain the name of the module:
        ##Triadic closure weighted: triplet value = minimum
    The second line should contain an IF statement to verify whether the term is included:
      if(length(effects[effects %in% "triadic.closure.w.min"])>0) {
    Then matrices needed by the function should be defined, e.g. for triadic.closure.w.min:
          dcwmin <- d;
    A results matrix should also be defined:
          netterm <- matrix(data=as.integer(0), nrow=nstrata, ncol=nrow(ld))
    Then a function that calculates the effect for the nodes defined in the strata (in vector k) should be included:
         effectfunction <- c(effectfunction, "netterm[,t] <- as.integer(dcwmin[i,k])")
    In addition, strings should be added to the the update functions. The updatefunctionb should be used when the tie is first formed, whereas updatefunctionw should be used when a tie is a reinforcement (d[i,j]>0), e.g.
          updatefunctionb <- c(updatefunctionb, 
    "dcwmin[which(d[,i]>0),j] <- dcwmin[which(d[,i]>0),j]+1")
          updatefunctionw <- c(updatefunctionw,
    "dcwmin[which(d[,i]>=d[i,j]),j] <- dcwmin[which(d[,i]>=d[i,j]),j]+1")
    Finally, the IF statement should be closed:
        }
  4. The term should be added to the list at line 362:
        for (t in effects[effects == "indegree" | 
                  effects == "instrength" |
                  effects == "reciprocity" |
                  effects == "reciprocityw" |
                  effects == "triadic.closure" |
                  effects == "triadic.closure.w.min" |
                  effects == "triadic.closure.w.gm" |
                  effects == "reinforcement"])
    For example:
         for (t in effects[effects == "indegree" | 
                  effects == "instrength" |
                  effects == "reciprocity" |
                  effects == "reciprocityw" |
                  effects == "triadic.closure" |
                  effects == "triadic.closure.w.min" |
                  effects == "triadic.closure.w.gm" |
                  effects == "reinforcement" |
                   effects == "netterm"])

IF you would like to add terms based on attributes, you need to do the following (term starts with term.):

  1. Add an IF statement for the term at line 130. For example effects that start with "term.":
        } else if(substr(t,1,5)=="term.") {
  2. Increase ax with 1
            ax <- ax+1;
  3. Create a NxN matrix and name it a.X, where X is the value of ax

  4. Add the effect name as an attribute to the a.X object:
            attributes(a.X)$nameeffect <- t
Last Updated ( Wednesday, 10 September 2008 )