• No results found

Examples for the lstbayes package Jeffrey B. Arnold July 6, 2018

N/A
N/A
Protected

Academic year: 2021

Share "Examples for the lstbayes package Jeffrey B. Arnold July 6, 2018"

Copied!
3
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Examples for the lstbayes package

Jeffrey B. Arnold

July 6, 2018

Some example programs typset using the listings language drivers provideb by the lstbayes package.

1

BUGS

(2)

2

JAGS

Linear regression example from John Myles White, http://www.johnmyleswhite. com/notebook/2010/08/20/using-jags-in-r-with-the-rjags-package/. model { f o r ( i in 1 :N) { y [ i ] ∼ dnorm ( y . h a t [ i ] , t a u ) y . h a t [ i ] ← a + b ∗ x [ i ] } a ∼ dnorm ( 0 , . 0 0 0 1 ) b ∼ dnorm ( 0 , . 0 0 0 1 ) t a u ← pow ( sigma , −2) sigma ∼ d u n i f ( 0 , 1 0 0 ) }

3

Stan

(3)

r e a l mu beta ; real<lower=0> s i g m a s q y ; real<lower=0> s i g m a s q a l p h a ; real<lower=0> s i g m a s q b e t a ; } transformed parameters { real<lower=0> s i g m a y ; real<lower=0> s i g m a a l p h a ; real<lower=0> s i g m a b e t a ; s i g m a y <− sqrt ( s i g m a s q y ) ; s i g m a a l p h a <− sqrt ( s i g m a s q a l p h a ) ; s i g m a b e t a <− sqrt ( s i g m a s q b e t a ) ; } model { r e a l p r e d [N∗T ] ; f o r ( n in 1 :N) f o r ( t in 1 :T) p r e d [ ( n−1)∗T + t ] <− fma( beta [ n ] , x m i n u s x b a r [ t ] , a l p h a [ n ] ) ; mu alpha ˜ normal ( 0 , 1 0 0 ) ; mu beta ˜ normal ( 0 , 1 0 0 ) ; s i g m a s q y ˜ inv gamma ( 0 . 0 0 1 , 0 . 0 0 1 ) ; s i g m a s q a l p h a ˜ inv gamma ( 0 . 0 0 1 , 0 . 0 0 1 ) ; s i g m a s q b e t a ˜ inv gamma ( 0 . 0 0 1 , 0 . 0 0 1 ) ; a l p h a ˜ normal ( mu alpha , s i g m a a l p h a ) ; // v e c t o r i z e d beta ˜ normal ( mu beta , s i g m a b e t a ) ; // v e c t o r i z e d

y l i n e a r ˜ normal ( pred , s i g m a y ) ; // v e c t o r i z e d }

Referenties

GERELATEERDE DOCUMENTEN

Every option can be used with \LPSet{option1 , option2 ,...} within the document, every option has a counterpart nooption and for every option x also an option

Numbers written in italic refer to the page where the corresponding entry is de- scribed; numbers underlined refer to the code line of the definition; numbers in roman refer to the

Aliquam pellentesque, augue quis sagittis posuere, turpis lacus congue quam, in hendrerit risus eros eget felis.. Maecenas eget erat in sapien

either duplex printing or printing two pages on one side of a sheet of paper with blank back side).. (These are the

Because the compilation time for this example is usually quite short, option timer is not demonstrated very

- negative Arabic numbers turned into upper-case Roman numbers (although historically there were no negative Roman numbers): \Romanbar{-12} prints -XII. - zero Arabic number

In the following three examples notice how I have scaled the total length of the scalebar by roughly the same scale as the font change to maintain a nice aspect ratio.. Make a

By virtue of natural reason, let us suppose that the transcendental unity of apperception abstracts from all content of knowledge; in view of these considerations, the Ideal of