Learn R Programming

sna (version 2.8)

npostpred: Take Posterior Predictive Draws for Functions of Networks

Description

npostpred takes a list or data frame, b, and applies the function FUN to each element of b's net member.

Usage

npostpred(b, FUN, ...)

Value

A series of posterior predictive draws

Arguments

b

A list or data frame containing posterior network draws; these draws must take the form of a graph stack, and must be the member of b referenced by "net"

FUN

Function for which posterior predictive is to be estimated

...

Additional arguments to FUN

Author

Carter T. Butts buttsc@uci.edu

Details

Although created to work with bbnam, npostpred is quite generic. The form of the posterior draws will vary with the output of FUN; since invocation is handled by apply, check there if unsure.

References

Gelman, A.; Carlin, J.B.; Stern, H.S.; and Rubin, D.B. (1995). Bayesian Data Analysis. London: Chapman and Hall.

See Also

bbnam

Examples

Run this code
#Create some random data
g<-rgraph(5)
g.p<-0.8*g+0.2*(1-g)
dat<-rgraph(5,5,tprob=g.p)

#Define a network prior
pnet<-matrix(ncol=5,nrow=5)
pnet[,]<-0.5
#Define em and ep priors
pem<-matrix(nrow=5,ncol=2)
pem[,1]<-3
pem[,2]<-5
pep<-matrix(nrow=5,ncol=2)
pep[,1]<-3
pep[,2]<-5

#Draw from the posterior
b<-bbnam(dat,model="actor",nprior=pnet,emprior=pem,epprior=pep,
    burntime=100,draws=100)
#Plot a summary of the posterior predictive of reciprocity
hist(npostpred(b,grecip))

Run the code above in your browser using DataLab