[Rsiena-commits] r248 - in pkg/RSiena: . man src/model/effects src/model/variables

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 28 15:01:32 CET 2013


Author: ortmann
Date: 2013-11-28 15:01:32 +0100 (Thu, 28 Nov 2013)
New Revision: 248

Modified:
   pkg/RSiena/
   pkg/RSiena/DESCRIPTION
   pkg/RSiena/changeLog
   pkg/RSiena/man/RSiena-package.Rd
   pkg/RSiena/src/model/effects/AltersCovariateAvSimEffect.cpp
   pkg/RSiena/src/model/effects/AltersCovariateTotSimEffect.cpp
   pkg/RSiena/src/model/variables/DiffusionEffectValueTable.cpp
   pkg/RSiena/src/model/variables/EffectValueTable.cpp
Log:
update:
    - version number
bug fix:
	- ambiguous call of abs in AlterCovariateAv/TotSimEffect by
	  replacing cmath by cstdlib
	- problem with using namespace std in DiffusionEffectValueTable
	  and EffectValueTable



Property changes on: pkg/RSiena
___________________________________________________________________
Added: svn:ignore
   + .cproject

.project


Modified: pkg/RSiena/DESCRIPTION
===================================================================
--- pkg/RSiena/DESCRIPTION	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/DESCRIPTION	2013-11-28 14:01:32 UTC (rev 248)
@@ -1,7 +1,7 @@
 Package: RSiena
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.1-246
+Version: 1.1-247
 Date: 2013-10-31
 Author: Ruth Ripley, Krists Boitmanis, Tom A.B. Snijders
 Depends: R (>= 2.15.0)

Modified: pkg/RSiena/changeLog
===================================================================
--- pkg/RSiena/changeLog	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/changeLog	2013-11-28 14:01:32 UTC (rev 248)
@@ -1,3 +1,12 @@
+2013-11-28 R-Forge Revision 247
+Changes in RSiena and RSienaTest:
+	* Fix problem with std::map<int,int>::const_iterator constructor
+	  call in IncidentTieIterator.cpp
+	* Fix ambiguous call of abs in AlterCovariateAv/TotSimEffect by
+	  replacing cmath by cstdlib
+	* Fix problem with using namespace std in DiffusionEffectValueTable
+	  and EffectValueTable
+
 2013-10-31 R-Forge Revision 246
 Changes in RSiena and RSienaTest:
    * New behavior objective function effects avSimAltX, totSimAltX and

Modified: pkg/RSiena/man/RSiena-package.Rd
===================================================================
--- pkg/RSiena/man/RSiena-package.Rd	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/man/RSiena-package.Rd	2013-11-28 14:01:32 UTC (rev 248)
@@ -43,7 +43,7 @@
 \tabular{ll}{
 Package: \tab RSiena\cr
 Type: \tab Package\cr
-Version: \tab 1.1-246\cr
+Version: \tab 1.1-247\cr
 Date: \tab 2013-10-31\cr
 Depends: \tab R (>= 2.15.0)\cr
 Imports: \tab Matrix\cr

Modified: pkg/RSiena/src/model/effects/AltersCovariateAvSimEffect.cpp
===================================================================
--- pkg/RSiena/src/model/effects/AltersCovariateAvSimEffect.cpp	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/src/model/effects/AltersCovariateAvSimEffect.cpp	2013-11-28 14:01:32 UTC (rev 248)
@@ -10,7 +10,7 @@
  *****************************************************************************/
 
 #include <stdexcept>
-#include <cmath>
+#include <cstdlib>
 
 #include "AltersCovariateAvSimEffect.h"
 #include "data/Data.h"
@@ -23,55 +23,48 @@
 #include "model/EffectInfo.h"
 #include "model/variables/BehaviorVariable.h"
 
-namespace siena
-{
+namespace siena {
 
 /**
  * Constructor.
  */
 AltersCovariateAvSimEffect::AltersCovariateAvSimEffect(
-	const EffectInfo * pEffectInfo) :
-	CovariateAndNetworkBehaviorEffect(pEffectInfo)
-{
+		const EffectInfo * pEffectInfo) :
+		CovariateAndNetworkBehaviorEffect(pEffectInfo) {
 }
 
-
-
 /**
  * Calculates the change in the statistic corresponding to this effect if
  * the given actor would change his behavior by the given amount.
  */
 double AltersCovariateAvSimEffect::calculateChangeContribution(int actor,
-	int difference)
-{
+		int difference) {
 	double contribution = 0;
 	const Network * pNetwork = this->pNetwork();
-	
+
 	if (pNetwork->outDegree(actor) > 0) // otherwise, nothing to calculate...
-	{
+			{
 
-		int oldValue = this->value(actor);    // ego's behavior value before moving on behavior scale
-		int newValue = oldValue + difference;  // ego's behavior value after moving on behavior scale
+		int oldValue = this->value(actor); // ego's behavior value before moving on behavior scale
+		int newValue = oldValue + difference; // ego's behavior value after moving on behavior scale
 		double totalChange = 0;                   // will keep track of changes
 
 		for (IncidentTieIterator iter = pNetwork->outTies(actor); // loops over outgoing ties of ego
-			iter.valid();
-			iter.next())
-		{
+		iter.valid(); iter.next()) {
 			int j = iter.actor();                // identifies alter
-			int alterValue = this->value(j);    // identifies behavior value of alter
-			int change =
-				abs(oldValue - alterValue) - abs(newValue - alterValue);
-				                                 // calculates impact of ego's movement on absolute difference to alter
+			int alterValue = this->value(j); // identifies behavior value of alter
+			int change = std::abs(oldValue - alterValue)
+					- std::abs(newValue - alterValue);
+			// calculates impact of ego's movement on absolute difference to alter
 
 			totalChange += change * this->covariateValue(j); // weighting change statistic acc. to covariate value of alter
 		}
 
 		contribution = totalChange / this->range(); // standardize by behavior range for SIMILARITY function
 
-		contribution /= pNetwork->outDegree(actor);  // divide by outdegree to get AVERAGE similarity change statistic
+		contribution /= pNetwork->outDegree(actor); // divide by outdegree to get AVERAGE similarity change statistic
 
-	}	
+	}
 
 	return contribution;
 
@@ -81,80 +74,71 @@
  * Returns the statistic corresponding to the given ego with respect to the
  * given values of the behavior variable.
  */
-double AltersCovariateAvSimEffect::egoStatistic(int ego, double * currentValues)
-{
+double AltersCovariateAvSimEffect::egoStatistic(int ego,
+		double * currentValues) {
 	const Network * pNetwork = this->pNetwork();
 
 	double statistic = 0;
 	int neighborCount = 0;
 
-	for (IncidentTieIterator iter = pNetwork->outTies(ego);
-		 iter.valid();
-		 iter.next())
-	{
+	for (IncidentTieIterator iter = pNetwork->outTies(ego); iter.valid();
+			iter.next()) {
 		int j = iter.actor();
 
-		if (!this->missing(this->period(), j) &&
-			!this->missing(this->period() + 1, j) &&
-			!this->missingCovariate(j,this->period()))
-		{
-			double tieStatistic =
-				this->similarity(currentValues[ego], currentValues[j]);
+		if (!this->missing(this->period(), j)
+				&& !this->missing(this->period() + 1, j)
+				&& !this->missingCovariate(j, this->period())) {
+			double tieStatistic = this->similarity(currentValues[ego],
+					currentValues[j]);
 
 			statistic += tieStatistic * this->covariateValue(j);
 			neighborCount++;
 		}
 	}
 
-	if (neighborCount > 0) 
-	{
+	if (neighborCount > 0) {
 		statistic /= neighborCount;
 	}
-	
+
 	return statistic;
 }
 
-
 /**
  * Returns the statistic corresponding to the given ego as part of
  * the endowment function with respect to the initial values of a
  * behavior variable and the current values.
  */
 double AltersCovariateAvSimEffect::egoEndowmentStatistic(int ego,
-	const int * difference,
-	double * currentValues)
-{
+		const int * difference, double * currentValues) {
 	double statistic = 0;
 	const Network * pNetwork = this->pNetwork();
 
-	if (difference[ego] > 0 && !this->missingDummy(ego) && (pNetwork->outDegree(ego) > 0)) // otherwise, nothing to calculate...
-	{
+	if (difference[ego] > 0 && !this->missingDummy(ego)
+			&& (pNetwork->outDegree(ego) > 0)) // otherwise, nothing to calculate...
+			{
 
-		int oldValue = this->value(ego);    // ego's behavior value before moving on behavior scale
-		int newValue = oldValue + difference[ego];  // ego's behavior value after moving on behavior scale
+		int oldValue = this->value(ego); // ego's behavior value before moving on behavior scale
+		int newValue = oldValue + difference[ego]; // ego's behavior value after moving on behavior scale
 		double totalChange = 0;                   // will keep track of changes
 
 		for (IncidentTieIterator iter = pNetwork->outTies(ego); // loops over outgoing ties of ego
-			iter.valid();
-			iter.next())
-		{
+		iter.valid(); iter.next()) {
 			int j = iter.actor();                // identifies alter
-			int alterValue = this->value(j);    // identifies behavior value of alter
-			int change =
-				abs(oldValue - alterValue) - abs(newValue - alterValue);
-				                                 // calculates impact of ego's movement on absolute difference to alter
+			int alterValue = this->value(j); // identifies behavior value of alter
+			int change = std::abs(oldValue - alterValue)
+					- std::abs(newValue - alterValue);
+			// calculates impact of ego's movement on absolute difference to alter
 
 			totalChange += change * this->covariateValue(j); // weighting change statistic acc. to covariate value of alter
 		}
 
 		statistic -= totalChange / this->range(); // standardize by behavior range for SIMILARITY function
 
-		statistic /= pNetwork->outDegree(ego);  // divide by outdegree to get AVERAGE similarity change statistic
-	
+		statistic /= pNetwork->outDegree(ego); // divide by outdegree to get AVERAGE similarity change statistic
+
 	}
 
 	return statistic;
 }
 
-
 }

Modified: pkg/RSiena/src/model/effects/AltersCovariateTotSimEffect.cpp
===================================================================
--- pkg/RSiena/src/model/effects/AltersCovariateTotSimEffect.cpp	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/src/model/effects/AltersCovariateTotSimEffect.cpp	2013-11-28 14:01:32 UTC (rev 248)
@@ -10,7 +10,7 @@
  *****************************************************************************/
 
 #include <stdexcept>
-#include <cmath>
+#include <cstdlib>
 
 #include "AltersCovariateTotSimEffect.h"
 #include "data/Data.h"
@@ -23,53 +23,46 @@
 #include "model/EffectInfo.h"
 #include "model/variables/BehaviorVariable.h"
 
-namespace siena
-{
+namespace siena {
 
 /**
  * Constructor.
  */
 AltersCovariateTotSimEffect::AltersCovariateTotSimEffect(
-	const EffectInfo * pEffectInfo) :
-	CovariateAndNetworkBehaviorEffect(pEffectInfo)
-{
+		const EffectInfo * pEffectInfo) :
+		CovariateAndNetworkBehaviorEffect(pEffectInfo) {
 }
 
-
-
 /**
  * Calculates the change in the statistic corresponding to this effect if
  * the given actor would change his behavior by the given amount.
  */
 double AltersCovariateTotSimEffect::calculateChangeContribution(int actor,
-	int difference)
-{
+		int difference) {
 	double contribution = 0;
 	const Network * pNetwork = this->pNetwork();
-	
+
 	if (pNetwork->outDegree(actor) > 0) // otherwise, nothing to calculate...
-	{
+			{
 
-		int oldValue = this->value(actor);    // ego's behavior value before moving on behavior scale
-		int newValue = oldValue + difference;  // ego's behavior value after moving on behavior scale
+		int oldValue = this->value(actor); // ego's behavior value before moving on behavior scale
+		int newValue = oldValue + difference; // ego's behavior value after moving on behavior scale
 		double totalChange = 0;                   // will keep track of changes
 
 		for (IncidentTieIterator iter = pNetwork->outTies(actor); // loops over outgoing ties of ego
-			iter.valid();
-			iter.next())
-		{
+		iter.valid(); iter.next()) {
 			int j = iter.actor();                // identifies alter
-			int alterValue = this->value(j);    // identifies behavior value of alter
-			int change =
-				abs(oldValue - alterValue) - abs(newValue - alterValue);
-				                                 // calculates impact of ego's movement on absolute difference to alter
+			int alterValue = this->value(j); // identifies behavior value of alter
+			int change = std::abs(oldValue - alterValue)
+					- std::abs(newValue - alterValue);
+			// calculates impact of ego's movement on absolute difference to alter
 
 			totalChange += change * this->covariateValue(j); // weighting change statistic acc. to covariate value of alter
 		}
 
 		contribution = ((double) totalChange) / this->range(); // standardize by behavior range for SIMILARITY function
 
-	}	
+	}
 
 	return contribution;
 
@@ -79,71 +72,63 @@
  * Returns the statistic corresponding to the given ego with respect to the
  * given values of the behavior variable.
  */
-double AltersCovariateTotSimEffect::egoStatistic(int ego, double * currentValues)
-{
+double AltersCovariateTotSimEffect::egoStatistic(int ego,
+		double * currentValues) {
 	const Network * pNetwork = this->pNetwork();
 
 	double statistic = 0;
-	
-	for (IncidentTieIterator iter = pNetwork->outTies(ego);
-		 iter.valid();
-		 iter.next())
-	{
+
+	for (IncidentTieIterator iter = pNetwork->outTies(ego); iter.valid();
+			iter.next()) {
 		int j = iter.actor();
 
-		if (!this->missing(this->period(), j) &&
-			!this->missing(this->period() + 1, j) &&
-			!this->missingCovariate(j,this->period()))
-		{
-			double tieStatistic =
-				this->similarity(currentValues[ego], currentValues[j]);
+		if (!this->missing(this->period(), j)
+				&& !this->missing(this->period() + 1, j)
+				&& !this->missingCovariate(j, this->period())) {
+			double tieStatistic = this->similarity(currentValues[ego],
+					currentValues[j]);
 
 			statistic += tieStatistic * this->covariateValue(j);
 		}
 	}
-	
+
 	return statistic;
 }
 
-
 /**
  * Returns the statistic corresponding to the given ego as part of
  * the endowment function with respect to the initial values of a
  * behavior variable and the current values.
  */
 double AltersCovariateTotSimEffect::egoEndowmentStatistic(int ego,
-	const int * difference,
-	double * currentValues)
-{
+		const int * difference, double * currentValues) {
 	double statistic = 0;
 	const Network * pNetwork = this->pNetwork();
 
-	if (difference[ego] > 0 && !this->missingDummy(ego) && (pNetwork->outDegree(ego) > 0)) // otherwise, nothing to calculate...
-	{
+	if (difference[ego] > 0 && !this->missingDummy(ego)
+			&& (pNetwork->outDegree(ego) > 0)) // otherwise, nothing to calculate...
+			{
 
-		int oldValue = this->value(ego);    // ego's behavior value before moving on behavior scale
-		int newValue = oldValue + difference[ego];  // ego's behavior value after moving on behavior scale
+		int oldValue = this->value(ego); // ego's behavior value before moving on behavior scale
+		int newValue = oldValue + difference[ego]; // ego's behavior value after moving on behavior scale
 		double totalChange = 0;                   // will keep track of changes
 
 		for (IncidentTieIterator iter = pNetwork->outTies(ego); // loops over outgoing ties of ego
-			iter.valid();
-			iter.next())
-		{
+		iter.valid(); iter.next()) {
 			int j = iter.actor();                // identifies alter
-			int alterValue = this->value(j);    // identifies behavior value of alter
-			int change =
-				abs(oldValue - alterValue) - abs(newValue - alterValue);
-				                                 // calculates impact of ego's movement on absolute difference to alter
+			int alterValue = this->value(j); // identifies behavior value of alter
+			int change = std::abs(oldValue - alterValue)
+					- std::abs(newValue - alterValue);
+			// calculates impact of ego's movement on absolute difference to alter
 
 			totalChange += change * this->covariateValue(j); // weighting change statistic acc. to covariate value of alter
 		}
 
 		statistic -= totalChange / this->range(); // standardize by behavior range for SIMILARITY function
-	
+
 	}
 
 	return statistic;
 }
 
-
 }

Modified: pkg/RSiena/src/model/variables/DiffusionEffectValueTable.cpp
===================================================================
--- pkg/RSiena/src/model/variables/DiffusionEffectValueTable.cpp	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/src/model/variables/DiffusionEffectValueTable.cpp	2013-11-28 14:01:32 UTC (rev 248)
@@ -8,20 +8,17 @@
  * Description: This file contains the implementation of the
  * DiffusionEffectValueTable class.
  *****************************************************************************/
-using namespace std;
 #include <cmath>
 #include "DiffusionEffectValueTable.h"
 
-namespace siena
-{
+namespace siena {
 
 /**
  * Creates a new look-up table for <i>n</i> actors.
  */
 
 DiffusionEffectValueTable::DiffusionEffectValueTable(int numeratorRange,
-						     int denominatorRange)
-{
+		int denominatorRange) {
 	this->lvalues = new double[numeratorRange * denominatorRange];
 	this->lparameterValues = new double[numeratorRange * denominatorRange];
 
@@ -31,8 +28,7 @@
 	this->ldenominatorRange = denominatorRange;
 	this->lnumeratorRange = numeratorRange;
 
-	for (int i = 0; i < numeratorRange * denominatorRange; i++)
-	{
+	for (int i = 0; i < numeratorRange * denominatorRange; i++) {
 		// exp(0) = 1
 
 		this->lvalues[i] = 1;
@@ -43,8 +39,7 @@
 /**
  * Deallocates this look-up table.
  */
-DiffusionEffectValueTable::~DiffusionEffectValueTable()
-{
+DiffusionEffectValueTable::~DiffusionEffectValueTable() {
 	delete[] this->lvalues;
 	delete[] this->lparameterValues;
 
@@ -52,41 +47,34 @@
 	this->lparameterValues = 0;
 }
 
-
 /**
  * Returns the current value of the effect parameter.
  */
-double DiffusionEffectValueTable::parameter() const
-{
+double DiffusionEffectValueTable::parameter() const {
 	return this->lparameter;
 }
 
-
 /**
  * Stores the effect parameter.
  */
-void DiffusionEffectValueTable::parameter(double value)
-{
+void DiffusionEffectValueTable::parameter(double value) {
 	this->lparameter = value;
 }
 
-
 /**
  * Returns the value of the effect.
  */
 
-double DiffusionEffectValueTable::value(int numerator, int denominator)
-{
-	int arrayIndex = ((numerator - 1) * this->ldenominatorRange) +
-		(denominator - 1);
+double DiffusionEffectValueTable::value(int numerator, int denominator) {
+	int arrayIndex = ((numerator - 1) * this->ldenominatorRange)
+			+ (denominator - 1);
 
-	if (this->lparameterValues[arrayIndex] != this->lparameter)
-	{
+	if (this->lparameterValues[arrayIndex] != this->lparameter) {
 		// The value stored in the table was calculated for a different
 		// parameter, hence we must recalculate the value.
 
-		this->lvalues[arrayIndex] = exp(this->lparameter *
-			(double)numerator / (double)denominator);
+		this->lvalues[arrayIndex] = std::exp(
+				this->lparameter * (double) numerator / (double) denominator);
 		this->lparameterValues[arrayIndex] = this->lparameter;
 	}
 

Modified: pkg/RSiena/src/model/variables/EffectValueTable.cpp
===================================================================
--- pkg/RSiena/src/model/variables/EffectValueTable.cpp	2013-11-28 13:54:20 UTC (rev 247)
+++ pkg/RSiena/src/model/variables/EffectValueTable.cpp	2013-11-28 14:01:32 UTC (rev 248)
@@ -8,19 +8,16 @@
  * Description: This file contains the implementation of the
  * EffectValueTable class.
  *****************************************************************************/
-using namespace std;
 #include <cmath>
 
 #include "EffectValueTable.h"
 
-namespace siena
-{
+namespace siena {
 
 /**
  * Creates a new look-up table for <i>n</i> actors and the given function.
  */
-EffectValueTable::EffectValueTable(int n, double (* pFunction)(int))
-{
+EffectValueTable::EffectValueTable(int n, double (*pFunction)(int)) {
 	this->lpFunction = pFunction;
 	this->lvalues = new double[n];
 	this->lparameterValues = new double[n];
@@ -29,8 +26,7 @@
 
 	this->lparameter = 0;
 
-	for (int i = 0; i < n; i++)
-	{
+	for (int i = 0; i < n; i++) {
 		// exp(0) = 1
 
 		this->lvalues[i] = 1;
@@ -38,12 +34,10 @@
 	}
 }
 
-
 /**
  * Deallocates this look-up table.
  */
-EffectValueTable::~EffectValueTable()
-{
+EffectValueTable::~EffectValueTable() {
 	delete[] this->lvalues;
 	delete[] this->lparameterValues;
 
@@ -52,36 +46,29 @@
 	this->lpFunction = 0;
 }
 
-
 /**
  * Returns the current value of the effect parameter.
  */
-double EffectValueTable::parameter() const
-{
+double EffectValueTable::parameter() const {
 	return this->lparameter;
 }
 
-
 /**
  * Stores the effect parameter.
  */
-void EffectValueTable::parameter(double value)
-{
+void EffectValueTable::parameter(double value) {
 	this->lparameter = value;
 }
 
-
 /**
  * Returns the value of the effect for the argument <i>i</i>.
  */
-double EffectValueTable::value(int i)
-{
-	if (this->lparameterValues[i] != this->lparameter)
-	{
+double EffectValueTable::value(int i) {
+	if (this->lparameterValues[i] != this->lparameter) {
 		// The value stored in the table was calculated for a different
 		// parameter, hence we must recalculate the value.
 
-		this->lvalues[i] = exp(this->lparameter * this->lpFunction(i));
+		this->lvalues[i] = std::exp(this->lparameter * this->lpFunction(i));
 		this->lparameterValues[i] = this->lparameter;
 	}
 



More information about the Rsiena-commits mailing list