-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwrite_test_data.R
136 lines (124 loc) · 10.6 KB
/
write_test_data.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
#' This function writes dummy data that is used in the "Introduction" vignette
#' @name write_test_data
#' @param nyears scalar, number of years in the model
#' @param ewaa_vector vector of empirical weight-at-age, length nyears * nages
#' @param catch_index_v list with two entries, one named "values" and one named "errors" corresponding to catch, each list entry has length nyears
#' @param survey_index_v list with two entries, one named "values" and one named "errors" corresponding to index, each list entry has length nyears
#' @param catch_comp_csv a string with the name of the .csv file containing the catch age composition data, if NULL (the default) dummy data are used
#' @param survey_comp_csv a string with the name of the .csv file containing the survey age composition data, if NULL (the default) dummy data are used
write_test_data <- function(nyears, ewaa_vector = NULL, catch_index_v = NULL, survey_index_v = NULL, catch_comp_csv = NULL, survey_comp_csv = NULL){
if(!is.null(ewaa_vector)){
empirical_weight <- ewaa_vector
} else{
empirical_weight<- c(0.5306555, 1.1963283, 2.0582654, 3.0349873, 4.0552124, 5.0646975, 6.0262262, 6.9169206, 7.7248909, 8.4461128, 9.0818532, 9.636695,
rep(c(0.5306555, 1.1963283, 2.0582654, 3.0349873, 4.0552124, 5.0646975, 6.0262262, 6.9169206, 7.7248909, 8.4461128, 9.0818532, 9.636695),29))
}
if(!is.null(catch_index_v)){
if(!names(catch_index_v)==c("values","error")){
stop("Error: catch index must have names of values and error.")
} else{
if((length(catch_index_v$values)!=nyears)|(length(catch_index_v$error))){
stop("Error: catch_index$values and catch_index$error must have one entry corresponding to each year.")
}
}
catch_index <- catch_index_v
} else{
catch_index <- list("values"=c(160.9729922, 469.039834, 767.2392242, 995.4491466, 760.1287713, 1330.812956,
1293.228597, 2476.815314, 1325.554509, 1523.691282, 1621.524464, 1611.573564,
1113.866103, 1538.117519, 1508.500687, 1266.046142, 2238.86148, 1607.917363,
1453.868581, 1295.528013, 1613.812022, 1072.966713, 1636.167979, 1210.822294,
1129.045115, 964.3269465, 923.3521247, 1218.20288, 881.6275361, 1270.847518), "error"=rep(0.01,30))
}
if(!is.null(survey_index_v)){
if(!names(survey_index_v)==c("values","error")){
stop("Error: survey index must have names of values and error.")
} else{
if((length(survey_index_v$values)!=nyears)|(length(survey_index_v$error))){
stop("Error: survey_index$values and survey_index$error must have one entry corresponding to each year.")
}
}
survey_index <- survey_index_v
} else{
survey_index<- list("values" = c(1.769444064, 1.507772568, 1.533016092, 1.616248667, 1.383168775, 1.616386391, 1.412438781, 1.312749108,
1.196086699, 1.100803192, 1.237393383, 1.059375707, 0.960531835, 0.975227232, 1.029677793, 0.859372577,
0.920958391, 0.702236849, 0.910970335, 0.671124274, 0.771789588, 0.636336668, 0.602957579, 0.66842653,
0.501908084, 0.462440308, 0.537562886, 0.564409646, 0.566285357, 0.495778669),
"error"=rep(0.2, 30))
}
if(!is.null(catch_comp_csv)){
catch_comp<- read.csv(catch_comp_csv)
} else{
catch_comp <- list("values"=c(0.075, 0.085, 0.105, 0.11, 0.1, 0.08, 0.1, 0.065, 0.065, 0.005, 0.055, 0.155,
0.07, 0.15, 0.125, 0.13, 0.095, 0.04, 0.07, 0.075, 0.025, 0.055, 0.05, 0.115,
0.075, 0.155, 0.11, 0.11, 0.135, 0.045, 0.075, 0.065, 0.04, 0.035, 0.025, 0.13,
0.075, 0.09, 0.12, 0.165, 0.095, 0.07, 0.09, 0.06, 0.06, 0.03, 0.02, 0.125,
0.115, 0.05, 0.11, 0.175, 0.1, 0.04, 0.085, 0.05, 0.045, 0.03, 0.035, 0.165,
0.075, 0.14, 0.12, 0.085, 0.085, 0.105, 0.085, 0.06, 0.055, 0.04, 0.025, 0.125,
0.09, 0.125, 0.195, 0.06, 0.105, 0.075, 0.055, 0.095, 0.055, 0.035, 0.015, 0.095,
0.065, 0.11, 0.135, 0.195, 0.075, 0.07, 0.095, 0.035, 0.055, 0.03, 0.015, 0.12,
0.105, 0.165, 0.155, 0.155, 0.12, 0.065, 0.05, 0.05, 0.02, 0.015, 0.015, 0.085,
0.07, 0.115, 0.145, 0.125, 0.17, 0.105, 0.035, 0.04, 0.045, 0.03, 0.02, 0.1,
0.085, 0.18, 0.115, 0.14, 0.095, 0.07, 0.075, 0.055, 0.02, 0.025, 0.045, 0.095,
0.105, 0.13, 0.16, 0.095, 0.13, 0.06, 0.085, 0.085, 0.03, 0.015, 0.025, 0.08,
0.1, 0.135, 0.16, 0.135, 0.09, 0.1, 0.065, 0.07, 0.055, 0.01, 0.01, 0.07,
0.085, 0.12, 0.18, 0.17, 0.11, 0.06, 0.075, 0.035, 0.055, 0.03, 0.01, 0.07,
0.075, 0.145, 0.215, 0.09, 0.135, 0.085, 0.06, 0.025, 0.055, 0.015, 0.02, 0.08,
0.125, 0.105, 0.205, 0.125, 0.095, 0.09, 0.05, 0.035, 0.045, 0.035, 0.02, 0.07,
0.12, 0.14, 0.155, 0.145, 0.125, 0.075, 0.075, 0.03, 0.045, 0.025, 0.01, 0.055,
0.085, 0.215, 0.16, 0.12, 0.12, 0.04, 0.075, 0.075, 0.04, 0.015, 0.03, 0.025,
0.105, 0.135, 0.22, 0.18, 0.095, 0.085, 0.065, 0.05, 0.02, 0.015, 0.005, 0.025,
0.12, 0.14, 0.16, 0.215, 0.135, 0.035, 0.065, 0.04, 0.015, 0.015, 0.01, 0.05,
0.16, 0.14, 0.145, 0.14, 0.125, 0.085, 0.06, 0.045, 0.02, 0.025, 0.01, 0.045,
0.165, 0.265, 0.135, 0.135, 0.06, 0.07, 0.055, 0.02, 0.01, 0.03, 0.015, 0.04,
0.11, 0.245, 0.23, 0.085, 0.11, 0.09, 0.055, 0.025, 0, 0.01, 0, 0.04,
0.165, 0.235, 0.23, 0.17, 0.055, 0.06, 0.03, 0.02, 0.005, 0.005, 0.01, 0.015,
0.165, 0.155, 0.205, 0.18, 0.13, 0.06, 0.035, 0.02, 0.02, 0.005, 0.005, 0.02,
0.12, 0.185, 0.19, 0.14, 0.185, 0.085, 0.02, 0.015, 0.03, 0.015, 0.005, 0.01,
0.165, 0.185, 0.19, 0.13, 0.11, 0.085, 0.05, 0.03, 0.01, 0.025, 0, 0.02,
0.19, 0.2, 0.135, 0.175, 0.09, 0.07, 0.07, 0.045, 0.01, 0, 0, 0.015,
0.18, 0.22, 0.155, 0.135, 0.125, 0.065, 0.07, 0.025, 0.015, 0.005, 0.005, 0,
0.145, 0.255, 0.215, 0.135, 0.07, 0.08, 0.02, 0.035, 0.02, 0.005, 0.005, 0.015),
"sample_size"=rep(200,30))
#write.csv(catch_comp, file="inst/extdata/catch_comp_1.csv")
}
if(!is.null(survey_comp_csv)){
survey_comp <- read.csv(survey_comp_csv)
} else{
survey_comp<- list("values"=c(0.04, 0.12, 0.155, 0.15, 0.15, 0.06, 0.085, 0.03, 0.035, 0.03, 0.01, 0.135,
0.07, 0.135, 0.135, 0.095, 0.11, 0.07, 0.105, 0.045, 0.045, 0.025, 0.04, 0.125,
0.085, 0.165, 0.12, 0.13, 0.115, 0.065, 0.045, 0.045, 0.04, 0.045, 0.01, 0.135,
0.05, 0.12, 0.195, 0.15, 0.125, 0.085, 0.06, 0.03, 0.035, 0.035, 0.025, 0.09,
0.04, 0.17, 0.12, 0.17, 0.105, 0.07, 0.045, 0.065, 0.035, 0.045, 0.01, 0.125,
0.085, 0.155, 0.13, 0.155, 0.105, 0.055, 0.06, 0.055, 0.045, 0.045, 0.01, 0.1,
0.085, 0.17, 0.235, 0.08, 0.13, 0.065, 0.055, 0.045, 0.025, 0.01, 0.04, 0.06,
0.07, 0.125, 0.2, 0.18, 0.07, 0.075, 0.065, 0.03, 0.045, 0.02, 0.02, 0.1,
0.07, 0.165, 0.145, 0.135, 0.15, 0.07, 0.06, 0.05, 0.035, 0.015, 0.025, 0.08,
0.065, 0.16, 0.16, 0.12, 0.14, 0.085, 0.055, 0.03, 0.035, 0.05, 0.01, 0.09,
0.105, 0.205, 0.14, 0.12, 0.08, 0.105, 0.055, 0.04, 0.02, 0.025, 0.02, 0.085,
0.09, 0.21, 0.155, 0.095, 0.12, 0.07, 0.07, 0.05, 0.04, 0.02, 0.02, 0.06,
0.115, 0.1, 0.19, 0.175, 0.09, 0.075, 0.055, 0.045, 0.025, 0.005, 0.02, 0.105,
0.065, 0.16, 0.18, 0.155, 0.095, 0.055, 0.075, 0.025, 0.025, 0.04, 0.025, 0.1,
0.09, 0.205, 0.15, 0.095, 0.15, 0.1, 0.07, 0.045, 0.01, 0.03, 0.02, 0.035,
0.09, 0.16, 0.18, 0.165, 0.095, 0.11, 0.035, 0.045, 0.025, 0.02, 0.025, 0.05,
0.14, 0.19, 0.17, 0.145, 0.065, 0.06, 0.07, 0.045, 0.03, 0.015, 0.005, 0.065,
0.055, 0.225, 0.28, 0.115, 0.105, 0.07, 0.045, 0.035, 0.015, 0.01, 0.015, 0.03,
0.08, 0.155, 0.255, 0.2, 0.085, 0.055, 0.025, 0.02, 0.035, 0.015, 0.025, 0.05,
0.07, 0.23, 0.175, 0.145, 0.135, 0.045, 0.06, 0.04, 0.035, 0.02, 0.015, 0.03,
0.16, 0.205, 0.21, 0.105, 0.1, 0.045, 0.05, 0.035, 0.015, 0.02, 0.005, 0.05,
0.12, 0.255, 0.16, 0.09, 0.095, 0.105, 0.065, 0.025, 0.025, 0.015, 0.005, 0.04,
0.115, 0.225, 0.29, 0.125, 0.065, 0.055, 0.03, 0.03, 0.015, 0.01, 0.015, 0.025,
0.095, 0.23, 0.24, 0.2, 0.085, 0.025, 0.04, 0.02, 0.01, 0.025, 0.005, 0.025,
0.11, 0.23, 0.185, 0.19, 0.125, 0.055, 0.025, 0.025, 0.02, 0.01, 0, 0.025,
0.08, 0.265, 0.165, 0.13, 0.185, 0.075, 0.055, 0.015, 0.01, 0.015, 0, 0.005,
0.125, 0.225, 0.275, 0.135, 0.1, 0.06, 0.045, 0.02, 0.005, 0, 0.005, 0.005,
0.13, 0.285, 0.185, 0.195, 0.1, 0.025, 0.045, 0.02, 0, 0, 0.005, 0.01,
0.135, 0.3, 0.245, 0.1, 0.1, 0.035, 0.02, 0.025, 0.025, 0.01, 0.005, 0,
0.11, 0.285, 0.225, 0.17, 0.05, 0.065, 0.02, 0.01, 0.035, 0.01, 0.005, 0.015), "sample_size"=rep(200,30))
#write.csv(survey_comp,"inst/extdata/survey_comp_1.csv")
}
return(list("ewaa"=empirical_weight,
"catch_index"=catch_index,
"survey_index"=survey_index,
"catch_comp"=catch_comp,
"survey_comp"=survey_comp))
}