Description Usage Arguments Value Examples
The incorporation of random effects accounts for heterogeneity contributed by individual aptitudes of the individuals concerned. The baseline rate is then scaled by the random effects.
1 | mcmcre(formatteddata, its, pilot_tuner1, pilot_tuner2, start1, start2)
|
formatteddata |
Formatted data using the function FormatData |
its |
Number of iterations |
pilot_tuner1 |
Tuner for the social parameter |
pilot_tuner2 |
Tuner for the asocial parameter |
start1 |
Start value for the social parameter |
start2 |
Start value for the asocial parameter |
The output is a list that contains: (i) The siumulated values for each parameter (ii) The posterior summaries each random effect parameter, (iii) The posterior summaries for the social and asocial parameters Trace plots for the social and asocial parameters are provided together with a density and acf plot for the social parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # library(calibrate)
# loading the x and y spatial coordinates to construct the spatially derived
#social network
data(Xx)
data(Yy)
X <- cbind(Xx,Yy)
plot(X[,1],X[,2],pch=16,cex=1,xlim=c(0,1),ylim=c(0,1),xlab="x",
ylab="y",main="",cex.axis=2,cex.lab=2)
areas = calculate.areas(X[,1], X[,2], rep(0.2,length(X[,1])), 1000)
spatialareas = areas
len = length(X[,1])
spatialnetwork = matrix(0,nrow=len,ncol=len)
for(i in 1:len){
for(j in i:len){
template = spatialareas[[i]][j]
spatialnetwork[i,j] = spatialnetwork[j,i] = template
#spatialareas[[i]]=NULL
}
}
# loading the times and ids to plot the diffusion times and run nbda
data(Times)
data(Ids)
numdiff = 10
plot_colors = colors()[c(12,28,31,32,34,37,41,47,59,62,146,176,258,117,154,625,563,376,113,556)]
for(i in 1:numdiff){
a = (i-1) * (len)
b = a + (len)
startindex = a + 1
endindex = b
plot(Times[startindex:endindex,1],c(1:len),type="o",lwd=4,col=plot_colors[i],ylab="Solver index",
main="",xlab="Time(s)",yaxt='n',ylim=c(0,len),xlim=range(Times))
#textxy(c(1:len), Times[startindex:endindex,1], Ids[startindex:endindex,1],cex = .8,col="red")
par(new=TRUE)
}
par(new=TRUE)
plot( Times[1:len,1],c(1:len),type="o",lwd=4,col=plot_colors[1],ylab="",main="",xlab="",
ylim=c(0,len),xlim=range(Times))
Diffusions = rep(1,len)
for(i in 2:numdiff){
addon = rep(i,len)
Diffusions = c(Diffusions,addon)
}
Groups = rep(1,length(Times[,1]))
Events = c(1:length(Times[,1]))
space = rep(1,length(Times[,1]))
spatialnetwork = 1*spatialnetwork
shape = FormatData(Times[,1],spatialnetwork,Ids[,1],Groups,Diffusions,Events,spatialnetwork)
# running nbda to obtain posterior estimates of the social and
# baseline rate parameters
#ptm <- proc.time()
#mcmc(shape,10000,0.05,0.05,-3,-5)
#proc.time() - ptm
# running nbda to obtain posterior estimates of the
# social, baseline rate and random effect parameters
#ptm <- proc.time()
#mcmcre(shape,10000,0.05,0.05,-3,-5)
#proc.time() - ptm
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.