Description Usage Arguments Details Value See Also Examples
This class contains the lexer and parser to create a model tree from the model string. To use this class, create an instance of it first. Then set the model string and data using the functions setModelString and setModelData. Afterwards use lexModel to create all object required to build the model. Than use parseModel to build the mode. This function will return the model tree that can be used in with sampler classed to sample from the model.
1 2 3 4 5 6 7 | lex = new('Lexer')
lex$setModelString(model_str)
lex$setModelData(data_list)
lex$lexModel()
root_plate = lex$parseModel()
|
mode_str |
Contains the model string |
data_list |
Is a named list with the data used to build the model. |
The language is very similar to the bugs language
Will return the build model tree if successful.
Package Overview:
Slice-Package
Base Sampler class:
Sampler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | require('Slice')
#define a regression model
my_model_str= "
model regModel{
#this is a comment
y~ dnorm(x*beta1 +beta0,sigma)
sigma~dgamma(0.01,0.01)
beta0 ~ dnorm(0,s)
s ~ dunif(0,1)
beta1 ~ dnorm(0,1) #one more comment
}
"
#generate some data
set.seed(1234)
n <- 100
beta <- c(1.4,-0.8)
sigma2 <- 1
X = cbind(rnorm(n,2,1),1)
val = X
y = matrix( val,ncol = 1)
x = matrix(X[,1],ncol = 1)
data_list = list('y'=y,'x'=x)
lex = new('Lexer') ##create lexer obj
lex$setModelString(my_model_str) #set model
lex$setModelData(data_list) # set data
lex$lexModel() ##lexx the syntax
root_plate = lex$parseModel() ##create the model
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.