testMatrix = matrix(rep(c(0,0,0,0), 1000), ncol = 4)
testVector = c(0,0,0,0)
##Standard multivariate normal proposal generator
testGenerator <- createProposalGenerator(covariance = c(1,1,1,1), message = TRUE)
methods(class = "proposalGenerator")
print(testGenerator)
x = testGenerator$returnProposal(testVector)
x
x <- testGenerator$returnProposalMatrix(testMatrix)
boxplot(x)
##Changing the covariance
testGenerator$covariance = diag(rep(100,4))
testGenerator <- testGenerator$updateProposalGenerator(testGenerator, message = TRUE)
testGenerator$returnProposal(testVector)
x <- testGenerator$returnProposalMatrix(testMatrix)
boxplot(x)
##-Changing the gibbs probabilities / probability to modify 1-n parameters
testGenerator$gibbsProbabilities = c(1,1,0,0)
testGenerator <- testGenerator$updateProposalGenerator(testGenerator)
testGenerator$returnProposal(testVector)
x <- testGenerator$returnProposalMatrix(testMatrix)
boxplot(x)
##-Changing the gibbs weights / probability to pick each parameter
testGenerator$gibbsWeights = c(0.3,0.3,0.3,100)
testGenerator <- testGenerator$updateProposalGenerator(testGenerator)
testGenerator$returnProposal(testVector)
x <- testGenerator$returnProposalMatrix(testMatrix)
boxplot(x)
##-Adding another function
otherFunction <- function(x) sample.int(10,1)
testGenerator <- createProposalGenerator(
covariance = c(1,1,1),
otherDistribution = otherFunction,
otherDistributionLocation = c(0,0,0,1),
otherDistributionScaled = TRUE
)
testGenerator$returnProposal(testVector)
x <- testGenerator$returnProposalMatrix(testMatrix)
boxplot(x)
table(x[,4])
Run the code above in your browser using DataLab