[Rsiena-commits] r86 - in pkg/RSienaTest: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 24 00:32:10 CEST 2010
Author: jalospinoso
Date: 2010-05-24 00:32:09 +0200 (Mon, 24 May 2010)
New Revision: 86
Modified:
pkg/RSienaTest/NAMESPACE
pkg/RSienaTest/R/sienaTimeTest.r
pkg/RSienaTest/man/sienaTimeTest.Rd
Log:
Added includeTimeDummy, documentation. Fixed naming in plot.sienaTimeTest.
Modified: pkg/RSienaTest/NAMESPACE
===================================================================
--- pkg/RSienaTest/NAMESPACE 2010-05-22 15:15:33 UTC (rev 85)
+++ pkg/RSienaTest/NAMESPACE 2010-05-23 22:32:09 UTC (rev 86)
@@ -5,7 +5,7 @@
sienaGroupCreate, sienaModelCreate, sienaNet, sienaNodeSet, #simstats0c,
varCovar, varDyadCovar, setEffect, includeEffects, includeInteraction,
effectsDocumentation, sienaDataConstraint, #maxlikefn,
- installGui, siena08, iwlsm, sienaTimeTest)
+ installGui, siena08, iwlsm, sienaTimeTest, includeTimeDummy)
import(Matrix)
import(xtable)
Modified: pkg/RSienaTest/R/sienaTimeTest.r
===================================================================
--- pkg/RSienaTest/R/sienaTimeTest.r 2010-05-22 15:15:33 UTC (rev 85)
+++ pkg/RSienaTest/R/sienaTimeTest.r 2010-05-23 22:32:09 UTC (rev 86)
@@ -397,8 +397,7 @@
ymin=min(yaxis[i, ] - scale * abs(yaxis[i, ]))
ymax=max(yaxis[i, ] + scale * abs(yaxis[i, ]))
xyplot(yaxis[i, ] ~ xaxis,
- type = "p", main = rownames(timetest$IndividualTest)
- [timetest$NonRateIndices[effects[i]]],
+ type = "p", main = rownames(timetest$EffectTest)[effects[i]] ,
sub=paste("p=", timetest$EffectTest[effects[i]]), bty="n",
xlab="Wave", ylab="Parameter Value", auto.key=TRUE,
ylim=c(ymin, ymax), xlim=c(0, length(xaxis) + 1),
@@ -670,4 +669,37 @@
list(effects=effects, data=data)
}
}
-
+##@includeTimeDummy DataCreate
+includeTimeDummy <- function(myeff, ..., timeDummy="all", name=myeff$name[1],
+ type="eval", interaction1="", interaction2="",
+ character=FALSE)
+{
+
+ if (character)
+ {
+ dots <- sapply(list(...), function(x)x)
+ }
+ else
+ {
+ dots <- substitute(list(...))[-1] ##first entry is the word 'list'
+ }
+ if (length(dots) == 0)
+ {
+ stop("need some effect short names")
+ }
+ if (!character)
+ {
+ effectNames <- sapply(dots, function(x)deparse(x))
+ }
+ else
+ {
+ effectNames <- dots
+ }
+ use <- myeff$shortName %in% effectNames &
+ myeff$type==type &
+ myeff$name==name &
+ myeff$interaction1 == interaction1 &
+ myeff$interaction2 == interaction2
+ myeff[use, "timeDummy"] <- timeDummy
+ myeff
+}
Modified: pkg/RSienaTest/man/sienaTimeTest.Rd
===================================================================
--- pkg/RSienaTest/man/sienaTimeTest.Rd 2010-05-22 15:15:33 UTC (rev 85)
+++ pkg/RSienaTest/man/sienaTimeTest.Rd 2010-05-23 22:32:09 UTC (rev 86)
@@ -28,9 +28,7 @@
timetest <- sienaTimeTest(sienaFit)
\method{plot}{sienaTimeTest}(x, pairwise=FALSE, effects=1:2,
dims=c(2, 1), scale=.2, plevels=c(.1, .05, .025), multiplot=FALSE, ...)
-sienaEffects$timeDummy <- "2,4,6" #Include time dummies for periods
- # 2, 4, and 6
-sienaEffects$timeDummy <- "all" #Include all time dummies
+myeffects <- includeTimeDummy(sienaEffects, outdegree, timeDummy="all")
}
\arguments{
\item{sienaFit}{ A sienaFit object returned by \code{siena07}. }
@@ -97,7 +95,8 @@
If it is determined that a time heterogeneity occurs for any number of
time periods or effects (or any combination therein), the
\code{timeDummy} column provides facilities within a sienaFit object to
- quickly adjust the model and re-estimate in the usual way.
+ quickly adjust the model and re-estimate in the usual way. Alternately,
+ the includeTimeDummy function can be used to add the desired dummies.
}
\value{
@@ -133,8 +132,7 @@
mynet1 <- sienaNet(array(c(s501, s502, s503), dim=c(50, 50, 3)))
mydata <- sienaDataCreate(mynet1)
myeff <- getEffects(mydata)
-myeff$include[myeff$shortName=='transTrip' & myeff$type=='eval'] <- TRUE
-myeff$include[myeff$shortName=='balance' & myeff$type=='eval'] <- TRUE
+myeff <- includeEffects(myeff, transTrip, balance)
ans <- siena07(mymodel, data=mydata, effects=myeff, batch=TRUE)
## Conduct the score type test to assess whether heterogeneity is present.
@@ -142,8 +140,7 @@
## Suppose that we wish to include two time dummies.
## Add them in the following way:
-myeff$timeDummy[myeff$shortName=='recip' & myeff$type=='eval'] = "2"
-myeff$timeDummy[myeff$shortName=='balance' & myeff$type=='eval'] = "2"
+myeff <- includeTimeDummy(myeff, recip, balance, timeDummy="2")
ans2 <- siena07(mymodel, data=mydata, effects=myeff, batch=TRUE)
## Re-assess the time heterogeneity
@@ -157,12 +154,10 @@
mynet1 <- sienaNet(array(c(s501, s502, s503, s501, s503, s502), dim=c(50, 50, 6)))
mydata <- sienaDataCreate(mynet1)
myeff <- getEffects(mydata)
-myeff$include[myeff$shortName=='transTrip' & myeff$type=='eval'] <- TRUE
-myeff$include[myeff$shortName=='balance' & myeff$type=='eval'] <- TRUE
-myeff$timeDummy[myeff$shortName=='recip' & myeff$type=='eval'] = "2,3,5"
-myeff$timeDummy[myeff$shortName=='balance' & myeff$type=='eval'] = "2,5"
-myeff$timeDummy[myeff$shortName=='recip' & myeff$type=='eval'] = "4"
-myeff$timeDummy[myeff$shortName=='density' & myeff$type=='eval'] = "all"
+myeff <- includeEffects(myeff, transTrip, balance)
+myeff <- includeTimeDummy(myeff, recip, timeDummy="2,3,5")
+myeff <- includeTimeDummy(myeff, balance, timeDummy="4")
+myeff <- includeTimeDummy(myeff, density, timeDummy="all")
ansp <- siena07(mymodel, data=mydata, effects=myeff, batch=FALSE)
ttp <- sienaTimeTest(ansp)
More information about the Rsiena-commits
mailing list