-
Notifications
You must be signed in to change notification settings - Fork 2
/
scenario_sample_size.R
185 lines (171 loc) · 5.14 KB
/
scenario_sample_size.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#### Code to run scenarios - SAMPLE SIZE
# run all multiple times and save output
# all run as functions
# load packages needed to run in parallel
library(foreach)
library(doParallel)
# choose number of times to run
n_runs <- 500
# create a randomly generated string of seeds
# seed must be integer
seed <- sample(round(1:100000000),n_runs,replace=F)
#seed <- NULL
# set up the scenario with parameters that need to be changed
# set parameters
#source("setParams.R") # this is now redundant
source("run_scenario.R")
# change those that need changing
## STRUCTURED SAMPLE SIZE
structured_sample_size <- seq(50,500,50) # 10 scenarios
# structured model
mapply(FUN = run_scenario,
nsamp = structured_sample_size,
parameter = structured_sample_size,
MoreArgs = list(
model_type="structured",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Sample_size_",
dim = c(300,300),
lambda = -2,
env.beta = 2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.2,
qsize = 1,
rho = 0.99,
resolution = c(10,10),
correlation = FALSE)) # to use the function you must put in all parameters it is expecting
# unstructured model
run_scenario(nsamp = 150,
parameter = structured_sample_size[3],
model_type="unstructured",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Sample_size_",
dim = c(300,300),
lambda = -2,
env.beta = 2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.2,
qsize = 1,
rho = 0.99,
resolution = c(10,10),
correlation = FALSE) # to use the function you must put in all parameters it is expecting
# unstructuredcov model
run_scenario(nsamp = 150,
parameter = structured_sample_size[3],
model_type="unstructuredcov",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Sample_size_",
dim = c(300,300),
lambda = -2,
env.beta = 2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.2,
qsize = 1,
rho = 0.99,
resolution = c(10,10),
correlation = FALSE) # to use the function you must put in all parameters it is expecting
# joint model
mapply(FUN = run_scenario,
nsamp = structured_sample_size,
parameter = structured_sample_size,
MoreArgs = list(
model_type="joint",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Sample_size_",
dim = c(300,300),
lambda = -2,
env.beta = 2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.2,
qsize = 1,
rho = 0.99,
resolution = c(10,10),
correlation = FALSE)) # to use the function you must put in all parameters it is expecting
# jointcov model
mapply(FUN = run_scenario,
nsamp = structured_sample_size,
parameter = structured_sample_size,
MoreArgs = list(
model_type="jointcov",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Sample_size_",
dim = c(300,300),
lambda = -2,
env.beta = 2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.2,
qsize = 1,
rho = 0.99,
resolution = c(10,10),
correlation = FALSE)) # to use the function you must put in all parameters it is expecting
# joint2 model
mapply(FUN = run_scenario,
nsamp = structured_sample_size,
parameter = structured_sample_size,
MoreArgs = list(
model_type="jointtwo",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Sample_size_",
dim = c(300,300),
lambda = -2,
env.beta = 2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.2,
qsize = 1,
rho = 0.99,
resolution = c(10,10),
correlation = FALSE)) # to use the function you must put in all parameters it is expecting