[Rsiena-commits] r31 - in pkg/RSienaTest: R data src/model src/model/effects
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Dec 31 17:22:27 CET 2009
Author: ripleyrm
Date: 2009-12-31 17:22:27 +0100 (Thu, 31 Dec 2009)
New Revision: 31
Added:
pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.cpp
pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.h
pkg/RSienaTest/src/model/effects/CovariateDependentBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/CovariateDependentBehaviorEffect.h
pkg/RSienaTest/src/model/effects/DenseTriadsBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/DenseTriadsBehaviorEffect.h
pkg/RSienaTest/src/model/effects/DenseTriadsSimilarityEffect.cpp
pkg/RSienaTest/src/model/effects/DenseTriadsSimilarityEffect.h
pkg/RSienaTest/src/model/effects/InteractionCovariateEffect.cpp
pkg/RSienaTest/src/model/effects/InteractionCovariateEffect.h
pkg/RSienaTest/src/model/effects/IsolateEffect.cpp
pkg/RSienaTest/src/model/effects/IsolateEffect.h
pkg/RSienaTest/src/model/effects/MainCovariateEffect.cpp
pkg/RSienaTest/src/model/effects/MainCovariateEffect.h
pkg/RSienaTest/src/model/effects/PopularityAlterEffect.cpp
pkg/RSienaTest/src/model/effects/PopularityAlterEffect.h
pkg/RSienaTest/src/model/effects/ReciprocalDegreeBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/ReciprocalDegreeBehaviorEffect.h
pkg/RSienaTest/src/model/effects/ReciprocatedSimilarityEffect.cpp
pkg/RSienaTest/src/model/effects/ReciprocatedSimilarityEffect.h
pkg/RSienaTest/src/model/effects/SimilarityEffect.cpp
pkg/RSienaTest/src/model/effects/SimilarityEffect.h
Removed:
pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.cpp
pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.h
pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.h
pkg/RSienaTest/src/model/effects/BehaviorMainBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/BehaviorMainBehaviorEffect.h
pkg/RSienaTest/src/model/effects/ChangingCovariateBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/ChangingCovariateBehaviorEffect.h
pkg/RSienaTest/src/model/effects/ChangingCovariateMainBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/ChangingCovariateMainBehaviorEffect.h
pkg/RSienaTest/src/model/effects/ConstantCovariateBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/ConstantCovariateBehaviorEffect.h
pkg/RSienaTest/src/model/effects/ConstantCovariateMainBehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/ConstantCovariateMainBehaviorEffect.h
pkg/RSienaTest/src/model/effects/TotalSimilarityEffect.cpp
pkg/RSienaTest/src/model/effects/TotalSimilarityEffect.h
Modified:
pkg/RSienaTest/R/effects.r
pkg/RSienaTest/R/print07Report.r
pkg/RSienaTest/R/simstatsc.r
pkg/RSienaTest/data/allEffects.csv
pkg/RSienaTest/src/model/EffectInfo.cpp
pkg/RSienaTest/src/model/EffectInfo.h
pkg/RSienaTest/src/model/effects/AllEffects.h
pkg/RSienaTest/src/model/effects/AverageAlterEffect.cpp
pkg/RSienaTest/src/model/effects/AverageAlterEffect.h
pkg/RSienaTest/src/model/effects/BehaviorEffect.cpp
pkg/RSienaTest/src/model/effects/BehaviorEffect.h
pkg/RSienaTest/src/model/effects/EffectFactory.cpp
pkg/RSienaTest/src/model/effects/IndegreeEffect.cpp
pkg/RSienaTest/src/model/effects/IndegreeEffect.h
pkg/RSienaTest/src/model/effects/LinearShapeEffect.cpp
pkg/RSienaTest/src/model/effects/LinearShapeEffect.h
pkg/RSienaTest/src/model/effects/OutdegreeEffect.cpp
pkg/RSienaTest/src/model/effects/OutdegreeEffect.h
pkg/RSienaTest/src/model/effects/QuadraticShapeEffect.cpp
pkg/RSienaTest/src/model/effects/QuadraticShapeEffect.h
Log:
Behavior effects additions, alterations
Modified: pkg/RSienaTest/R/effects.r
===================================================================
--- pkg/RSienaTest/R/effects.r 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/R/effects.r 2009-12-31 16:22:27 UTC (rev 31)
@@ -686,12 +686,12 @@
}
}
}
- if (!is.null(covObjEffects))
- {
- usestr <- paste("effFrom", type, sep="")
- covObjEffects$shortName <-
- sub("effFrom", usestr, covObjEffects$shortName)
- }
+ # if (!is.null(covObjEffects))
+ # {
+ # usestr <- paste("effFrom", type, sep="")
+ # covObjEffects$shortName <-
+ # sub("effFrom", usestr, covObjEffects$shortName)
+ # }
list(objEff=covObjEffects, rateEff=covRateEffects)
}
Modified: pkg/RSienaTest/R/print07Report.r
===================================================================
--- pkg/RSienaTest/R/print07Report.r 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/R/print07Report.r 2009-12-31 16:22:27 UTC (rev 31)
@@ -58,14 +58,14 @@
tmp <- paste(' 0.', nnstr, ' Rate parameter period ',
1:nn, ' ',
format(round(z$rate,4),width=9),
- ' (',format(round(z$vrate,4),width=9),
+ ' (',format(round(sqrt(z$vrate),4),width=9),
')\n', sep = '')
} else{
tmp <- paste(' 0.', nnstr,
'Rate parameter cond. variable period ',
1:nn, ' ',
format(round(z$rate,4),width=9),
- ' (',format(round(z$vrate,4),width=9),
+ ' (',format(round(sqrt(z$vrate),4),width=9),
')\n', sep='')
}
Report(tmp, outf, sep='')
Modified: pkg/RSienaTest/R/simstatsc.r
===================================================================
--- pkg/RSienaTest/R/simstatsc.r 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/R/simstatsc.r 2009-12-31 16:22:27 UTC (rev 31)
@@ -3,7 +3,7 @@
# *
# * Web: http://www.stats.ox.ac.uk/~snidjers/siena
# *
-# * File: siena01.r
+# * File: simstatsc.r
# *
# * Description: This module contains the code for simulating the process,
# * communicating with C++.
Modified: pkg/RSienaTest/data/allEffects.csv
===================================================================
--- pkg/RSienaTest/data/allEffects.csv 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/data/allEffects.csv 2009-12-31 16:22:27 UTC (rev 31)
@@ -3,18 +3,18 @@
behaviorOneModeObjective,behavior xxxxxx total similarity,beh. xxxxxx total similarity ,totSim,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
behaviorOneModeObjective,behavior xxxxxx indegree,beh. xxxxxx indegrees ,indeg,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
behaviorOneModeObjective,behavior xxxxxx outdegree,beh. xxxxxx outdegrees ,outdeg,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx isolate,beh. xxxxxx isolate ,isolate,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx ave. sim. x reciprocity,beh. xxxxxx ave. similarity x reciprocity ,avSimRecip,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx tot. sim. x reciprocity,beh. xxxxxx tot. similarity x reciprocity ,totSimRecip,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx ave. sim. x popularity alter,beh. xxxxxx ave. sim. x indegrees(one-sided) ,avSimPopAlt,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx tot. sim. x popularity alter,beh. xxxxxx tot. sim. x indegrees(one-sided) ,totSimPopAlt,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx ave. sim. x rec. x pop. (alter),beh. xxxxxx ave. sim. x rec. x i.d.(one-sided) ,avSimRecPop,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx tot. sim. x rec. x pop. (alter),beh. xxxxxx tot. sim. x rec. x i.d.(one-sided) ,totSimRecPop,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx isolate,beh. xxxxxx isolate ,isolate,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx ave. sim. x reciprocity,beh. xxxxxx ave. similarity x reciprocity ,avSimRecip,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx tot. sim. x reciprocity,beh. xxxxxx tot. similarity x reciprocity ,totSimRecip,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx ave. sim. x popularity alter,beh. xxxxxx ave. sim. x indegrees(one-sided) ,avSimPopAlt,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx tot. sim. x popularity alter,beh. xxxxxx tot. sim. x indegrees(one-sided) ,totSimPopAlt,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx ave. sim. x rec. x pop. (alter),beh. xxxxxx ave. sim. x rec. x i.d.(one-sided) ,avSimRecPop,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx tot. sim. x rec. x pop. (alter),beh. xxxxxx tot. sim. x rec. x i.d.(one-sided) ,totSimRecPop,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
behaviorOneModeObjective,behavior xxxxxx average alter,beh. xxxxxx average alters ,avAlt,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx average rec. alters,beh. xxxxxx average rec. alters ,avRecAlt,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx dense triads <maybe wrong>,beh. xxxxxx dense triads <<<maybe wrong>>> ,behDenseTriads,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx similarity in dense triads <maybe wrong>,beh. xxxxxx homogeneity of dense triads <<<maybe wrong>>> ,simDenseTriads,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-behaviorOneModeObjective,behavior xxxxxx reciprocated degree,beh. xxxxxx reciprocated degrees ,recipDeg,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx average rec. alters,beh. xxxxxx average rec. alters ,avRecAlt,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx dense triads <maybe wrong>,beh. xxxxxx dense triads <<<maybe wrong>>> ,behDenseTriads,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,5,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx similarity in dense triads <maybe wrong>,beh. xxxxxx homogeneity of dense triads <<<maybe wrong>>> ,simDenseTriads,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,5,objective,NA,NA,0,,,,
+behaviorOneModeObjective,behavior xxxxxx reciprocated degree,beh. xxxxxx reciprocated degrees ,recipDeg,FALSE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
behaviorOneModeObjective,behavior xxxxxx ave. sim. x popularity ego,beh. xxxxxx ave. sim. x indegrees ego ,avSimPopEgo,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
behaviorOneModeObjective2,behavior xxxxxx: infl. one-sided ? x xxxxxx alter,beh. xxxxxx: infl. interaction? x xxxxxx alter,behInfl1sid,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
behaviorBipartiteObjective,behavior xxxxxx average similarity,beh. xxxxxx average similarity ,avSim,TRUE,yyyyyy,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
@@ -101,8 +101,8 @@
nonSymmetricObjective,transitive ties,Number of ties with transitive closure,transTies,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
nonSymmetricObjective,betweenness,betweenness count,between,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
nonSymmetricObjective,balance,Amount of balance,balance,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-nonSymmetricObjective,number of actors at distance 2,Number of directed distances equal to 2,nbrDist2,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
-nonSymmetricObjective,number pairs at doubly achieved distance 2,Number of doubly achieved distances 2,nbrDist2twice,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+nonSymmetricObjective,number of actors at distance 2,Number of directed distances equal to 2,nbrDist2,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
+nonSymmetricObjective,number pairs at doubly achieved distance 2,Number of doubly achieved distances 2,nbrDist2twice,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
nonSymmetricObjective,dense triads,Sum of triads with # or more ties,denseTriads,FALSE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,5,objective,NA,NA,0,,,,
nonSymmetricObjective,indegree - popularity,Sum of squared indegrees,inPop,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
nonSymmetricObjective,indegree - popularity (sqrt),Sum of indegrees x sqrt(indegree),inPopSqrt,TRUE,,,eval,FALSE,FALSE,FALSE,FALSE,FALSE,0,0,objective,NA,NA,0,,,,
Modified: pkg/RSienaTest/src/model/EffectInfo.cpp
===================================================================
--- pkg/RSienaTest/src/model/EffectInfo.cpp 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/EffectInfo.cpp 2009-12-31 16:22:27 UTC (rev 31)
@@ -146,6 +146,16 @@
/**
+ * Returns the name of the other variable or covariate this effect interacts with,
+ * if the effect has two such interactions.
+ */
+string EffectInfo::interactionName2() const
+{
+ return this->linteractionName2;
+}
+
+
+/**
* Returns the type of rate effect of this effect. Blank if not a rate effect,
* values "structural" or "covariate".
*/
Modified: pkg/RSienaTest/src/model/EffectInfo.h
===================================================================
--- pkg/RSienaTest/src/model/EffectInfo.h 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/EffectInfo.h 2009-12-31 16:22:27 UTC (rev 31)
@@ -49,6 +49,7 @@
double parameter() const;
double internalEffectParameter() const;
string interactionName1() const;
+ string interactionName2() const;
string rateType() const;
const EffectInfo * pEffectInfo1() const;
const EffectInfo * pEffectInfo2() const;
Modified: pkg/RSienaTest/src/model/effects/AllEffects.h
===================================================================
--- pkg/RSienaTest/src/model/effects/AllEffects.h 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/AllEffects.h 2009-12-31 16:22:27 UTC (rev 31)
@@ -13,31 +13,34 @@
#define ALLEFFECTS_H_
#include "AverageAlterEffect.h"
-#include "AverageSimilarityEffect.h"
+#include "AverageReciprocatedAlterEffect.h"
#include "BalanceEffect.h"
-#include "BehaviorMainBehaviorEffect.h"
#include "BetweennessEffect.h"
-#include "ChangingCovariateMainBehaviorEffect.h"
-#include "ConstantCovariateMainBehaviorEffect.h"
#include "CovariateAlterEffect.h"
#include "CovariateEgoAlterEffect.h"
#include "CovariateEgoEffect.h"
#include "CovariateIndirectTiesEffect.h"
#include "CovariateSimilarityEffect.h"
+#include "DenseTriadsBehaviorEffect.h"
#include "DenseTriadsEffect.h"
+#include "DenseTriadsSimilarityEffect.h"
#include "DensityEffect.h"
#include "DistanceTwoEffect.h"
#include "DyadicCovariateMainEffect.h"
#include "DyadicCovariateReciprocityEffect.h"
#include "FourCyclesEffect.h"
+#include "HigherCovariateEffect.h"
#include "IndegreeEffect.h"
#include "IndegreeActivityEffect.h"
#include "IndegreePopularityEffect.h"
#include "InInDegreeAssortativityEffect.h"
#include "InOutDegreeAssortativityEffect.h"
+#include "InteractionCovariateEffect.h"
#include "InverseOutdegreeEffect.h"
#include "InverseSquaredOutdegreeEffect.h"
+#include "IsolateEffect.h"
#include "LinearShapeEffect.h"
+#include "MainCovariateEffect.h"
#include "NetworkInteractionEffect.h"
#include "OutdegreeEffect.h"
#include "OutdegreeActivityEffect.h"
@@ -46,10 +49,12 @@
#include "OutInDegreeAssortativityEffect.h"
#include "OutOutDegreeAssortativityEffect.h"
#include "QuadraticShapeEffect.h"
+#include "ReciprocalDegreeBehaviorEffect.h"
+#include "ReciprocatedSimilarityEffect.h"
#include "ReciprocityEffect.h"
#include "SameCovariateEffect.h"
+#include "SimilarityEffect.h"
#include "ThreeCyclesEffect.h"
-#include "TotalSimilarityEffect.h"
#include "TransitiveMediatedTripletsEffect.h"
#include "TransitiveTiesEffect.h"
#include "TransitiveTriadsEffect.h"
Modified: pkg/RSienaTest/src/model/effects/AverageAlterEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/AverageAlterEffect.cpp 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/AverageAlterEffect.cpp 2009-12-31 16:22:27 UTC (rev 31)
@@ -35,7 +35,7 @@
* the given actor would change his behavior by the given amount.
*/
double AverageAlterEffect::calculateChangeContribution(int actor,
- int difference) const
+ int difference)
{
double contribution = 0;
const Network * pNetwork = this->pNetwork();
@@ -49,17 +49,17 @@
// This is d * avg(v_j), the average being taken over all neighbors
// of i. This is what is calculated below.
- double averageAlterChange = 0;
+ double totalAlterValue = 0;
for (IncidentTieIterator iter = pNetwork->outTies(actor);
iter.valid();
iter.next())
{
double alterValue = this->centeredValue(iter.actor());
- averageAlterChange += alterValue;
+ totalAlterValue += alterValue;
}
- contribution = difference * averageAlterChange /
+ contribution = difference * totalAlterValue /
pNetwork->outDegree(actor);
}
@@ -68,45 +68,46 @@
/**
- * Returns the statistic corresponding to this effect as part of
- * the evaluation function with respect to the given behavior variable.
+ * Returns the statistic corresponding to the given ego with respect to the
+ * given values of the behavior variable.
*/
-double AverageAlterEffect::evaluationStatistic(double * currentValues) const
+double AverageAlterEffect::egoStatistic(int i, double * currentValues)
{
double statistic = 0;
- int n = this->n();
const Network * pNetwork = this->pNetwork();
+ int neighborCount = 0;
- for (int i = 0; i < n; i++)
+ for (IncidentTieIterator iter = pNetwork->outTies(i);
+ iter.valid();
+ iter.next())
{
- if (pNetwork->outDegree(i))
+ int j = iter.actor();
+
+ if (!this->missing(this->period(), j) &&
+ !this->missing(this->period() + 1, j))
{
- double thisStatistic = 0;
-
- for (IncidentTieIterator iter = pNetwork->outTies(i);
- iter.valid();
- iter.next())
- {
- double alterValue = currentValues[iter.actor()];
- thisStatistic += iter.value() * alterValue;
- }
-
- thisStatistic *= currentValues[i] / pNetwork->outDegree(i);
- statistic += thisStatistic;
+ statistic += currentValues[j];
+ neighborCount++;
}
}
+ if (neighborCount > 0)
+ {
+ statistic *= currentValues[i] / neighborCount;
+ }
+
return statistic;
}
+
/**
* Returns the statistic corresponding to this effect as part of
* the endowment function with respect to the initial values of a
* behavior variable and the current values.
*/
double AverageAlterEffect::endowmentStatistic(const int * difference,
- double * currentValues) const
+ double * currentValues)
{
double statistic = 0;
int n = this->n();
Modified: pkg/RSienaTest/src/model/effects/AverageAlterEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/AverageAlterEffect.h 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/AverageAlterEffect.h 2009-12-31 16:22:27 UTC (rev 31)
@@ -21,16 +21,16 @@
* Average alter effect defined as the product of the ego with the average
* of its neighbors (with respect to a certain network).
*/
- class AverageAlterEffect : public NetworkDependentBehaviorEffect
+class AverageAlterEffect : public NetworkDependentBehaviorEffect
{
public:
AverageAlterEffect(const EffectInfo * pEffectInfo);
virtual double calculateChangeContribution(int actor,
- int difference) const;
- virtual double evaluationStatistic(double * currentValues) const;
+ int difference);
virtual double endowmentStatistic(const int * difference,
- double * currentValues) const;
+ double * currentValues);
+ virtual double egoStatistic(int ego, double * currentValues);
};
}
Added: pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.cpp (rev 0)
+++ pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.cpp 2009-12-31 16:22:27 UTC (rev 31)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: AverageReciprocatedAlterEffect.cpp
+ *
+ * Description: This file contains the implementation of the
+ * AverageReciprocatedAlterEffect class.
+ *****************************************************************************/
+
+#include <stdexcept>
+#include "AverageReciprocatedAlterEffect.h"
+#include "network/CommonNeighborIterator.h"
+#include "network/OneModeNetwork.h"
+
+using namespace std;
+
+namespace siena
+{
+
+/**
+ * Constructor.
+ */
+AverageReciprocatedAlterEffect::AverageReciprocatedAlterEffect(
+ const EffectInfo * pEffectInfo) :
+ NetworkDependentBehaviorEffect(pEffectInfo)
+{
+}
+
+
+/**
+ * Calculates the change in the statistic corresponding to this effect if
+ * the given actor would change his behavior by the given amount.
+ */
+double AverageReciprocatedAlterEffect::calculateChangeContribution(int actor,
+ int difference)
+{
+ double contribution = 0;
+ const OneModeNetwork * pNetwork =
+ dynamic_cast<const OneModeNetwork *>(this->pNetwork());
+
+ if (!pNetwork)
+ {
+ throw runtime_error(string("One-mode network expected in ") +
+ "AverageReciprocatedAlterEffect");
+ }
+
+ if (pNetwork->reciprocalDegree(actor) > 0)
+ {
+ double totalAlterValue = 0;
+
+ for (CommonNeighborIterator iter = pNetwork->reciprocatedTies(actor);
+ iter.valid();
+ iter.next())
+ {
+ double alterValue = this->centeredValue(iter.actor());
+ totalAlterValue += alterValue;
+ }
+
+ contribution = difference * totalAlterValue /
+ pNetwork->reciprocalDegree(actor);
+ }
+
+ return contribution;
+}
+
+
+/**
+ * Returns the statistic corresponding to the given ego with respect to the
+ * given values of the behavior variable.
+ */
+double AverageReciprocatedAlterEffect::egoStatistic(int i,
+ double * currentValues)
+{
+ const OneModeNetwork * pNetwork =
+ dynamic_cast<const OneModeNetwork *>(this->pNetwork());
+
+ if (!pNetwork)
+ {
+ throw runtime_error(string("One-mode network expected in ") +
+ "AverageReciprocatedAlterEffect");
+ }
+
+ double statistic = 0;
+ int neighborCount = 0;
+
+ for (CommonNeighborIterator iter = pNetwork->reciprocatedTies(i);
+ iter.valid();
+ iter.next())
+ {
+ int j = iter.actor();
+
+ if (!this->missing(this->period(), j) &&
+ !this->missing(this->period() + 1, j))
+ {
+ statistic += currentValues[j];
+ neighborCount++;
+ }
+ }
+
+ if (neighborCount > 0)
+ {
+ statistic *= currentValues[i] / neighborCount;
+ }
+
+ return statistic;
+}
+
+}
Added: pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.h (rev 0)
+++ pkg/RSienaTest/src/model/effects/AverageReciprocatedAlterEffect.h 2009-12-31 16:22:27 UTC (rev 31)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: AverageReciprocatedAlterEffect.h
+ *
+ * Description: This file contains the definition of the
+ * AverageReciprocatedAlterEffect class.
+ *****************************************************************************/
+
+#ifndef AVERAGERECIPROCATEDALTEREFFECT_H_
+#define AVERAGERECIPROCATEDALTEREFFECT_H_
+
+#include "NetworkDependentBehaviorEffect.h"
+
+namespace siena
+{
+
+/**
+ * Average reciprocated alter effect (see manual).
+ */
+class AverageReciprocatedAlterEffect : public NetworkDependentBehaviorEffect
+{
+public:
+ AverageReciprocatedAlterEffect(const EffectInfo * pEffectInfo);
+
+ virtual double calculateChangeContribution(int actor,
+ int difference);
+ virtual double egoStatistic(int ego, double * currentValues);
+};
+
+}
+
+#endif /*AVERAGERECIPROCATEDALTEREFFECT_H_*/
Deleted: pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.cpp 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.cpp 2009-12-31 16:22:27 UTC (rev 31)
@@ -1,182 +0,0 @@
-/******************************************************************************
- * SIENA: Simulation Investigation for Empirical Network Analysis
- *
- * Web: http://www.stats.ox.ac.uk/~snijders/siena/
- *
- * File: AverageSimilarityEffect.cpp
- *
- * Description: This file contains the implementation of the
- * AverageSimilarityEffect class.
- *****************************************************************************/
-
-#include <cmath>
-#include "AverageSimilarityEffect.h"
-#include "network/Network.h"
-#include "network/IncidentTieIterator.h"
-
-#include "model/variables/NetworkVariable.h"
-#include "model/variables/BehaviorVariable.h"
-#include <R.h>
-namespace siena
-{
-
-/**
- * Constructor.
- */
-AverageSimilarityEffect::AverageSimilarityEffect(
- const EffectInfo * pEffectInfo) :
- NetworkDependentBehaviorEffect(pEffectInfo)
-{
-}
-
-
-/**
- * Calculates the change in the statistic corresponding to this effect if
- * the given actor would change his behavior by the given amount.
- */
-double AverageSimilarityEffect::calculateChangeContribution(int actor,
- int difference) const
-{
- double contribution = 0;
- const Network * pNetwork = this->pNetwork();
-
- if (pNetwork->outDegree(actor) > 0)
- {
- // The formula for the effect:
- // s_i(x) = avg(sim(v_i, v_j) - centeringConstant) over all neighbors
- // j of i.
- // sim(v_i, v_j) = 1.0 - |v_i - v_j| / observedRange
- // We need to calculate the change delta in s_i(x), if we changed
- // v_i to v_i + d (d being the given amount of change in v_i).
- // To this end, we can disregard the centering constant and
- // compute the average change in similarity, namely,
- // avg(sim(v_i + d, v_j) - sim(v_i, v_j)) =
- // avg(1 - |v_i+d-v_j|/range - 1 + |v_i-v_j|/range) =
- // avg(|v_i-v_j| - |v_i+d-v_j|) / range,
- // the average being taken over all neighbors of i. This is what
- // is calculated below.
-
- int oldValue = this->value(actor);
- int newValue = oldValue + difference;
- int totalSimilarityChange = 0;
-
- for (IncidentTieIterator iter = pNetwork->outTies(actor);
- iter.valid();
- iter.next())
- {
- int alterValue = this->value(iter.actor());
- totalSimilarityChange +=
- abs(oldValue - alterValue) - abs(newValue - alterValue);
- }
-
- contribution = ((double) totalSimilarityChange) /
- this->range() /
- pNetwork->outDegree(actor);
- }
-
- return contribution;
-}
-
-/**
- * Returns the statistic corresponding to this effect as part of
- * the evaluation function with respect to the given behavior variable.
- */
-double AverageSimilarityEffect::evaluationStatistic(double * currentValues) const
-{
- double statistic = 0;
- int n = this->n();
- const Network * pNetwork = this->pNetwork();
-
- double similarityMean = this->similarityMean();
-
- for (int i = 0; i < n; i++)
- {
- if (pNetwork->outDegree(i))
- {
- double thisStatistic = 0;
-
- for (IncidentTieIterator iter = pNetwork->outTies(i);
- iter.valid();
- iter.next())
- {
- double alterValue = currentValues[iter.actor()];
- double range = this->range();
- thisStatistic += iter.value() *
- (1.0 - fabs(alterValue - currentValues[i]) / range);
- thisStatistic -= similarityMean;
- }
-
- thisStatistic /= pNetwork->outDegree(i);
- statistic += thisStatistic;
- }
- }
-
- return statistic;
-}
-
-
-/**
- * Returns the statistic corresponding to this effect as part of
- * the endowment function with respect to the initial values of a
- * behavior variable and the current values.
- */
-double AverageSimilarityEffect::endowmentStatistic(const int * difference,
- double * currentValues) const
-{
- double statistic = 0;
- int n = this->n();
- const Network * pNetwork = this->pNetwork();
-
- double similarityMean = this->similarityMean();
-
- for (int i = 0; i < n; i++)
- {
- if (difference[i] > 0)
- {
- if (pNetwork->outDegree(i))
- {
- double thisStatistic = 0;
-
- for (IncidentTieIterator iter = pNetwork->outTies(i);
- iter.valid();
- iter.next())
- {
- double alterValue = currentValues[iter.actor()];
- double range = this->range();
- thisStatistic += iter.value() *
- (1.0 - fabs(alterValue - currentValues[i]) / range);
- thisStatistic -= similarityMean;
- }
-
- thisStatistic /= pNetwork->outDegree(i);
- statistic += 2 * thisStatistic;
-
- // do the same using the difference in i's value
- // rather than current state and subtract it.
- // not sure whether this is correct.
-
- thisStatistic = 0;
-
- for (IncidentTieIterator iter = pNetwork->outTies(i);
- iter.valid();
- iter.next())
- {
- double alterValue = currentValues[iter.actor()];
- double range = this->range();
- thisStatistic += iter.value() *
- (1.0 - fabs(alterValue - (difference[i] +
- currentValues[i]))
- / range);
- thisStatistic -= similarityMean;
- }
-
- thisStatistic /= pNetwork->outDegree(i);
- statistic -= thisStatistic;
- }
- }
- }
-
- return statistic;
-}
-
-}
Deleted: pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.h 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/AverageSimilarityEffect.h 2009-12-31 16:22:27 UTC (rev 31)
@@ -1,38 +0,0 @@
-/******************************************************************************
- * SIENA: Simulation Investigation for Empirical Network Analysis
- *
- * Web: http://www.stats.ox.ac.uk/~snijders/siena/
- *
- * File: AverageSimilarityEffect.h
- *
- * Description: This file contains the definition of the
- * AverageSimilarityEffect class.
- *****************************************************************************/
-
-#ifndef AVERAGESIMILARITYEFFECT_H_
-#define AVERAGESIMILARITYEFFECT_H_
-
-#include "NetworkDependentBehaviorEffect.h"
-
-namespace siena
-{
-
-/**
- * Average similarity effect defined as the average centered similarity
- * of the ego with each of its neighbors (with respect to a certain network).
- */
-class AverageSimilarityEffect : public NetworkDependentBehaviorEffect
-{
-public:
- AverageSimilarityEffect(const EffectInfo * pEffectInfo);
-
- virtual double calculateChangeContribution(int actor,
- int difference) const;
- virtual double evaluationStatistic(double * currentValues) const;
- virtual double endowmentStatistic(const int * difference,
- double * currentValues) const;
-};
-
-}
-
-#endif /*AVERAGESIMILARITYEFFECT_H_*/
Deleted: pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.cpp
===================================================================
--- pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.cpp 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.cpp 2009-12-31 16:22:27 UTC (rev 31)
@@ -1,72 +0,0 @@
-/******************************************************************************
- * SIENA: Simulation Investigation for Empirical Network Analysis
- *
- * Web: http://www.stats.ox.ac.uk/~snijders/siena/
- *
- * File: BehaviorDependentBehaviorEffect.cpp
- *
- * Description: This file contains the implementation of the
- * BehaviorDependentBehaviorEffect class.
- *****************************************************************************/
-
-#include <stdexcept>
-
-#include "BehaviorDependentBehaviorEffect.h"
-#include "data/BehaviorLongitudinalData.h"
-#include "model/EpochSimulation.h"
-#include "model/EffectInfo.h"
-#include "model/variables/BehaviorVariable.h"
-#include "model/State.h"
-
-namespace siena
-{
-
-/**
- * Constructor.
- * @param[in] pEffectInfo the descriptor object of the effect
- */
-BehaviorDependentBehaviorEffect::BehaviorDependentBehaviorEffect(
- const EffectInfo * pEffectInfo) : BehaviorEffect(pEffectInfo)
-{
- this->linteractionValues = 0;
- this->lpInteractionBehaviorData = 0;
-}
-
-
-/**
- * Initializes this effect.
- * @param[in] pData the observed data
- * @param[in] pState the current state of the dependent variables
- * @param[in] period the period of interest
- * @param[in] pCache the cache object to be used to speed up calculations
- */
-void BehaviorDependentBehaviorEffect::initialize(const Data * pData,
- State * pState,
- int period,
- Cache * pCache)
-{
- BehaviorEffect::initialize(pData, pState, period, pCache);
- string name = this->pEffectInfo()->interactionName1();
-
- this->linteractionValues = pState->behaviorValues(name);
- this->lpInteractionBehaviorData = pData->pBehaviorData(name);
-
- if (!this->linteractionValues || !this->lpInteractionBehaviorData)
- {
- throw logic_error("Behavior variable '" + name + "' expected.");
- }
-}
-
-
-/**
- * Returns the interaction value of the given actor
- * centered around the overall mean of all observed values.
- */
-double BehaviorDependentBehaviorEffect::centeredInteractionValue(int actor)
- const
-{
- return this->linteractionValues[actor] -
- this->lpInteractionBehaviorData->overallMean();
-}
-
-}
Deleted: pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.h
===================================================================
--- pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.h 2009-12-17 13:55:28 UTC (rev 30)
+++ pkg/RSienaTest/src/model/effects/BehaviorDependentBehaviorEffect.h 2009-12-31 16:22:27 UTC (rev 31)
@@ -1,74 +0,0 @@
-/******************************************************************************
- * SIENA: Simulation Investigation for Empirical Network Analysis
- *
- * Web: http://www.stats.ox.ac.uk/~snijders/siena/
- *
- * File: BehaviorDependentBehaviorEffect.h
- *
- * Description: This file contains the definition of the
- * BehaviorVariableBehaviorEffect class.
- *****************************************************************************/
-
-#ifndef BEHAVIORDEPENDENTBEHAVIOREFFECT_H_
-#define BEHAVIORDEPENDENTBEHAVIOREFFECT_H_
-
-#include "BehaviorEffect.h"
-
-namespace siena
-{
-
-// ----------------------------------------------------------------------------
-// Section: Forward declarations
-// ----------------------------------------------------------------------------
-
-class BehaviorVariable;
-
-
-// ----------------------------------------------------------------------------
-// Section: BehaviorDependentBehaviorEffect class
-// ----------------------------------------------------------------------------
-
-/**
- * The base class for all behavior effects depending on some other behavior
- * variable.
- */
-class BehaviorDependentBehaviorEffect : public BehaviorEffect
-{
-public:
- BehaviorDependentBehaviorEffect(const EffectInfo * pEffectInfo);
-
- virtual void initialize(const Data * pData,
- State * pState,
- int period,
- Cache * pCache);
-
-protected:
- inline int interactionValue(int actor) const;
- double centeredInteractionValue(int actor) const;
-
-private:
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rsiena -r 31
More information about the Rsiena-commits
mailing list