npostpred                package:sna                R Documentation

_T_a_k_e _P_o_s_t_e_r_i_o_r _P_r_e_d_i_c_t_i_v_e _D_r_a_w_s _f_o_r _F_u_n_c_t_i_o_n_s _o_f _N_e_t_w_o_r_k_s

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

     npostpred(b, FUN, ...)

_A_r_g_u_m_e_n_t_s:

       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' 

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     A series of posterior predictive draws

_A_u_t_h_o_r(_s):

     Carter T. Butts ctb@andrew.cmu.edu

_R_e_f_e_r_e_n_c_e_s:

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

_S_e_e _A_l_s_o:

     `bbnam'

_E_x_a_m_p_l_e_s:

     #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))

