Function to run the MCMC sampler to draw from the posterior distribution of intercept, slopes, and latent positions. HLSMrandomEF( ) fits random effects model; HLSMfixedEF( ) fits fixed effects model; LSM( ) fits single network model.
HLSMrandomEF(Y,edgeCov=NULL, receiverCov = NULL, senderCov = NULL,
FullX = NULL,initialVals = NULL, priors = NULL, tune = NULL,
tuneIn = TRUE,dd=2, niter)HLSMfixedEF(Y,edgeCov=NULL, receiverCov = NULL, senderCov = NULL,
FullX = NULL, initialVals = NULL, priors = NULL, tune = NULL,
tuneIn = TRUE,dd=2, niter)
LSM(Y,edgeCov=NULL, receiverCov = NULL, senderCov = NULL,
FullX = NULL,initialVals = NULL, priors = NULL, tune = NULL,
tuneIn = TRUE,dd=2, estimate.intercept=FALSE, niter)
getBeta(object, burnin = 0, thin = 1)
getIntercept(object, burnin = 0, thin = 1)
getLS(object, burnin = 0, thin = 1)
getLikelihood(object, burnin = 0, thin = 1)
input outcome for different networks. Y can either be
(i). list of sociomatrices for K
different networks (Y[[i]] must be a matrix with named rows and columns)
(ii). list of data frame with columns Sender
, Receiver
and Outcome
for K
different networks
(iii). a dataframe with columns named as follows: id
to identify network, Receiver
for receiver nodes, Sender
for sender nodes and finally, Outcome
for the edge outcome.
data frame to specify edge level covariates with
(i). a column for network id named id
,
(ii). a column for sender node named Sender
,
(iii). a column for receiver nodes named Receiver
, and
(iv). columns for values of each edge level covariates.
a data frame to specify nodal covariates as edge receivers with
(i.) a column for network id named id
,
(ii.) a column Node
for node names, and
(iii). the rest for respective node level covariates.
a data frame to specify nodal covariates as edge senders with
(i). a column for network id named id
,
(ii). a column Node
for node names, and
(iii). the rest for respective node level covariates.
list of numeric arrays of dimension n
by n
by p
of covariates for K different networks. When FullX is provided to the function, edgeCov, receiverCov and senderCov must be specified as NULL.
an optional list of values to initialize the chain. If NULL
default initialization is used, else
initialVals = list(ZZ, beta, intercept, alpha)
.
For fixed effect model beta
is a vector of length p
and intercept
is a vector of length 1.
For random effect model beta
is an array of dimension K
by p
, and intercept
is a vector of length K
, where p
is the number of covariates and K
is the number of network.
ZZ
is an array of dimension NN
by dd
, where NN
is the sum of nodes in all K
networks.
an optional list to specify the hyper-parameters for the prior distribution of the paramters.
If priors = NULL
, default value is used. Else,
priors=
list(MuBeta,VarBeta,MuZ,VarZ,PriorA,PriorB)
MuBeta
is a numeric vector of length PP + 1 specifying the mean of prior distribution for coefficients and intercept
VarBeta
is a numeric vector for the variance of the prior distribution of coefficients and intercept. Its length is same as that of MuBeta.
MuZ
is a numeric vector of length same as the dimension of the latent space, specifying the prior mean of the latent positions.
VarZ
is a numeric vector of length same as the dimension of the latent space, specifying diagonal of the variance covariance matrix of the prior of latent positions.
PriorA, PriorB
is a numeric variable to indicate the rate and scale parameters for the inverse gamma prior distribution of the hyper parameter of variance of slope and intercept
an optional list of tuning parameters for tuning the chain. If tune = NULL
, default tuning is done. Else,
tune = list(tuneBeta, tuneInt,tuneZ)
.
tuneBeta
and tuneInt
have the same structure as beta
and intercept
in initialVals
.
ZZ
is a vector of length NN
.
a logical to indicate whether tuning is needed in the MCMC sampling. Default is FALSE
.
dimension of latent space.
When TRUE, the intercept will be estimated. If the variance of the latent positions are of interest, intercept=FALSE will allow users to obtain a unique variance. The intercept can also be inputed by the user.
number of iterations for the MCMC chain.
object of class 'HLSM' returned by HLSM()
or HLSMfixedEF()
numeric value to burn the chain while extracting results from the 'HLSM'object. Default is burnin = 0
.
numeric value by which the chain is to be thinned while extracting results from the 'HLSM' object. Default is thin = 1
.
Returns an object of class "HLSM". It is a list with following components:
list of posterior draws for each parameters.
list of acceptance rates of the parameters.
the matched call.
final tuning values
The HLSMfixedEF
and HLSMrandomEF
functions will not automatically assess thinning and burn-in. To ensure appropriate inference, see HLSMdiag
.
See also LSM
for fitting network data from a single network.
Tracy M. Sweet, Andrew C. Thomas and Brian W. Junker (2013), "Hierarchical Network Models for Education Research: Hierarchical Latent Space Models", Journal of Educational and Behavorial Statistics.
# NOT RUN {
library(HLSM)
#Set values for the inputs of the function
priors = NULL
tune = NULL
initialVals = NULL
niter = 10
#Fixed effect HLSM on Pitt and Spillane data
fixed.fit = HLSMfixedEF(Y = ps.advice.mat, senderCov=ps.node.df,
initialVals = initialVals,priors = priors,
tune = tune,tuneIn = FALSE,dd = 2,niter = niter)
summary(fixed.fit)
lsm.fit = LSM(Y=School9Network,edgeCov=School9EdgeCov,
senderCov=School9NodeCov, receiverCov=School9NodeCov, niter = niter)
names(lsm.fit)
# }
Run the code above in your browser using DataLab