[Rsiena-commits] r142 - in pkg: RSiena RSienaTest RSienaTest/R RSienaTest/data RSienaTest/man RSienaTest/src/model/effects

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 6 04:15:26 CET 2011


Author: jalospinoso
Date: 2011-03-06 04:15:22 +0100 (Sun, 06 Mar 2011)
New Revision: 142

Added:
   pkg/RSienaTest/src/model/effects/GwespBBEffect.cpp
   pkg/RSienaTest/src/model/effects/GwespBBEffect.h
   pkg/RSienaTest/src/model/effects/GwespBFEffect.cpp
   pkg/RSienaTest/src/model/effects/GwespBFEffect.h
   pkg/RSienaTest/src/model/effects/GwespFBEffect.cpp
   pkg/RSienaTest/src/model/effects/GwespFBEffect.h
   pkg/RSienaTest/src/model/effects/GwespFFEffect.cpp
   pkg/RSienaTest/src/model/effects/GwespFFEffect.h
   pkg/RSienaTest/src/model/effects/GwespRREffect.cpp
   pkg/RSienaTest/src/model/effects/GwespRREffect.h
Modified:
   pkg/RSiena/DESCRIPTION
   pkg/RSiena/changeLog
   pkg/RSienaTest/DESCRIPTION
   pkg/RSienaTest/R/sienaGOF.r
   pkg/RSienaTest/changeLog
   pkg/RSienaTest/data/allEffects.csv
   pkg/RSienaTest/man/sienaGOF.Rd
   pkg/RSienaTest/src/model/effects/AllEffects.h
   pkg/RSienaTest/src/model/effects/EffectFactory.cpp
Log:
Added Gwesp, some debugs to sienaGOF

Modified: pkg/RSiena/DESCRIPTION
===================================================================
--- pkg/RSiena/DESCRIPTION	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSiena/DESCRIPTION	2011-03-06 03:15:22 UTC (rev 142)
@@ -1,8 +1,8 @@
 Package: RSiena
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.0.12.141
-Date: 2011-02-26
+Version: 1.0.12.142
+Date: 2011-03-06
 Author: Various
 Depends: R (>= 2.9.0), xtable
 Imports: Matrix

Modified: pkg/RSiena/changeLog
===================================================================
--- pkg/RSiena/changeLog	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSiena/changeLog	2011-03-06 03:15:22 UTC (rev 142)
@@ -1,3 +1,27 @@
+2011-03-06 R-forge revision 142
+
+	* R/sienaGOF: fixed a plotting issue with missing data
+	*  src/model/effects/EffectFactory.cpp: added GWESP terms
+	* src/model/effects/AllEffects.h: added GWESP terms
+	* src/model/effects/EffectFactory.cpp: added GWESP terms
+	* data/allEffects.csv: added GWESP terms
+	* man/sienaGOF.Rd: Incorporated GWESP into the model
+	* src/model/effects/GwespBFEffect.h added
+	* src/model/effects/GwespFBEffect.h added
+	* src/model/effects/GwespBBEffect.h added
+	* src/model/effects/GwespFFEffect.h added
+	* src/model/effects/GwespRREffect.h added
+	* src/model/effects/GwespBFEffect.cpp added
+	* src/model/effects/GwespFBEffect.cpp added
+	* src/model/effects/GwespBBEffect.cpp added
+	* src/model/effects/GwespFFEffect.cpp added
+	* src/model/effects/GwespRREffect.cpp added
+	* NOTE: the 'parm' column needs an integer, and I got
+	around this by using it as a "hundredths" interpretation
+	so that I x 100 when it reaches the effect object's
+	constructor. It would be nice to have it imported in
+	"createEffect" as a double.
+
 2011-02-26 R-forge revision 141
 
 	* man/RSiena-package.Rd, DESCRIPTION: fix typos, one making check fail!

Modified: pkg/RSienaTest/DESCRIPTION
===================================================================
--- pkg/RSienaTest/DESCRIPTION	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/DESCRIPTION	2011-03-06 03:15:22 UTC (rev 142)
@@ -1,8 +1,8 @@
 Package: RSienaTest
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.0.12.141
-Date: 2011-02-26
+Version: 1.0.12.142
+Date: 2011-03-06
 Author: Various
 Depends: R (>= 2.9.0), xtable
 Imports: Matrix

Modified: pkg/RSienaTest/R/sienaGOF.r
===================================================================
--- pkg/RSienaTest/R/sienaGOF.r	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/R/sienaGOF.r	2011-03-06 03:15:22 UTC (rev 142)
@@ -429,10 +429,12 @@
 			}
 		}
 		x <- x[[wave]]
-		itns <- nrow(x$Simulations)
-		vars <- ncol(x$Simulations)
 		sims <- x$Simulations
 		obs <- x$Observations
+		itns <- nrow(sims)
+		vars <- ncol(sims)
+
+		## Need to check for useless statistics here:
 		n.obs <- nrow(obs)
 		if (standardize==3) 
 		{
@@ -464,8 +466,15 @@
 			obs <- matrix(sapply(1:ncol(sims), function(i)
 								(obs[,i] - sims.mean[i]) ), nrow=n.obs )
 		}
-		sims[is.nan(sims)] <- 0
-		obs[is.nan(obs)] <- 0
+		
+		screen <- sapply(1:ncol(obs),function(i){
+			(sum(is.nan(rbind(sims,obs)[,i])) == 0) }) &
+			(diag(var(rbind(sims,obs)))!=0)
+		sims <- sims[,screen, drop=FALSE]
+		obs <- obs[,screen, drop=FALSE]
+		obsLabels <- round(x$Observations[,screen, drop=FALSE],3)
+		key <- key[screen]
+		
 		if (is.null(ylim)) 
 		{
 			ylim = c(min(obs, sims), max(obs, sims))
@@ -483,7 +492,7 @@
 		{
 			ylab = "Statistic Values"
 		}
-		xAxis <- (1:vars)
+		xAxis <- (1:sum(screen))
 		
 		plot(obs[1,]~xAxis, col="white", type="p",
 				ylim=ylim, xlim=xlim, main=main,
@@ -527,7 +536,7 @@
 		{
 			lines(obs[i,]~xAxis, col="red", type="l", lwd=1, ...)
 			lines(obs[i,]~xAxis, col="red", type="p", lwd=3, pch=19, ...)
-			text(xAxis, obs[i,], labels=round(x$Observation[i,],3), pos=4)
+			text(xAxis, obs[i,], labels=obsLabels[i,], pos=4)
 		}
 	}
 }
\ No newline at end of file

Modified: pkg/RSienaTest/changeLog
===================================================================
--- pkg/RSienaTest/changeLog	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/changeLog	2011-03-06 03:15:22 UTC (rev 142)
@@ -1,3 +1,27 @@
+2011-03-06 R-forge revision 142
+
+	* R/sienaGOF: fixed a plotting issue with missing data
+	*  src/model/effects/EffectFactory.cpp: added GWESP terms
+	* src/model/effects/AllEffects.h: added GWESP terms
+	* src/model/effects/EffectFactory.cpp: added GWESP terms
+	* data/allEffects.csv: added GWESP terms
+	* man/sienaGOF.Rd: Incorporated GWESP into the model
+	* src/model/effects/GwespBFEffect.h added
+	* src/model/effects/GwespFBEffect.h added
+	* src/model/effects/GwespBBEffect.h added
+	* src/model/effects/GwespFFEffect.h added
+	* src/model/effects/GwespRREffect.h added
+	* src/model/effects/GwespBFEffect.cpp added
+	* src/model/effects/GwespFBEffect.cpp added
+	* src/model/effects/GwespBBEffect.cpp added
+	* src/model/effects/GwespFFEffect.cpp added
+	* src/model/effects/GwespRREffect.cpp added
+	* NOTE: the 'parm' column needs an integer, and I got
+	around this by using it as a "hundredths" interpretation
+	so that I x 100 when it reaches the effect object's
+	constructor. It would be nice to have it imported in
+	"createEffect" as a double.
+
 2011-02-26 R-forge revision 141
 
 	* man/RSiena-package.Rd, DESCRIPTION: fix typos, one making check fail!

Modified: pkg/RSienaTest/data/allEffects.csv
===================================================================
--- pkg/RSienaTest/data/allEffects.csv	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/data/allEffects.csv	2011-03-06 03:15:22 UTC (rev 142)
@@ -121,6 +121,11 @@
 nonSymmetricObjective,outdegree - activity,Sum of squared outdegrees,outAct,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,0,objective,NA,NA,0,0,0,0,
 nonSymmetricObjective,outdegree - activity (sqrt),Sum of outdegrees^(1.5),outActSqrt,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,0,objective,NA,NA,0,0,0,0,
 nonSymmetricObjective,1/(outdegree + #),Sum 1/(outdegrees + #),outInv,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,1,objective,NA,NA,0,0,0,0,
+nonSymmetricObjective,GWESP I -> K -> J (#),Number of edgewise shared partners by two path (#),gwespFF,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,25,objective,NA,NA,0,0,0,0,
+nonSymmetricObjective,GWESP I <- K <- J (#),Number of edgewise shared partners by reverse two path (#),gwespBB,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,25,objective,NA,NA,0,0,0,0,
+nonSymmetricObjective,GWESP I <- K -> J (#),Number of edgewise shared partners by out two stars (#),gwespFB,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,25,objective,NA,NA,0,0,0,0,
+nonSymmetricObjective,GWESP I -> K <- J (#),Number of edgewise shared partners by in two stars (#),gwespBF,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,25,objective,NA,NA,0,0,0,0,
+nonSymmetricObjective,GWESP I <> K <> J (#),Number of edgewise shared partners both in AND out two stars (#),gwespRR,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,25,objective,NA,NA,0,0,0,0,
 nonSymmetricObjective,1/(outdegree+#)(outdegree+1+#),Sum 1/(outdegrees + #)(outdegrees + 1 + #),outSqInv,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,1,objective,NA,NA,0,0,0,0,
 nonSymmetricObjective,out-out degree^(1/#) assortativity,Sum of out-out degree^(1/#) products,outOutAss,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,2,objective,NA,NA,0,0,0,0,
 nonSymmetricObjective,out-in degree^(1/#) assortativity,Sum of out-in degree^(1/#) products,outInAss,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,2,objective,NA,NA,0,0,0,0,
@@ -176,4 +181,4 @@
 bipartiteBipartiteObjective,outdegree^(1/#) xxxxxx activity,sum outd. x degree^(1/#) xxxxxx,outActIntn,TRUE,xxxxxx,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,2,objective,NA,NA,0,0,0,0,dyadic
 covarNetNetObjective,from xxxxxx agr. x same yyyyyy,"m.tr. XWW, W = xxxxxx, same yyyyyy",covNetNet,TRUE,xxxxxx,yyyyyy,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,0,objective,NA,NA,0,0,0,0,dyadic
 covarNetNetObjective,yyyyyy alter at distance 2 on xxxxxx,yyyyyy alter at distance 2 on xxxxxx,altDist2W,TRUE,xxxxxx,yyyyyy,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,1,objective,NA,NA,0,0,0,0,
-covarNetNetObjective,yyyyyy similarity at distance 2 on xxxxxx,yyyyyy similarity at distance 2 on xxxxxx,simDist2W,TRUE,xxxxxx,yyyyyy,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,0,objective,NA,NA,0,0,0,0,
+covarNetNetObjective,yyyyyy similarity at distance 2 on xxxxxx,yyyyyy similarity at distance 2 on xxxxxx,simDist2W,TRUE,xxxxxx,yyyyyy,eval,FALSE,FALSE,FALSE,FALSE,FALSE,",",0,0,objective,NA,NA,0,0,0,0,
\ No newline at end of file

Modified: pkg/RSienaTest/man/sienaGOF.Rd
===================================================================
--- pkg/RSienaTest/man/sienaGOF.Rd	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/man/sienaGOF.Rd	2011-03-06 03:15:22 UTC (rev 142)
@@ -27,7 +27,6 @@
 \method{print}{sienaGOF}(x, \dots)
 }
 \arguments{
- ## sienaGOF(\dots):
   \item{sienaDataObject}{Results from a call to \code{sienaDataCreate}.}
   \item{sienaFitObject}{Results from a call to \code{siena07}.}
   \item{groupName}{The name of the sienaGroup to be used.}
@@ -51,7 +50,6 @@
   \item{twoTailed}{Whether to use two tails for calculating p values on the
    Monte Carlo test. Recommended for 
   advanced users only, as it is probably only applicable in rare cases.}
-  ## plot(\dots):
   \item{x}{ Object from a call to sienaGOF. }
   \item{standardize}{ One of three levels of standardization to be performed
   on the auxiliary statistics (for layout):
@@ -72,7 +70,6 @@
   This option will negate most of the others. }
   \item{imageThreshold}{ Threshold for the ratio of errors required
   to plot a false dyad in the image.}
-  ## Both:
   \item{wave}{Wave(s) to be used.}
   \item{\dots}{Other arguments.}
 }
@@ -149,25 +146,26 @@
 mynet1 <- sienaNet(array(c(s501, s502, s503), dim=c(50, 50, 3)))
 mydata <- sienaDataCreate(mynet1)
 myeff <- getEffects(mydata)
-myeff <- includeEffects(myeff, transTrip, balance)
+myeff <- includeEffects(myeff, gwespFB, balance)
+# The 'parm' column only accepts integers, so the convention is
+# to specify alpha * 100, i.e. in hundredths:
+myeff[myeff$shortName=='gwespFB', 'parm'] <- 30
 ans <- siena07(mymodel, data=mydata, effects=myeff, returnDeps=TRUE, batch=TRUE)
 
 require(sna)
 require(network)
+
+missingsToZero <- function(x, missingData) {
+	x[is.na(x)] <- 0
+	1*( (x==1 & !missingData) )
+}
+
 triadCensus <- function (x, missingData) {
 	# Zero out the missing data
-	zeroed <- 1*( (x==1 & !missingData) )
+	zeroed <- missingsToZero(x, missingData)
 	triad.census(as.matrix(zeroed))
-	## ALTERNATELY: Utilize the edgelist. This can be
-	## slower, depending on the package used. For
-	## traid.census, this approach takes 1.5x the time
-	# summary() of a sparse matrix gets the egdelist
-	#edgelist <- summary(zeroed)
-	# Ensure all nodes are represented in the edgelist
-	#edgelist <- rbind(edgelist,c(nrow(x),nrow(x),0))
-	#triad.census(network(edgelist))
-
 }
+
 res <- sienaGOF(mydata, ans,"Data1", "mynet1", triadCensus, verbose=TRUE,
  join=TRUE)
 
@@ -178,7 +176,7 @@
 
 # We can also do cumulative tests:
 outdegreeDistribution <- function(x, missingData) {
-	zeroed <- 1*( (x==1 & !missingData) )
+	zeroed <- missingsToZero(x, missingData)
 	outdegrees <- apply(zeroed,1,sum)
 	# Returns the cumulative distribution of outdegrees from levels 0 to 7
 	cumulativeOutdegrees = sapply(0:7, function(i)sum(outdegrees<=i))

Modified: pkg/RSienaTest/src/model/effects/AllEffects.h
===================================================================
--- pkg/RSienaTest/src/model/effects/AllEffects.h	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/src/model/effects/AllEffects.h	2011-03-06 03:15:22 UTC (rev 142)
@@ -32,6 +32,11 @@
 #include "DyadicCovariateMainEffect.h"
 #include "DyadicCovariateReciprocityEffect.h"
 #include "FourCyclesEffect.h"
+#include "GwespBBEffect.h"
+#include "GwespBFEffect.h"
+#include "GwespFBEffect.h"
+#include "GwespFFEffect.h"
+#include "GwespRREffect.h"
 #include "HigherCovariateEffect.h"
 #include "IndegreeEffect.h"
 #include "IndegreeActivityEffect.h"

Modified: pkg/RSienaTest/src/model/effects/EffectFactory.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/EffectFactory.cpp	2011-02-26 16:32:56 UTC (rev 141)
+++ pkg/RSienaTest/src/model/effects/EffectFactory.cpp	2011-03-06 03:15:22 UTC (rev 142)
@@ -260,6 +260,26 @@
 	{
 		pEffect = new FourCyclesEffect(pEffectInfo);
 	}
+	else if (effectName == "gwespFF")
+	{
+		pEffect = new GwespFFEffect(pEffectInfo);
+	}
+	else if (effectName == "gwespFB")
+	{
+		pEffect = new GwespFBEffect(pEffectInfo);
+	}
+	else if (effectName == "gwespBF")
+	{
+		pEffect = new GwespBFEffect(pEffectInfo);
+	}
+	else if (effectName == "gwespBB")
+	{
+		pEffect = new GwespBBEffect(pEffectInfo);
+	}
+	else if (effectName == "gwespRR")
+	{
+		pEffect = new GwespRREffect(pEffectInfo);
+	}
 	else if (effectName == "inStructEq")
 	{
 		pEffect = new InStructuralEquivalenceEffect(pEffectInfo);

Added: pkg/RSienaTest/src/model/effects/GwespBBEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespBBEffect.cpp	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespBBEffect.cpp	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespBBEffect.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * GwespBBEffect.
+ *****************************************************************************/
+
+#include "GwespBBEffect.h"
+#include "network/OneModeNetwork.h"
+#include "network/TieIterator.h"
+#include "model/variables/NetworkVariable.h"
+#include "model/tables/ConfigurationTable.h"
+#include "model/EffectInfo.h"
+#include <math.h>
+
+namespace siena
+{
+
+/**
+ * Constructor.
+ */
+GwespBBEffect::GwespBBEffect(
+	const EffectInfo * pEffectInfo) : NetworkEffect(pEffectInfo)
+{
+	this->weight = -.01 * pEffectInfo->internalEffectParameter();
+}
+
+
+/**
+ * Calculates the contribution of a tie flip to the given actor.
+ */
+double GwespBBEffect::calculateContribution(int alter) const
+{
+	return exp(this->weight * this->pReverseTwoPathTable()->get(alter) );
+}
+
+
+/**
+ * The contribution of the tie from the implicit ego to the given alter
+ * to the statistic. It is assumed that preprocessEgo(ego) has been
+ * called before.
+ */
+double GwespBBEffect::tieStatistic(int alter)
+{
+	return exp(this->weight * this->pReverseTwoPathTable()->get(alter) ) / 6.0;
+}
+
+}

Added: pkg/RSienaTest/src/model/effects/GwespBBEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespBBEffect.h	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespBBEffect.h	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespBBEffect.h
+ *
+ * Description: This file contains the declaration of the class
+ * GwespBBEffect.
+ *****************************************************************************/
+
+#ifndef GwespBBEffect_H_
+#define GwespBBEffect_H_
+
+#include "model/effects/NetworkEffect.h"
+
+namespace siena
+{
+
+/**
+ * This class defines the transitive triads effect. It is a version of the
+ * transitive triplets effect for symmetric networks.
+ */
+class GwespBBEffect : public NetworkEffect
+{
+public:
+	GwespBBEffect(const EffectInfo * pEffectInfo);
+
+	virtual double calculateContribution(int alter) const;
+
+protected:
+	virtual double tieStatistic(int alter);
+	double weight;
+};
+
+}
+
+#endif /*GwespBBEffect_H_*/

Added: pkg/RSienaTest/src/model/effects/GwespBFEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespBFEffect.cpp	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespBFEffect.cpp	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespBFEffect.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * GwespBFEffect.
+ *****************************************************************************/
+
+#include "GwespBFEffect.h"
+#include "network/OneModeNetwork.h"
+#include "network/TieIterator.h"
+#include "model/variables/NetworkVariable.h"
+#include "model/tables/ConfigurationTable.h"
+#include "model/EffectInfo.h"
+#include <math.h>
+
+namespace siena
+{
+
+/**
+ * Constructor.
+ */
+GwespBFEffect::GwespBFEffect(
+	const EffectInfo * pEffectInfo) : NetworkEffect(pEffectInfo)
+{
+	this->weight = -.01 * pEffectInfo->internalEffectParameter();
+}
+
+
+/**
+ * Calculates the contribution of a tie flip to the given actor.
+ */
+double GwespBFEffect::calculateContribution(int alter) const
+{
+	return exp(this->weight * this->pOutStarTable()->get(alter) );
+}
+
+
+/**
+ * The contribution of the tie from the implicit ego to the given alter
+ * to the statistic. It is assumed that preprocessEgo(ego) has been
+ * called before.
+ */
+double GwespBFEffect::tieStatistic(int alter)
+{
+	return exp(this->weight * this->pOutStarTable()->get(alter) ) / 6.0;
+}
+
+}

Added: pkg/RSienaTest/src/model/effects/GwespBFEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespBFEffect.h	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespBFEffect.h	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespBFEffect.h
+ *
+ * Description: This file contains the declaration of the class
+ * GwespBFEffect.
+ *****************************************************************************/
+
+#ifndef GwespBFEffect_H_
+#define GwespBFEffect_H_
+
+#include "model/effects/NetworkEffect.h"
+
+namespace siena
+{
+
+/**
+ * This class defines the transitive triads effect. It is a version of the
+ * transitive triplets effect for symmetric networks.
+ */
+class GwespBFEffect : public NetworkEffect
+{
+public:
+	GwespBFEffect(const EffectInfo * pEffectInfo);
+
+	virtual double calculateContribution(int alter) const;
+
+protected:
+	virtual double tieStatistic(int alter);
+	double weight;
+};
+
+}
+
+#endif /*GwespBFEffect_H_*/

Added: pkg/RSienaTest/src/model/effects/GwespFBEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespFBEffect.cpp	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespFBEffect.cpp	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespFBEffect.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * GwespFBEffect.
+ *****************************************************************************/
+
+#include "GwespFBEffect.h"
+#include "network/OneModeNetwork.h"
+#include "network/TieIterator.h"
+#include "model/variables/NetworkVariable.h"
+#include "model/tables/ConfigurationTable.h"
+#include "model/EffectInfo.h"
+#include <math.h>
+#include <Rinternals.h>
+
+namespace siena
+{
+
+/**
+ * Constructor.
+ */
+GwespFBEffect::GwespFBEffect(
+	const EffectInfo * pEffectInfo) : NetworkEffect(pEffectInfo)
+{
+	this->weight = -.01 * pEffectInfo->internalEffectParameter();
+}
+
+
+/**
+ * Calculates the contribution of a tie flip to the given actor.
+ */
+double GwespFBEffect::calculateContribution(int alter) const
+{
+	return exp(this->weight * this->pInStarTable()->get(alter) );
+}
+
+
+/**
+ * The contribution of the tie from the implicit ego to the given alter
+ * to the statistic. It is assumed that preprocessEgo(ego) has been
+ * called before.
+ */
+double GwespFBEffect::tieStatistic(int alter)
+{
+	return exp(this->weight * this->pInStarTable()->get(alter) ) / 6.0;
+}
+
+}

Added: pkg/RSienaTest/src/model/effects/GwespFBEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespFBEffect.h	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespFBEffect.h	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespFBEffect.h
+ *
+ * Description: This file contains the declaration of the class
+ * GwespFBEffect.
+ *****************************************************************************/
+
+#ifndef GwespFBEffect_H_
+#define GwespFBEffect_H_
+
+#include "model/effects/NetworkEffect.h"
+
+namespace siena
+{
+
+/**
+ * This class defines the transitive triads effect. It is a version of the
+ * transitive triplets effect for symmetric networks.
+ */
+class GwespFBEffect : public NetworkEffect
+{
+public:
+	GwespFBEffect(const EffectInfo * pEffectInfo);
+
+	virtual double calculateContribution(int alter) const;
+
+protected:
+	virtual double tieStatistic(int alter);
+	double weight;
+};
+
+}
+
+#endif /*GwespFBEffect_H_*/

Added: pkg/RSienaTest/src/model/effects/GwespFFEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespFFEffect.cpp	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespFFEffect.cpp	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespFFEffect.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * GwespFFEffect.
+ *****************************************************************************/
+
+#include "GwespFFEffect.h"
+#include "network/OneModeNetwork.h"
+#include "network/TieIterator.h"
+#include "model/variables/NetworkVariable.h"
+#include "model/tables/ConfigurationTable.h"
+#include "model/EffectInfo.h"
+#include <math.h>
+
+namespace siena
+{
+
+/**
+ * Constructor.
+ */
+GwespFFEffect::GwespFFEffect(
+	const EffectInfo * pEffectInfo) : NetworkEffect(pEffectInfo)
+{
+	this->weight = -.01 * pEffectInfo->internalEffectParameter();
+}
+
+
+/**
+ * Calculates the contribution of a tie flip to the given actor.
+ */
+double GwespFFEffect::calculateContribution(int alter) const
+{
+	return exp(this->weight * this->pTwoPathTable()->get(alter) );
+}
+
+
+/**
+ * The contribution of the tie from the implicit ego to the given alter
+ * to the statistic. It is assumed that preprocessEgo(ego) has been
+ * called before.
+ */
+double GwespFFEffect::tieStatistic(int alter)
+{
+	return exp(this->weight * this->pTwoPathTable()->get(alter) ) / 6.0;
+}
+
+}

Added: pkg/RSienaTest/src/model/effects/GwespFFEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespFFEffect.h	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespFFEffect.h	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespFFEffect.h
+ *
+ * Description: This file contains the declaration of the class
+ * GwespFFEffect.
+ *****************************************************************************/
+
+#ifndef GwespFFEffect_H_
+#define GwespFFEffect_H_
+
+#include "model/effects/NetworkEffect.h"
+
+namespace siena
+{
+
+/**
+ * This class defines the transitive triads effect. It is a version of the
+ * transitive triplets effect for symmetric networks.
+ */
+class GwespFFEffect : public NetworkEffect
+{
+public:
+	GwespFFEffect(const EffectInfo * pEffectInfo);
+
+	virtual double calculateContribution(int alter) const;
+
+protected:
+	virtual double tieStatistic(int alter);
+	double weight;
+};
+
+}
+
+#endif /*GwespFFEffect_H_*/

Added: pkg/RSienaTest/src/model/effects/GwespRREffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespRREffect.cpp	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespRREffect.cpp	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespRREffect.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * GwespRREffect.
+ *****************************************************************************/
+
+#include "GwespRREffect.h"
+#include "network/OneModeNetwork.h"
+#include "network/TieIterator.h"
+#include "model/variables/NetworkVariable.h"
+#include "model/tables/ConfigurationTable.h"
+#include "model/EffectInfo.h"
+#include <math.h>
+
+namespace siena
+{
+
+/**
+ * Constructor.
+ */
+GwespRREffect::GwespRREffect(
+	const EffectInfo * pEffectInfo) : NetworkEffect(pEffectInfo)
+{
+	this->weight = -.01 * pEffectInfo->internalEffectParameter();
+}
+
+
+/**
+ * Calculates the contribution of a tie flip to the given actor.
+ */
+double GwespRREffect::calculateContribution(int alter) const
+{
+	return exp(this->weight * this->pRRTable()->get(alter) );
+}
+
+
+/**
+ * The contribution of the tie from the implicit ego to the given alter
+ * to the statistic. It is assumed that preprocessEgo(ego) has been
+ * called before.
+ */
+double GwespRREffect::tieStatistic(int alter)
+{
+	return exp(this->weight * this->pRRTable()->get(alter) ) / 6.0;
+}
+
+}

Added: pkg/RSienaTest/src/model/effects/GwespRREffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/GwespRREffect.h	                        (rev 0)
+++ pkg/RSienaTest/src/model/effects/GwespRREffect.h	2011-03-06 03:15:22 UTC (rev 142)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: GwespRREffect.h
+ *
+ * Description: This file contains the declaration of the class
+ * GwespRREffect.
+ *****************************************************************************/
+
+#ifndef GwespRREffect_H_
+#define GwespRREffect_H_
+
+#include "model/effects/NetworkEffect.h"
+
+namespace siena
+{
+
+/**
+ * This class defines the transitive triads effect. It is a version of the
+ * transitive triplets effect for symmetric networks.
+ */
+class GwespRREffect : public NetworkEffect
+{
+public:
+	GwespRREffect(const EffectInfo * pEffectInfo);
+
+	virtual double calculateContribution(int alter) const;
+
+protected:
+	virtual double tieStatistic(int alter);
+	double weight;
+};
+
+}
+
+#endif /*GwespRREffect_H_*/



More information about the Rsiena-commits mailing list