Last data update: 2014.03.03

R: Convert a vector to JAGS Probabilities
vectorProbsR Documentation

Convert a vector to JAGS Probabilities

Description

Probability vectors can be passed manually to the model, but they must be formatted in code appropriate to JAGS. vectorProbs will convert a vector of counts or weights to probabilities and format it into JAGS code.

Usage

vectorProbs(p, node, normalize = TRUE)

Arguments

p

a vector of counts, weights, or probabilities.

node

the node for the parameters. this is converted to a character string. It is important that this be given accurately or it will not match with the code written by writeNetworkModel.

normalize

A logical indicating if the weights in p should be normalized (each value is taken as a proportion of the sum).

Author(s)

Jarrod Dalton and Benjamin Nutter

Examples

vectorProbs(c(1, 2, 3), "wells")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HydeNet)
Loading required package: nnet
Loading required package: rjags
Loading required package: coda
Linked to JAGS 4.1.0
Loaded modules: basemod,bugs
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HydeNet/vectorProbs.Rd_%03d_medium.png", width=480, height=480)
> ### Name: vectorProbs
> ### Title: Convert a vector to JAGS Probabilities
> ### Aliases: vectorProbs
> 
> ### ** Examples
> 
> vectorProbs(c(1, 2, 3), "wells")
[1] "pi.wells[1] <- 0.166666666666667; pi.wells[2] <- 0.333333333333333; pi.wells[3] <- 0.5"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>