[Rsiena-commits] r58 - in pkg/RSiena: man src/data src/model src/model/effects/generic src/model/filters src/model/ml

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 11 20:04:57 CET 2010


Author: ripleyrm
Date: 2010-02-11 20:04:57 +0100 (Thu, 11 Feb 2010)
New Revision: 58

Added:
   pkg/RSiena/man/sienaDataConstraint.Rd
   pkg/RSiena/src/data/NetworkConstraint.cpp
   pkg/RSiena/src/data/NetworkConstraint.h
   pkg/RSiena/src/model/effects/generic/AlterPredicate.cpp
   pkg/RSiena/src/model/effects/generic/AlterPredicate.h
   pkg/RSiena/src/model/effects/generic/ConditionalFunction.cpp
   pkg/RSiena/src/model/effects/generic/ConditionalFunction.h
   pkg/RSiena/src/model/effects/generic/CovariatePredicate.cpp
   pkg/RSiena/src/model/effects/generic/CovariatePredicate.h
   pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.cpp
   pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.h
   pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.cpp
   pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.h
   pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.cpp
   pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.h
   pkg/RSiena/src/model/filters/
   pkg/RSiena/src/model/filters/AtLeastOneFilter.cpp
   pkg/RSiena/src/model/filters/AtLeastOneFilter.h
   pkg/RSiena/src/model/filters/DisjointFilter.cpp
   pkg/RSiena/src/model/filters/DisjointFilter.h
   pkg/RSiena/src/model/filters/HigherFilter.cpp
   pkg/RSiena/src/model/filters/HigherFilter.h
   pkg/RSiena/src/model/filters/LowerFilter.cpp
   pkg/RSiena/src/model/filters/LowerFilter.h
   pkg/RSiena/src/model/filters/NetworkDependentFilter.cpp
   pkg/RSiena/src/model/filters/NetworkDependentFilter.h
   pkg/RSiena/src/model/filters/PermittedChangeFilter.cpp
   pkg/RSiena/src/model/filters/PermittedChangeFilter.h
   pkg/RSiena/src/model/ml/
   pkg/RSiena/src/model/ml/BehaviorChange.cpp
   pkg/RSiena/src/model/ml/BehaviorChange.h
   pkg/RSiena/src/model/ml/Chain.cpp
   pkg/RSiena/src/model/ml/Chain.h
   pkg/RSiena/src/model/ml/MiniStep.cpp
   pkg/RSiena/src/model/ml/MiniStep.h
   pkg/RSiena/src/model/ml/NetworkChange.cpp
   pkg/RSiena/src/model/ml/NetworkChange.h
Log:
Adding the forgotten files

Added: pkg/RSiena/man/sienaDataConstraint.Rd
===================================================================
--- pkg/RSiena/man/sienaDataConstraint.Rd	                        (rev 0)
+++ pkg/RSiena/man/sienaDataConstraint.Rd	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,39 @@
+\name{sienaDataConstraint}
+\alias{sienaDataConstraint}
+\title{
+Function to change the values of the constraints between networks.
+}
+\description{This function allows the user to change the constraints of
+  "higher", "disjoint" and "atLeastOne" for a specified pair of networks
+  in a Siena data object.
+}
+\usage{
+sienaDataConstraint(x, net1, net2,
+type = c("higher", "disjoint", "atLeastOne"), value = FALSE)
+}
+\arguments{
+  \item{x}{Siena Data Object Maybe a group object?}
+  \item{net1}{name of first network}
+  \item{net2}{name of second network}
+  \item{type}{one of "higher", "disjoint", "atleastOne". Default is "higher".
+}
+  \item{value}{Boolean giving the value
+}
+}
+\details{
+  The value of the appropriate attribute is set to the value requested.
+}
+\value{
+  Updated Siena data object.
+}
+\references{See \url{http://www.stats.ox.ac.uk/~snijders/siena/}}
+\author{Ruth Ripley}
+\seealso{\code{\link{sienaDataCreate}}}
+
+\examples{
+mynet1 <- sienaNet(array(c(s501,s502,s503),dim=c(50,50,3)))
+mynet2 <- sienaNet(s50a,type='behavior')
+mydata <- sienaDataCreate(mynet1, mynet2)
+mydata <- sienaDataConstraint(mydata, mynet2, mynet1, "higher", FALSE)
+}
+\keyword{ classes }


Property changes on: pkg/RSiena/man/sienaDataConstraint.Rd
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/data/NetworkConstraint.cpp
===================================================================
--- pkg/RSiena/src/data/NetworkConstraint.cpp	                        (rev 0)
+++ pkg/RSiena/src/data/NetworkConstraint.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,29 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: NetworkConstraint.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * NetworkConstraint.
+ *****************************************************************************/
+
+#include "NetworkConstraint.h"
+
+namespace siena
+{
+
+/**
+ * Constructs a new network constraint.
+ */
+NetworkConstraint::NetworkConstraint(string networkName1,
+	string networkName2,
+	NetworkConstraintType type)
+{
+	this->lnetworkName1 = networkName1;
+	this->lnetworkName2 = networkName2;
+	this->ltype = type;
+}
+
+}


Property changes on: pkg/RSiena/src/data/NetworkConstraint.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/data/NetworkConstraint.h
===================================================================
--- pkg/RSiena/src/data/NetworkConstraint.h	                        (rev 0)
+++ pkg/RSiena/src/data/NetworkConstraint.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: NetworkConstraint.h
+ *
+ * Description: This file contains the definition of the
+ * NetworkConstraint class.
+ *****************************************************************************/
+
+#ifndef NETWORKCONSTRAINT_H_
+#define NETWORKCONSTRAINT_H_
+
+#include <string>
+
+using namespace std;
+
+namespace siena
+{
+
+// ----------------------------------------------------------------------------
+// Section: Enums
+// ----------------------------------------------------------------------------
+
+/**
+ * This enumeration defines two possible directions of traversing a tie.
+ */
+enum NetworkConstraintType {HIGHER, DISJOINT, AT_LEAST_ONE};
+
+
+// ----------------------------------------------------------------------------
+// Section: Class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * A descriptor class for network constraints like higher(network1, network2).
+ * These constraints are maintained during model simulations.
+ */
+class NetworkConstraint
+{
+public:
+	NetworkConstraint(string networkName1,
+		string networkName2,
+		NetworkConstraintType type);
+
+	inline string networkName1() const;
+	inline string networkName2() const;
+	inline NetworkConstraintType type() const;
+
+private:
+	// The name of the first network involved in this constraint
+	string lnetworkName1;
+
+	// The name of the second network involved in this constraint
+	string lnetworkName2;
+
+	// The type of the constraint
+	NetworkConstraintType ltype;
+};
+
+
+// ----------------------------------------------------------------------------
+// Section: Inline methods
+// ----------------------------------------------------------------------------
+
+/**
+ * Returns the name of the first network variable involved in this constraint.
+ */
+string NetworkConstraint::networkName1() const
+{
+	return this->lnetworkName1;
+}
+
+
+/**
+ * Returns the name of the second network variable involved in this constraint.
+ */
+string NetworkConstraint::networkName2() const
+{
+	return this->lnetworkName2;
+}
+
+
+/**
+ * Returns the type of this constraint.
+ */
+NetworkConstraintType NetworkConstraint::type() const
+{
+	return this->ltype;
+}
+
+}
+
+#endif /* NETWORKCONSTRAINT_H_ */


Property changes on: pkg/RSiena/src/data/NetworkConstraint.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/AlterPredicate.cpp
===================================================================
--- pkg/RSiena/src/model/effects/generic/AlterPredicate.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/AlterPredicate.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,42 @@
+#include "AlterPredicate.h"
+
+namespace siena
+{
+
+/**
+ * Creates a new predicate.
+ */
+AlterPredicate::AlterPredicate()
+{
+	this->lego = -1;
+	this->lperiod = -1;
+}
+
+
+/**
+ * Initializes this predicate.
+ * @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 AlterPredicate::initialize(const Data * pData,
+	State * pState,
+	int period,
+	Cache * pCache)
+{
+	this->lperiod = period;
+}
+
+
+/**
+ * Does the necessary preprocessing work for calculating the
+ * predicate for a specific ego. This method must be invoked before
+ * calling AlterPredicate::value(...).
+ */
+void AlterPredicate::preprocessEgo(int ego)
+{
+	this->lego = ego;
+}
+
+}


Property changes on: pkg/RSiena/src/model/effects/generic/AlterPredicate.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/AlterPredicate.h
===================================================================
--- pkg/RSiena/src/model/effects/generic/AlterPredicate.h	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/AlterPredicate.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: AlterPredicate.h
+ *
+ * Description: This file contains the definition of the AlterPredicate class.
+ *****************************************************************************/
+
+#ifndef ALTERPREDICATE_H_
+#define ALTERPREDICATE_H_
+
+namespace siena
+{
+
+// ----------------------------------------------------------------------------
+// Section: Forward declarations
+// ----------------------------------------------------------------------------
+
+class Data;
+class State;
+class Cache;
+
+
+// ----------------------------------------------------------------------------
+// Section: Class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * Defines a predicate on all actors (alters) with respect to a given ego.
+ */
+class AlterPredicate
+{
+public:
+	AlterPredicate();
+
+	virtual void initialize(const Data * pData,
+		State * pState,
+		int period,
+		Cache * pCache);
+	virtual void preprocessEgo(int ego);
+
+	inline int ego() const;
+	inline int period() const;
+
+	/**
+	 * Returns if this predicate holds for the given alter. It is assumed
+	 * that the predicate has been initialized before and pre-processed with
+	 * respect to a certain ego.
+	 */
+	virtual bool value(int alter) = 0;
+
+private:
+	int lego;
+	int lperiod;
+};
+
+
+// ----------------------------------------------------------------------------
+// Section: Inline methods
+// ----------------------------------------------------------------------------
+
+/**
+ * Returns the current ego.
+ */
+int AlterPredicate::ego() const
+{
+	return this->lego;
+}
+
+
+/**
+ * Returns the period of interest.
+ */
+int AlterPredicate::period() const
+{
+	return this->lperiod;
+}
+
+}
+
+#endif /* ALTERPREDICATE_H_ */


Property changes on: pkg/RSiena/src/model/effects/generic/AlterPredicate.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/ConditionalFunction.cpp
===================================================================
--- pkg/RSiena/src/model/effects/generic/ConditionalFunction.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/ConditionalFunction.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: ConditionalFunction.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * ConditionalFunction.
+ *****************************************************************************/
+
+#include "ConditionalFunction.h"
+#include "model/effects/generic/AlterPredicate.h"
+
+namespace siena
+{
+
+/**
+ * Creates a new conditional function.
+ * @param[in] pPredicate the predicate to be tested
+ * @param[in] pIfFunction the function to be called if the predicate holds
+ * @param[in] pElseFunction the function to be called if the predicate does not
+ * hold
+ */
+ConditionalFunction::ConditionalFunction(AlterPredicate * pPredicate,
+	AlterFunction * pIfFunction,
+	AlterFunction * pElseFunction)
+{
+	this->lpPredicate = pPredicate;
+	this->lpIfFunction = pIfFunction;
+	this->lpElseFunction = pElseFunction;
+}
+
+
+/**
+ * Deallocates this function.
+ */
+ConditionalFunction::~ConditionalFunction()
+{
+	delete this->lpPredicate;
+	delete this->lpIfFunction;
+	delete this->lpElseFunction;
+}
+
+
+/**
+ * Initializes this function.
+ * @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 ConditionalFunction::initialize(const Data * pData,
+	State * pState,
+	int period,
+	Cache * pCache)
+{
+	AlterFunction::initialize(pData, pState, period, pCache);
+	this->lpPredicate->initialize(pData, pState, period, pCache);
+
+	if (this->lpIfFunction)
+	{
+		this->lpIfFunction->initialize(pData, pState, period, pCache);
+	}
+
+	if (this->lpElseFunction)
+	{
+		this->lpElseFunction->initialize(pData, pState, period, pCache);
+	}
+}
+
+
+/**
+ * Does the necessary preprocessing work for calculating the alter
+ * function for a specific ego. This method must be invoked before
+ * calling ConditionalFunction::value(...).
+ */
+void ConditionalFunction::preprocessEgo(int ego)
+{
+	AlterFunction::preprocessEgo(ego);
+	this->lpPredicate->preprocessEgo(ego);
+
+	if (this->lpIfFunction)
+	{
+		this->lpIfFunction->preprocessEgo(ego);
+	}
+
+	if (this->lpElseFunction)
+	{
+		this->lpElseFunction->preprocessEgo(ego);
+	}
+}
+
+
+/**
+ * Returns the value of this function for the given alter. It is assumed
+ * that the function has been initialized before and pre-processed with
+ * respect to a certain ego.
+ */
+double ConditionalFunction::value(int alter)
+{
+	double value = 0;
+
+	if (this->lpPredicate->value(alter))
+	{
+		if (this->lpIfFunction)
+		{
+			value = this->lpIfFunction->value(alter);
+		}
+	}
+	else if (this->lpElseFunction)
+	{
+		value = this->lpElseFunction->value(alter);
+	}
+
+	return value;
+}
+
+}


Property changes on: pkg/RSiena/src/model/effects/generic/ConditionalFunction.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/ConditionalFunction.h
===================================================================
--- pkg/RSiena/src/model/effects/generic/ConditionalFunction.h	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/ConditionalFunction.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: ConditionalFunction.h
+ *
+ * Description: This file contains the definition of the
+ * ConditionalFunction class.
+ *****************************************************************************/
+
+#ifndef CONDITIONALFUNCTION_H_
+#define CONDITIONALFUNCTION_H_
+
+#include "AlterFunction.h"
+
+namespace siena
+{
+
+// ----------------------------------------------------------------------------
+// Section: Forward declarations
+// ----------------------------------------------------------------------------
+
+class AlterPredicate;
+
+
+// ----------------------------------------------------------------------------
+// Section: Class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * Defines an alter function depending on a condition. More specifically,
+ * this function owns two sub-functions and a predicate. If the predicate
+ * is true then the calculation of the function value is delegated to the
+ * if-function. Otherwise, the calculation is delegated to the else-function.
+ */
+class ConditionalFunction: public AlterFunction
+{
+public:
+	ConditionalFunction(AlterPredicate * pPredicate,
+		AlterFunction * pIfFunction,
+		AlterFunction * pElseFunction);
+	virtual ~ConditionalFunction();
+
+	virtual void initialize(const Data * pData,
+		State * pState,
+		int period,
+		Cache * pCache);
+	virtual void preprocessEgo(int ego);
+
+	virtual double value(int alter);
+
+private:
+	AlterPredicate * lpPredicate;
+	AlterFunction * lpIfFunction;
+	AlterFunction * lpElseFunction;
+};
+
+}
+
+#endif /* CONDITIONALFUNCTION_H_ */


Property changes on: pkg/RSiena/src/model/effects/generic/ConditionalFunction.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/CovariatePredicate.cpp
===================================================================
--- pkg/RSiena/src/model/effects/generic/CovariatePredicate.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/CovariatePredicate.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: CovariatePredicate.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * CovariatePredicate.
+ *****************************************************************************/
+
+#include <stdexcept>
+#include "CovariatePredicate.h"
+#include "data/Data.h"
+#include "data/ConstantCovariate.h"
+#include "data/ChangingCovariate.h"
+#include "data/BehaviorLongitudinalData.h"
+#include "model/State.h"
+
+using namespace std;
+
+namespace siena
+{
+
+/**
+ * Creates a new predicate.
+ */
+CovariatePredicate::CovariatePredicate(string covariateName) :
+	NamedObject(covariateName)
+{
+	this->lpConstantCovariate = 0;
+	this->lpChangingCovariate = 0;
+	this->lpBehaviorData = 0;
+	this->lvalues = 0;
+}
+
+
+/**
+ * Initializes this predicate.
+ * @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 CovariatePredicate::initialize(const Data * pData,
+	State * pState,
+	int period,
+	Cache * pCache)
+{
+	AlterPredicate::initialize(pData, pState, period, pCache);
+	string name = this->name();
+
+	this->lpConstantCovariate = pData->pConstantCovariate(name);
+	this->lpChangingCovariate = pData->pChangingCovariate(name);
+	this->lpBehaviorData = pData->pBehaviorData(name);
+	this->lvalues = pState->behaviorValues(name);
+
+	if (!this->lpConstantCovariate &&
+		!this->lpChangingCovariate &&
+		!(this->lpBehaviorData && this->lvalues))
+	{
+		throw logic_error("Covariate or dependent behavior variable '" +
+			name +
+			"' expected.");
+	}
+}
+
+
+/**
+ * Returns the covariate value for the given actor.
+ */
+double CovariatePredicate::covariateValue(int i) const
+{
+	double value = 0;
+
+	if (this->lpConstantCovariate)
+	{
+		value = this->lpConstantCovariate->value(i);
+	}
+	else if (this->lpChangingCovariate)
+	{
+		value = this->lpChangingCovariate->value(i, this->period());
+	}
+	else
+	{
+		value = this->lvalues[i] - this->lpBehaviorData->overallMean();
+	}
+
+	return value;
+}
+
+
+/**
+ * Returns if the covariate value for the given actor is missing.
+ */
+bool CovariatePredicate::missing(int i) const
+{
+	bool missing = false;
+
+	if (this->lpConstantCovariate)
+	{
+		missing = this->lpConstantCovariate->missing(i);
+	}
+	else if (this->lpChangingCovariate)
+	{
+		missing = this->lpChangingCovariate->missing(i, this->period());
+	}
+	else
+	{
+		missing = this->lpBehaviorData->missing(this->period(), i);
+	}
+
+	return missing;
+}
+
+}


Property changes on: pkg/RSiena/src/model/effects/generic/CovariatePredicate.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/CovariatePredicate.h
===================================================================
--- pkg/RSiena/src/model/effects/generic/CovariatePredicate.h	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/CovariatePredicate.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,54 @@
+#ifndef COVARIATEPREDICATE_H_
+#define COVARIATEPREDICATE_H_
+
+#include "AlterPredicate.h"
+#include "utils/NamedObject.h"
+
+namespace siena
+{
+
+// ----------------------------------------------------------------------------
+// Section: Forward declarations
+// ----------------------------------------------------------------------------
+
+class ConstantCovariate;
+class ChangingCovariate;
+class BehaviorLongitudinalData;
+
+
+// ----------------------------------------------------------------------------
+// Section: Class definition
+// ----------------------------------------------------------------------------
+
+/**
+ * Defines an alter predicate that depends on a certain covariate or
+ * behavior variable.
+ */
+class CovariatePredicate: public AlterPredicate, NamedObject
+{
+public:
+	CovariatePredicate(string covariateName);
+
+	virtual void initialize(const Data * pData,
+		State * pState,
+		int period,
+		Cache * pCache);
+
+protected:
+	double covariateValue(int i) const;
+	bool missing(int i) const;
+
+private:
+	ConstantCovariate * lpConstantCovariate;
+	ChangingCovariate * lpChangingCovariate;
+	BehaviorLongitudinalData * lpBehaviorData;
+
+	// The current value of a behavior variable per each actor.
+	// This array is 0 for covariate-based effects.
+
+	const int * lvalues;
+};
+
+}
+
+#endif /* COVARIATEPREDICATE_H_ */


Property changes on: pkg/RSiena/src/model/effects/generic/CovariatePredicate.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.cpp
===================================================================
--- pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: EqualCovariatePredicate.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * EqualCovariatePredicate.
+ *****************************************************************************/
+
+#include <cmath>
+#include "EqualCovariatePredicate.h"
+#include "utils/Utils.h"
+
+namespace siena
+{
+
+/**
+ * Constructs a new predicate.
+ */
+EqualCovariatePredicate::EqualCovariatePredicate(string covariateName) :
+	CovariatePredicate(covariateName)
+{
+}
+
+
+/**
+ * Returns if this predicate holds for the given alter. It is assumed
+ * that the predicate has been initialized before and pre-processed with
+ * respect to a certain ego.
+ */
+bool EqualCovariatePredicate::value(int alter)
+{
+	return fabs(this->covariateValue(this->ego()) -
+		this->covariateValue(alter)) < EPSILON;
+}
+
+}


Property changes on: pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.h
===================================================================
--- pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.h	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: EqualCovariatePredicate.h
+ *
+ * Description: This file contains the definition of the
+ * EqualCovariatePredicate class.
+ *****************************************************************************/
+
+#ifndef EQUALCOVARIATEPREDICATE_H_
+#define EQUALCOVARIATEPREDICATE_H_
+
+#include "CovariatePredicate.h"
+
+namespace siena
+{
+
+/**
+ * Defines a predicate that holds if the ego and the alter have the same
+ * covariate values.
+ */
+class EqualCovariatePredicate: public CovariatePredicate
+{
+public:
+	EqualCovariatePredicate(string covariateName);
+
+	virtual bool value(int alter);
+};
+
+}
+
+#endif /* EQUALCOVARIATEPREDICATE_H_ */


Property changes on: pkg/RSiena/src/model/effects/generic/EqualCovariatePredicate.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.cpp
===================================================================
--- pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: MissingCovariatePredicate.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * MissingCovariatePredicate.
+ *****************************************************************************/
+
+#include "MissingCovariatePredicate.h"
+
+namespace siena
+{
+
+/**
+ * Constructs a new predicate.
+ */
+MissingCovariatePredicate::MissingCovariatePredicate(string covariateName) :
+	CovariatePredicate(covariateName)
+{
+}
+
+
+/**
+ * Returns if this predicate holds for the given alter. It is assumed
+ * that the predicate has been initialized before and pre-processed with
+ * respect to a certain ego.
+ */
+bool MissingCovariatePredicate::value(int alter)
+{
+	return this->missing(this->ego()) || this->missing(alter);
+}
+
+}


Property changes on: pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.h
===================================================================
--- pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.h	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: MissingCovariatePredicate.h
+ *
+ * Description: This file contains the definition of the
+ * MissingCovariatePredicate class.
+ *****************************************************************************/
+
+#ifndef MISSINGCOVARIATEPREDICATE_H_
+#define MISSINGCOVARIATEPREDICATE_H_
+
+#include "CovariatePredicate.h"
+
+namespace siena
+{
+
+/**
+ * Defines a predicate that holds if the covariate value is missing either for
+ * the ego or the alter.
+ */
+class MissingCovariatePredicate: public CovariatePredicate
+{
+public:
+	MissingCovariatePredicate(string covariateName);
+
+	virtual bool value(int alter);
+};
+
+}
+
+#endif /* MISSINGCOVARIATEPREDICATE_H_ */


Property changes on: pkg/RSiena/src/model/effects/generic/MissingCovariatePredicate.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.cpp
===================================================================
--- pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: OneModeNetworkAlterFunction.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * OneModeNetworkAlterFunction.
+ *****************************************************************************/
+
+#include <stdexcept>
+#include "OneModeNetworkAlterFunction.h"
+#include "network/OneModeNetwork.h"
+
+namespace siena
+{
+
+/**
+ * Creates a new function depending on a one-mode network with the
+ * given name.
+ */
+OneModeNetworkAlterFunction::OneModeNetworkAlterFunction(string networkName) :
+	NetworkAlterFunction(networkName)
+{
+}
+
+
+/**
+ * Initializes this function.
+ * @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 OneModeNetworkAlterFunction::initialize(const Data * pData,
+	State * pState,
+	int period,
+	Cache * pCache)
+{
+	NetworkAlterFunction::initialize(pData, pState, period, pCache);
+
+	if (dynamic_cast<const OneModeNetwork *>(this->pNetwork()) == 0)
+	{
+		throw logic_error("One-mode network expected.");
+	}
+}
+
+}


Property changes on: pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.h
===================================================================
--- pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.h	                        (rev 0)
+++ pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: OneModeNetworkAlterFunction.h
+ *
+ * Description: This file contains the definition of the
+ * OneModeNetworkAlterFunction class.
+ *****************************************************************************/
+
+#ifndef ONEMODENETWORKALTERFUNCTION_H_
+#define ONEMODENETWORKALTERFUNCTION_H_
+
+#include "NetworkAlterFunction.h"
+
+namespace siena
+{
+
+/**
+ * An alter function that depends on a one-mode network.
+ */
+class OneModeNetworkAlterFunction: public NetworkAlterFunction
+{
+public:
+	OneModeNetworkAlterFunction(string networkName);
+
+	virtual void initialize(const Data * pData,
+		State * pState,
+		int period,
+		Cache * pCache);
+};
+
+}
+
+#endif /* ONEMODENETWORKALTERFUNCTION_H_ */


Property changes on: pkg/RSiena/src/model/effects/generic/OneModeNetworkAlterFunction.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/filters/AtLeastOneFilter.cpp
===================================================================
--- pkg/RSiena/src/model/filters/AtLeastOneFilter.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/filters/AtLeastOneFilter.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: AtLeastOneFilter.cpp
+ *
+ * Description: This file contains the implementation of the class
+ * AtLeastOneFilter.
+ *****************************************************************************/
+
+#include "AtLeastOneFilter.h"
+#include "network/IncidentTieIterator.h"
+#include "network/Network.h"
+#include "model/variables/NetworkVariable.h"
+
+namespace siena
+{
+
+/**
+ * Constructs a new filter.
+ */
+AtLeastOneFilter::AtLeastOneFilter(const NetworkVariable * pOwnerVariable,
+	const NetworkVariable * pOtherVariable) :
+		NetworkDependentFilter(pOwnerVariable, pOtherVariable)
+{
+}
+
+
+/**
+ * Forbids tie changes between the given ego and some alters
+ * by setting the permitted flag to false for these alters.
+ */
+void AtLeastOneFilter::filterPermittedChanges(int ego, bool * permitted)
+{
+	const Network * pNetwork1 = this->pVariable()->pNetwork();
+	const Network * pNetwork2 = this->pOtherVariable()->pNetwork();
+
+	// We shouldn't withdraw a tie if it is not present in the other network.
+
+	IncidentTieIterator iter1 = pNetwork1->outTies(ego);
+	IncidentTieIterator iter2 = pNetwork2->outTies(ego);
+
+	while (iter1.valid())
+	{
+		while (iter2.valid() && iter2.actor() < iter1.actor())
+		{
+			iter2.next();
+		}
+
+		if (!iter2.valid() || iter2.actor() > iter1.actor())
+		{
+			permitted[iter1.actor()] = false;
+		}
+
+		iter1.next();
+	}
+}
+
+}


Property changes on: pkg/RSiena/src/model/filters/AtLeastOneFilter.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/filters/AtLeastOneFilter.h
===================================================================
--- pkg/RSiena/src/model/filters/AtLeastOneFilter.h	                        (rev 0)
+++ pkg/RSiena/src/model/filters/AtLeastOneFilter.h	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * SIENA: Simulation Investigation for Empirical Network Analysis
+ *
+ * Web: http://www.stats.ox.ac.uk/~snijders/siena/
+ *
+ * File: AtLeastOneFilter.h
+ *
+ * Description: This file contains the definition of the
+ * AtLeastOneFilter class.
+ *****************************************************************************/
+
+#ifndef ATLEASTONEFILTER_H_
+#define ATLEASTONEFILTER_H_
+
+#include "NetworkDependentFilter.h"
+
+namespace siena
+{
+
+/**
+ * Defines a filter of permissible changes that requires that every
+ * tie (i,j) is present in at least one of two networks.
+ */
+class AtLeastOneFilter: public NetworkDependentFilter
+{
+public:
+	AtLeastOneFilter(const NetworkVariable * pOwnerVariable,
+		const NetworkVariable * pOtherVariable);
+
+	virtual void filterPermittedChanges(int ego, bool * permitted);
+};
+
+}
+
+#endif /* ATLEASTONEFILTER_H_ */


Property changes on: pkg/RSiena/src/model/filters/AtLeastOneFilter.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: pkg/RSiena/src/model/filters/DisjointFilter.cpp
===================================================================
--- pkg/RSiena/src/model/filters/DisjointFilter.cpp	                        (rev 0)
+++ pkg/RSiena/src/model/filters/DisjointFilter.cpp	2010-02-11 19:04:57 UTC (rev 58)
@@ -0,0 +1,60 @@
+/******************************************************************************
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rsiena -r 58


More information about the Rsiena-commits mailing list