transformScript: Function to transform 'RSiena' and 'multiSiena' scripts

View source: R/TransformScript.R

transformScriptR Documentation

Function to transform RSiena and multiSiena scripts

Description

Function to transform a script with 'old' function names of RSiena and multiSiena to the new names that are used since version RSiena.1.6.0 and multiSiena.1.2.36.

Usage

transformScript(theoldscript, fileName="newScript.R",
                    linelength=80, initialblanks=6, logfile="log.txt",
                    keepOldAlgorithms=FALSE)

Arguments

theoldscript

Character vector: an R script which uses RSiena and/or multiSiena.

fileName

Character string naming a file for the new script.

linelength

The maximum line length for the new script.

initialblanks

The number of blanks at the start of each follow-up line for a given transformed R command.

logfile

Character string naming a file, for the log file.

keepOldAlgorithms

Boolean: should the old calls of sienaAlgorithmCreate be retained in the new script, even though they are redundant.

Details

This function transforms theoldscript, supposedly a script with 'old' function names of RSiena and multiSiena, and transforms it to fileName in which the old names are replaced with the new names that are used since version RSiena.1.6.0; the use of the functions is adapted correspondingly.
The calls for constructing the algorithms required for the estimation functions siena and multi_siena are positioned immediately before the calls of the respective estimation functions. This may involve duplication.
For creation of a time-constant dyadic covariate ("coDyadCovar") the argument type=oneMode is always used; the user should check whether, instead, it should be type=bipartite.
This function is not guaranteed to be correct, and the result should be checked!
Hash signs (#) in strings that are names of objects in RSiena functions will lead to errors, because it is assumed that everything following a has sign in a line is not part of the command.
Functions utilizing other RSiena functions may also lead to errors.
If an error is encountered, the end of the log file will show the line number to which the transformation proceeded without errors.
The use of keepOldAlgorithms is just for the sake of possible information or checking. These calls of sienaAlgorithmCreate can be dropped from the new script without any consequences for its functioning.

Note that using "" for a filename will write to the console.

This function transforms calls of RSiena and multiSiena functions to calls utilizing the new names. The only RSiena functions in theoldscript that are executed are calls of sienaAlgorithmCreate; their results are used for transforming calls of siena07 and sienaBayes.

Value

Invisibly, the new script will be returned as a character vector.

Author(s)

Tom Snijders

References

See the Chapter on "New function names" in the manual available from https://www.stats.ox.ac.uk/~snijders/siena/.

Examples

oldscript <- c("mynet <- sienaDependent(array(c(s501, s502), dim=c(50, 50, 2)))",
    "# construct actor covariate",
"drink <- coCovar(s50a[1,], centered=FALSE)",
"mydata <- sienaDataCreate(mynet, drink)",
"mymodel <- getEffects(mydata)",
"mymodel <- setEffect(mymodel, transTrip)",
"mymodel <- includeEffects(mymodel, simX ,egoX, altX, interaction1='drink')",
"mycontrols0 <- sienaAlgorithmCreate(projname='ans.txt')",
"(ans <- siena07(mycontrols0, data=mydata, effects=mymodel))",
"mycontrols <- sienaAlgorithmCreate(projname='ans.txt', nsub=1, ",
"                                   n2start=2000, n3=2000, seed=1234)",
"(ans1 <- siena07(mycontrols, data=mydata, effects=mymodel, prevAns=ans))",
"(mtest <- Multipar.RSiena(ans1, tested=3:4))")
transformScript(oldscript, fileName="", logfile=tempfile())

RSiena documentation built on April 20, 2026, 5:07 p.m.