CInterface: Estimate parameters in a Siena model

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Estimates parameters in a Siena model using Method of Moments, or Generalized Method of Moments, based on direct simulation; or using Maximum Likelihood by MCMC simulation. Estimation is done using a Robbins-Monro algorithm. Note that the data and particular model to be used must be passed in using named arguments as ..., and the specification for the algorithm must be passed on as x, which is a sienaAlgorithm object as produced by sienaAlgorithmCreate; see examples below.

Usage

1
2
3
4
5
6
7
sienacpp(x,
    nThreads=1,
    logLevelConsole='WARNING', logLevelFile='INFO',
    logBaseName=x$projname, logIncludeLocation=F,
    tt=NA, batch=NA, verbose=NA, silent=NA, initC=NA, useCluster=NA,
    clusterType=NA, clusterString=NA, nbrNodes=NA, clusterIter=NA,
    ...)

Arguments

x

A control object, of class sienaAlgorithm.

nThreads

Number of OpenMP threads each process can use.

logLevelConsole

Minimal level of logging output to the console. One of 'DEBUG', 'VERBOSE', 'INFO', 'WARNING', 'ERROR', 'FATAL'. Where 'DEBUG' prints all messages, 'FATAL' only the messages with highest priority.

logLevelFile

Like logLevelConsole but for logging to files.

logBaseName

Base name of the logging files. Each process logs into a separate file. The final log file name is <logBaseName>-<mpiRank>:<threadID>.log.

logIncludeLocation

When TRUE also log the code location (file, method, line) where the logging message originated.

...

Arguments for initializeFRAN. Usually, data and effects, as in the examples below.

batch

Deprecated. See logLevel

verbose

Deprecated. See logLevel

silent

Deprecated. See logLevel

clusterString

Deprecated. The cluster setup is detected automatically via MPI.

useCluster

Deprecated. See clusterString

nbrNodes

Deprecated. See clusterString

clusterIter

Deprecated. See clusterString

clusterType

Deprecated. See clusterString

initC

Deprecated. C++ anyway.

tt

Deprecated. No GUI supported.

Details

This implementation is an alternative to siena07. In sienacpp the algorithm is coded entirely in C++, whereas for siena07 the 'front end' is coded in R. The Generalized Method of Moments is available only in sienacpp. Objects produced by siena07 contain some more material (usually not needed). For the rest, the two functions do the same.

sienacpp runs a Robbins-Monro algorithm for parameter estimation using for the Method of Moments the three-phase implementation in Snijders (2001) and Snijders, Steglich and Schweinberger (2007), with (if findiff=TRUE in the sienaAlgorithm object) derivative estimation as in Schweinberger and Snijders (2007). Phase 1 does a few iterations to estimate the derivative matrix of the targets with respect to the parameter vector. Phase 2 does the estimation. Phase 3 runs a simulation to estimate standard errors and check convergence of the model.

The Generalized Method of Moments is used if any of the effects specified in the effects object is defined with type=gmm. For the Generalized Method of Moments the algorithm of Amati, Schoenenberger, and Snijders (2015) is used, which uses a three-phase Robbins-Monro algorithm as above, but with an estimated optimal linear combination of the statistics.

If maxlike=TRUE in the sienaAlgorithm object, estimation is done by Maximum Likelihood implemented as in Snijders, Koskinen and Schweinberger (2010) also using the three-phase Robbins-Monro algorithm.

The deprecated parameters are included to allow using the same syntax as for siena07.
The Dolby option in sienaAlgorithmCreate is not yet supported by sienacpp.
sienaFit objects created by sienacpp cannot be used for sienaTimeTest or sienaGOF.

The specification of the effects object for GMoM estimation requires that in the effects object, apart from the basic rate effects, some of the effects were specified in includeEffects with type='eval' (the default, which means that this does not need to be stated) and the others with type='gmm'. The first then are evaluation effects defining the model specification, the second are statistics used for estimation. The method requires that the number of statistics (type='gmm') is equal to or larger than the number of evaluation effects (type='eval'). See the example below.

Value

Returns an object of class sienaFit, some parts of which are:

OK

Boolean indicating successful termination

termination

Character string, values: "OK", "Error", or "UserInterrupt". "UserInterrupt" indicates that the user asked for early termination before phase 3.

f

Various characteristics of the data and model definition.

theta

Fitted value of theta.

pp

Length of theta: number of parameters, excluding conditioning rate parameters (if any).

qq

Number of statistics used in estimation: equal to pp for MoM and ML estimation.

covtheta

Estimated covariance matrix of theta; this is not available if the sienaAlgorithm object x was produced with simOnly=TRUE.

dfra

Matrix of estimated derivatives of expected statistics (linear combinations used in Robbins-Monro updates) by parameters.

gamma

Matrix of estimated derivatives of expected statistics (all) by parameters.

sf

Matrix of deviations from targets in phase 3.

sf2

Array of statistics from simulations in phase 3.

tstat

t-statistics for convergence.

targets

Observed statistics.

targets2

Observed statistics by wave, starting with the second wave .

ssc

Score function contributions for each wave for each simulation in phase 3. Zero if finite difference method is used

Phase3nits

Number of iterations actually performed in phase 3.

Writes text output to the file named "projname.out", where projname is defined in the sienaAlgorithm object x.

Author(s)

Felix Schoenenberger, some modifications by Tom Snijders

References

See Also

sienaAlgorithmCreate, siena07.
There are print, summary and xtable methods for sienaFit objects: xtable, print.sienaFit.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Method of Moments:
algo <- sienaAlgorithmCreate(nsub=2, n3=100, seed=123)
net <- sienaDependent(array(c(tmp3, tmp4), dim=c(32, 32, 2)))
dataset <- sienaDataCreate(net)
eff <- getEffects(dataset)
eff
(ans <- sienacpp(algo, data=dataset, effects=eff))
# or if a previous 'on track' result ans was obtained
(ans <- sienacpp(algo, data=dataset, effects=eff, prevAns=ans))
# Generalized Method of Moments:
algo <- sienaAlgorithmCreate(nsub=2, n3=100, dolby=FALSE, seed=123)
eff <- includeEffects(eff, density)
eff <- includeEffects(eff, density, type='gmm')
eff <- includeEffects(eff, recip)
eff <- includeEffects(eff, recip, realrecip, persistrecip, type='gmm')
eff
(ans <- sienacpp(algo, data=dataset, effects=eff))

RSienaTest documentation built on July 14, 2021, 3 a.m.