File tree Expand file tree Collapse file tree 8 files changed +16
-16
lines changed
Bayesian_Cognitive_Modeling/ParameterEstimation Expand file tree Collapse file tree 8 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ rm(list=ls())
44library(rstan )
55
66# ### Notes to Stan model #######################################################
7- # # 1) Approach to this model can be difficult to understand for beginners.
8- # # Therefore I suggest either not trying to understand it and look on WinBUGS
9- # # version or go deep into Stan manual.
7+ # # Implementation of this model can be difficult to understand for beginners.
8+ # # Therefore I suggest either not trying to understand it and look on WinBUGS
9+ # # version or go deep into Stan manual.
1010# ###############################################################################
1111model <- "
1212# ChaSaSoon Censored Data
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ library(rstan)
99# # you change the values, you'll need to increment iterations significantly
1010# # 2) Code is quite dissimilar to original WinBUGS model - using conditionals
1111# # instead of step function. This will happen in further models more often.
12- # # There are difference in what functions are efficient in BUGS and Stan.
12+ # # There is a difference in what functions are efficient in BUGS and Stan.
1313# ###############################################################################
1414model <- "
1515// Change Detection
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ rm(list=ls())
44library(rstan )
55
66# ### Notes to Stan model #######################################################
7- # # 1) Multivariate normal distribution in Stan uses covariance matrix insted of
7+ # # 1) Multivariate normal distribution in Stan uses covariance matrix instead of
88# # precision matrix.
99# # 2) Multivariate normal distribution can be (and is) also vectorized.
1010# # 3) Warnings may occur during sampling, ignore them.
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ rm(list=ls())
44library(rstan )
55
66# ### Notes to Stan model #######################################################
7- # # 1) All notes from previsou model Correlation_1 also applies to this model.
7+ # # 1) All notes from previous model Correlation_1 also apply to this model.
88# # 2) If you change sigmaerror to c(0.03, 10) as suggested in excercise 5.2.2
99# # warning statements will be more frequent and posterior less smooth.
1010# ###############################################################################
Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ rm(list=ls())
44library(rstan )
55
66# ### Notes to Stan model #######################################################
7- # # 1) First time we use simplex data type. Simplex is similar to vector, but
8- # # with a property that sum of all it's elements is equal to 1.
7+ # # 1) This is the first time we use simplex data type. Simplex is similar to
8+ # # vector, but with a property that sum of all it's elements is equal to 1.
99# # 2) Sampling statements for parameters alpha, beta and gamma could be removed
1010# # leading to uniform prior on (0, 1) interval which is the same as beta(1, 1)
1111# # 3) Variable n was removed here. Stan doesn't need this information as
12- # # an argument for multinomial distribution. Always make sure, that you know
12+ # # an argument for multinomial distribution. Always make sure that you know
1313# # what arguments are required for a function / sampling statement. In many
1414# # cases these are different from BUGS. Very useful for this are last pages
1515# # of Stan manual
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ library(rstan)
55
66# ### Notes to Stan model #######################################################
77# # Stan has hypergeometric distribution implemented, so in one way the code
8- # # is more intuitive. On the other side , Stan can't sample discrete parameters
8+ # # is more intuitive. On the other hand , Stan can't sample discrete parameters,
99# # therefore we have to increment log probability manually (as we did in
1010# # Survey example).
1111# ###############################################################################
Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ library(rstan)
55
66# ### Notes to Stan model #######################################################
77# # 1) If parameter's prior distribution is not specified, Stan will assume that
8- # # you want it distributed uniformly with boundaries given by variable
9- # # constraints. Here constrains <lower=0,upper=10> gives uniform(0, 100)
10- # # 2) In Stan most of the sampling statements can be vectorized. In this example
11- # # you can see it in a statement for vector x. Instead of using for loop for
12- # # each element of the vector, we can simple write it as above. Saves code,
8+ # # you want it to be distributed uniformly with boundaries given by variable
9+ # # constraints. Here constrains <lower=0,upper=10> give uniform (0, 100)
10+ # # 2) In Stan, most of the sampling statements can be vectorized. In this example
11+ # # you can see it in the statement for vector x. Instead of using for loop for
12+ # # each element of the vector, we can simple write it as above. This saves code,
1313# # speeds up computation. For more information read Vectorization chapter in
1414# # the Stan manual (p.231 in version 2.4.0)
1515# ###############################################################################
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ library(rstan)
55
66# ### Notes to Stan model #######################################################
77# # 1) We used implicit uniform distribution for sigma and vector mu
8- # # 2) The second loop in this model (1:m) is unnecessary here. You can try to
8+ # # 2) The second loop in this model (1:m) is not necessary here. You can try to
99# # remove it, but don't forget to remove its index j. Remember vectorization!
1010# ###############################################################################
1111model <- "
You can’t perform that action at this time.
0 commit comments