-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpost-6.R
80 lines (70 loc) · 2.44 KB
/
post-6.R
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
##
## http://edustatistics.org/mcmcinirt/setup/post-6.R
##
##
## Last update: 24-Oct-2013 by Nathan VanHoudnos
## Set the required package list
required.packages <- c("coda")
## Function to load R code
## ... based off of:
## http://stackoverflow.com/a/12195574/419842
source.setup <- function( code.to.run ) {
url <- paste("http://edustatistics.org/mcmcinirt/setup/",
code.to.run,sep="")
tryCatch( source(url),
error=function(cond) {
message(paste("Error with URL:\n\n ", url,'\n'))
message(cond)
message("\n")
stop("Stopping script.")
},
warning=function(cond) {
message(paste("Error with URL:\n\n ", url,'\n'))
message(cond)
message("\n")
stop("Stopping script.")
})
}
cat('Attempting to load required packages...\n')
for (pkg in required.packages) {
if( pkg %in% rownames(installed.packages()) ) {
require(pkg, character.only=TRUE)
} else {
tmp.msg <- paste('\n The required package "', pkg, '" is not installed on your system. \n', sep="")
tmp.msg <- paste(tmp.msg, 'Please install it by copying the line below and pasting it\n into your R session: \n\n')
tmp.msg <- paste(tmp.msg,' install.packages("',pkg,'")\n\n',sep="")
stop(tmp.msg)
}
}
cat('Attempting to load previous R code...\n')
cat(' ... from Post 2\n')
source.setup( "post-2-generate-2pl-data-set-parameters.R" )
source.setup( "post-2-generate-2pl-data-calc-U.R" )
source.setup( "post-2-equate-functions.R" )
cat(' ... from Post 3\n')
source.setup( "post-3-function-blocked-mcmc-update.R")
source.setup( "post-3-mh-gibbs-shell-setup.R" )
source.setup( "post-3-mh-gibbs-shell.R" )
source.setup( "post-3-mh-gibbs-shell-run-A-setup.R" )
source.setup( "post-3-get-2pl-params.R")
cat(' ... from Post 4\n')
source.setup( "post-4-function-log-prob.R")
source.setup( "post-4-function-sample-th.R")
cat(' ... from Post 5\n')
source.setup( "post-4-function-sample-th.R")
source.setup( "post-5-function-mh-sample.R")
source.setup( "post-5-function-sample-th-refactor.R")
##
cat(' ... ... Implement sample.th.refactor as sample.th\n')
sample.th <- sample.th.refactor
rm(sample.th.refactor)
##
##
source.setup( "post-5-function-prop-th-abl.R")
source.setup( "post-5-function-th-abl-cc.R")
cat(' ... from Post 6\n')
source.setup( "post-6-function-generic-normal-proposal.R")
source.setup( "post-6-function-prop-th-abl-refactor.R")
## Clean up
rm(source.setup, required.packages)
cat("Done.\n")