Checking the CIDnetworks Suite: Covariates (COV)

A.C. Thomas, November 22

r library(CIDnetworks)

Here we test the fitting and plotting options for COV.

Component alone, three covariates.

n.nodes <- 100; covs <- 3
test.cov <- COV(n.nodes=100, covariates=matrix(rbinom(covs*n.nodes*(n.nodes-1)/2, 1, 0.5), ncol=3), coef.cov=1:covs, generate=TRUE)
test.cov.pieces <- test.cov$pieces()
test.cov.value <- test.cov$value()

test.cov.gibbs <- test.cov$gibbs.full(draws=500, report=100, burnin=200, thin=2, make.random.start=TRUE)
test.cov$gibbs.plot(test.cov.gibbs)

test.cov.gibbs.unlist <- list.output.to.matrices (test.cov.gibbs)

test.cov.gibbs.value <- test.cov$gibbs.value(test.cov.gibbs)
plot(test.cov.gibbs.unlist$log.lik, main="Log-likelihood")
plot(test.cov.gibbs.unlist$coef.cov[1,], main=paste("Coefficient 1", test.cov.pieces$coef.cov[1])); abline(h=test.cov.pieces$coef.cov[1], lwd=3, col=2)

test.cov$plot.network()
test.cov$gibbs.plot(test.cov.gibbs)

test.cov$netplot(test.cov$edge.list, , colvalues=20, main="Oracle values")
test.cov$plot.network(test.cov.value)
test.cov$plot.network(apply(test.cov.gibbs.value, 1, mean))

Binary within CID:

test.cov.b <- CID.generate (n.nodes=100, components=list(COV(covariates=matrix(rbinom(covs*n.nodes*(n.nodes-1)/2, 1, 0.5), ncol=3), coef.cov=1:covs)), intercept=-3, residual.variance=2)


test.cov.b.pieces <- test.cov.b$pieces()
test.cov.b.value <- test.cov.b$value()

test.cov.b.gibbs <- test.cov.b$gibbs.full(draws=1000, report=100, burnin=1000, make.random.start=TRUE)
test.cov.b.gibbs.value <- test.cov.b$gibbs.value(test.cov.b.gibbs)

test.cov.b$gibbs.plot (test.cov.b.gibbs)

color.range <- range(c(test.cov.b.value, apply(test.cov.b.gibbs.value, 1, mean)))
test.cov.b$plot.network(test.cov.b.value)
test.cov.b$plot.network(apply(test.cov.b.gibbs.value, 1, mean))


plot(jitter(test.cov.b.value), jitter(apply(test.cov.b.gibbs.value, 1, mean)))


Try the CIDnetworks package in your browser

Any scripts or data that you put into this service are public.

CIDnetworks documentation built on May 30, 2017, 4:10 a.m.