[statnet_help] Troubleshooting for Relational Event Models

Michael Heaney mheaney at umich.edu
Tue Apr 14 15:31:04 PDT 2020


Dear Statnet Community,

I would most appreciate any assistance in troubleshooting for a Relational
Event Model.

I am mimicking Section 3 of "Modeling Relational Event Dyanmics with
statnet", which is available here: https://github.com/statnet/Workshops/wiki

The code works fine when I use the data provided by the workshop. I only
get the error when using my own data.

Everything works in the code until the semifinal line, after which I get
the following error:

Error in check.objfun.output(out, minimize, d) :
objfun returned value that is NA or NaN

I have posted my adapted code below. The problem is evident after the line
that starts with gamma.fit2<-rem( . . .

Here is the code:

# Open Libraries

library(statnet)
library(relevent)
library(informR)

# Read Data

data <- read.csv("Hashtags_More_Than_Once_and_Attributes_2020-04-12.csv",
header=TRUE,stringsAsFactors=FALSE)

rawevents<-cbind(data$handle, data$hashtag)

evls<-gen.evl(rawevents)

names(evls) # See the structure of the evls object
length(evls$eventlist) # N
evls$eventlist[[1]] # The first event history in the eventlist
evls$event.key # The event.key maps the tokens to the event type names.

alpha.ints <- gen.intercepts(evls)

# Examine the structure of the alpha.ints statslist

length(alpha.ints) # N
dim(alpha.ints[[1]][[1]])
alpha.ints[[1]][[1]][1,,]

alpha.fit<-rem(eventlist=evls$eventlist,statslist=alpha.ints,
estimator="BPM",prior.param=list(mu=0,sigma=100,nu=4))
summary(alpha.fit)

pois.mle<-log(prop.table(table(data$handle))[-c(7,10)]
/prop.table(table(data$handle))[10])
round(cbind(BPM=alpha.fit$coef[order(names(alpha.fit$coef))],pois.mle),4)

a1<-paste(evls$event.key[-9,1],evls$event.key[-9,1],sep="") # All inertial
terms
a1

set.seed(12345)
inds<-sample(1:length(evls$eventlist),500)
evls$eventlist<-evls$eventlist[inds]
alpha.ints<-alpha.ints[inds]

beta.sforms<-gen.sformlist(evls,a1)

evls$eventlist$trumprussia

beta.sforms$"trumprussia"[1:4,,c("aa","bb")]

beta.ints<-slbind(beta.sforms,alpha.ints,type=1,new.names=TRUE,event.key=evls$event.key)

beta.fit<-rem(evls$eventlist,beta.ints,estimator="BPM",
prior.param=list(mu=0,sigma=100,nu=4))

round(cbind(BPM=beta.fit$coef[13:25],Z=beta.fit$coef[13:25]/beta.fit$sd[13:25]),4)

beta.sansints<-sfl2statslist(beta.sforms)

a2<-c("a(c|h)b","ad+b")
gamma.sforms<-gen.sformlist(evls,a2)
gamma.ints<-slbind(gamma.sforms,beta.ints,new.names=TRUE,event.key=evls$event.key)

gamma.fit<-rem(evls$eventlist,gamma.ints,estimator="BPM",
prior.param=list(mu=0,sigma=100,nu=4))
summary(gamma.fit)

moveon.sfs<-paste("a",letters[2:14],"a",sep="")
moveon.sfs

moveon.sforms<-glb.sformlist(evls,sforms=list(moveon.sfs),new.names="InterMoveOn")
moveon.ints<-slbind(moveon.sforms, gamma.ints)
moveon.fit<-rem(evls$eventlist,moveon.ints,estimator="BPM",
prior.param=list(mu=0,sigma=100,nu=4))
round(cbind(BPM=moveon.fit$coef,Z=moveon.fit$coef/moveon.fit$sd)[26:28,],4)

delta.ints<-sldrop(moveon.ints,varname=c("InterMoveOn","publicipublici"))
delta.fit<-rem(evls$eventlist,delta.ints) # fit it.
names(delta.fit$coef)

c(delta.fit$BIC,moveon.fit$BIC)

sl.ind<-87:88

New.evs<-unlist(glapply(data$New,data$hashtag,unique,regroup=FALSE))

New.evs<-ifelse(New.evs==1,1,0)[inds]

gamma.ints2<-slbind.cond(New.evs,gamma.ints,sl.ind=sl.ind,var.suffix="NEW")
sl.ind<-87:90
gamma.fit2<-rem(evls$eventlist,gamma.ints2,estimator="BPM", prior.param=
list(mu=0,sigma=100,nu=4))
round(cbind(BPM=gamma.fit2$coef[sl.ind],Z=gamma.fit2$coef[sl.ind]/gamma.fit2$sd[sl.ind]),4)

--
Michael T. Heaney, Ph.D.
Adjunct Research Professor
Institute for Research on Women and Gender
University of Michigan
1136 Lane Hall
204 S. State Street
Ann Arbor, MI 48109-1290 USA

Phone: +1.734.764.9537
E-mail: mheaney at umich.edu <michaeltheaney at gmail.com>
http://www.michaeltheaney.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman13.u.washington.edu/pipermail/statnet_help/attachments/20200414/f62d538d/attachment.html>


More information about the statnet_help mailing list