# \donttest{
#example analyses
#generate example data
set.seed(234)
n <- 50
d1 <- .2
Wadj1 <- sna::rgraph(n, tprob=d1, mode="graph")
W1 <- sna::make.stochastic(Wadj1, mode="row")
d2 <- .4
Wadj2 <- sna::rgraph(n, tprob=d2, mode="graph")
W2 <- sna::make.stochastic(Wadj2, mode="row")
# set rho, beta, sigma2, and generate y
rho1 <- .3
K <- 3
beta <- rnorm(K)
sigma2 <- 1
X <- matrix(c(rep(1, n), rnorm(n*(K-1))), nrow=n, ncol=K)
y <- c((solve(diag(n) - rho1*W1))%*%(X%*%beta + rnorm(n)))
#Bayesian estimation of NAM with a single weight matrix using a flat prior for rho
best1 <- banam(y,X,W1)
print(best1)
#Bayesian estimation of NAM with two weight matrices using standard normal priors
best2 <- banam(y,X,W=list(W1,W2))
print(best2)
#Bayes factor testing of equality/order hypotheses using environment of package 'BFpack'
BFbest2 <- BF(best2,hypothesis="rho1>rho2>0; rho1=rho2>0; rho1=rho2=0")
# }
Run the code above in your browser using DataLab