I am trying to do stratified sampling in R using the stratified function in the splitstackshape package. I have four strata (labeled 1:4). When setting the size = 1, it returns one row belonging to each strata (great!). However, I'm not able to increase my sample size by one.
I want it to select 5 rows: 4 of them belonging to strata 1:4, and the fifth one belonging to strata #1 (the strata that covers the most amount of area in my study site); and ideally this will be done without replacement so the second row that is sampled from strata #1 will not be the same as the first.
Setting the size = 1 - 1.99 always returns 1 row from each strata (4 total). Setting the size = 2 returns 8 rows (2 from each strata).
Dataframe
homer_join_strat<- structure(list(cluster = c(4L, 3L, 4L, 5L, 5L, 4L, 4L, 4L, 5L,
5L, 5L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 5L, 1L, 1L, 5L, 4L, 4L,
4L), waterbody = c("Homer", "Homer", "Homer", "Homer", "Homer",
"Homer", "Homer", "Homer", "Homer", "Homer", "Homer", "Homer",
"Homer", "Homer", "Homer", "Homer", "Homer", "Homer", "Homer",
"Homer", "Homer", "Homer", "Homer", "Homer", "Homer", "Homer"
), transect_number = 1:26, BLG = c(75, 38.4204909284952, 77.634011090573,
82.1917808219178, 119.341563786008, 22.5422667501565, 155.275381552754,
81.1332904056665, 37.037037037037, 73.2824427480916, 71.608040201005,
208.806818181818, 116.504854368932, 119.775421085465, 104.408352668213,
117.391304347826, 12.0603015075377, 93.5593220338983, 166.795366795367,
20, 91.566265060241, 70.8860759493671, 0, 44.8765893792072, 0,
3.96563119629874), GSF = c(0, 6.4034151547492, 11.090573012939,
16.4383561643836, 4.11522633744856, 0, 0, 0, 0, 4.58015267175573,
0, 21.3068181818182, 0, 0, 6.96055684454756, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0), LMB = c(51.3157894736842, 83.2443970117396, 73.9371534195933,
71.2328767123288, 28.8065843621399, 37.5704445835942, 59.721300597213,
38.6349001931745, 66.6666666666667, 77.8625954198473, 67.8391959798995,
63.9204545454545, 46.6019417475728, 22.4578914535246, 6.96055684454756,
13.0434782608696, 24.1206030150754, 40.6779661016949, 60.2316602316602,
56, 28.9156626506024, 55.6962025316456, 20.2360876897133, 31.413612565445,
0, 31.7250495703899), YLB = c(0, 0, 14.7874306839187, 0, 4.11522633744856,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.63320463320463, 0, 0,
0, 0, 0, 0, 0), BLC = c(7.89473684210526, 12.8068303094984, 7.39371534195933,
10.958904109589, 0, 0, 3.9814200398142, 0, 3.7037037037037, 13.7404580152672,
11.3065326633166, 12.7840909090909, 3.88349514563107, 3.74298190892077,
0, 0, 0, 4.06779661016949, 0, 16, 9.63855421686747, 5.06329113924051,
20.2360876897133, 22.4382946896036, 0, 7.93126239259749), WHC = c(0,
0, 0, 0, 0, 0, 3.9814200398142, 0, 7.40740740740741, 0, 0, 0,
0, 7.48596381784155, 0, 0, 0, 0, 0, 0, 0, 10.126582278481, 0,
4.48765893792072, 0, 0), RSF = c(0, 0, 0, 0, 0, 0, 11.9442601194426,
0, 0, 13.7404580152672, 0, 0, 0, 0, 0, 0, 0, 0, 27.7992277992278,
0, 4.81927710843374, 0, 0, 4.48765893792072, 0, 0), CCF = c(0,
0, 0, 0, 0, 0, 0, 0, 3.7037037037037, 0, 0, 0, 3.88349514563107,
0, 0, 0, 0, 8.13559322033898, 0, 0, 0, 0, 0, 0, 0, 0), BLB = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8.52272727272727, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0)), class = "data.frame", row.names = c(NA,
-26L))
Code
stratified(homer_join_strat, "cluster", size=.06)
stratified(homer_join_strat, "cluster", size=.07)
stratified(homer_join_strat, "cluster", size=.09)
stratified(homer_join_strat, "cluster", size=2)
Does anyone have experience using this function to select a number of rows that does not equal or is not a multiple of the number of strata in the data?
I am able to have it select 1, 2, 3, rows (in order of square area) by setting the size = .06, .07, .09 respectively (why I thought a number between 1-1.99 would give me 5 rows selected
Thanks in advance!