0

I wanna do bootstrapping on my data using popbio's boot.transitions function. However, it is somehow giving a weird error with the fertility column:

stagefate = read.table("file.csv", header = TRUE, sep=",")
stagefatenames<- c("individual", "stage", "fate","fertility")
trans2.3 <- stagefate[stagefatenames]

boot2.3 <- boot.transitions(trans2.3, 100)
ci2.3 <- quantile(boot2.3$lambda, c(0.025, 0.975))
hist(boot2.3$lambda, col = "grey80", xlab = "Lambda", main = "")
abline(v = ci2.3, lty = 3)
dput(trans2.3)

50+ errors:

Missing a fertility column with individual fertility rates

Which I both don't really understand. I have added a column 'fertility', not sure how it's not seeing it and how to fix this.

Btw, my table looks like this:

  individual  stage     fate fertility
1          1 infant   infant         0
2          2 infant   infant         0
3          3 infant juvenile         0
4          4 infant juvenile         0
5          5 infant juvenile         0
6          6 juvenile adult          0
7          7 adult    adult          0
8          8 adult    adult          1
9          9 adult    adult          1

dput(trans2.3)

structure(list(individual = 1:9, stage = structure(c(2L, 2L, 
2L, 2L, 2L, 3L, 1L, 1L, 1L), .Label = c("adult", "infant", "juvenile"
), class = "factor"), fate = structure(c(2L, 2L, 3L, 3L, 3L, 
1L, 1L, 1L, 1L), .Label = c("adult", "infant", "juvenile"), class = 
"factor"), 
    fertility = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L)), row.names = c(NA, 
-9L), class = "data.frame")

edit: The data wasn't in the right format, and this fixed one previous error (error sorting matrix).

However the fertility error still persists. Anyway it is giving some output, which i find really strange and will probably be caused by the fertility error. The confidence intervals after bootstrapping for any data i put in are always under the value of 1, which is strange as our lambda's we calculate are never this low.

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
Kaiser
  • 41
  • 1
  • 3
  • You gave some of the required information for a question, which is helpful, but a little more is necessary. Is `boot.transitions()` a function that you wrote? Or it is a function from an additional library you're using? If it's from a library, which library? And we can see your data, but it's more useful if you also include the output from `dput(stagefate)`. Since, we don't know what `boot.transitions()` does, it's hard to say what's going wrong, but `trans2.3` is the same thing as `stagefate`. Not sure why you would duplicate the data frame and then use 2nd version with `boot.transitions`. – shea Dec 20 '18 at 18:42
  • @shea It looks like `boot.transitions` is a function in the `popbio` CRAN package mentioned in the title and first sentence. I edited/reformatted to make that clearer. – Ken Williams Dec 20 '18 at 19:24
  • @shea it's indeed a function of the library popbio, I should have been more cleae. I'm using trans2. 3, which is a subset of my data, because when this starts working I can make other subset for different years. – Kaiser Dec 20 '18 at 19:40
  • Is the table in the last code window supposed to be trans2.3? Can you add `dput(trans2.3)` to your post? – shea Dec 20 '18 at 22:21
  • @shea So there were indeed problems with my data, the matrix sorting error is fixed. As for now it only shows the fertility error. I added the dput output if it could provide some insight in the problem. I tried looking at the source code but I still don't understand why it's saying there's no fertility column – Kaiser Dec 21 '18 at 13:25
  • I don't know what the problem is. The example from the documentation works. Your table has a column called fertility and `boot.transitions()` doesn't seem to like it. The only difference I can see between your data and the practice data from the example is that your data has whole numbers and the practice data is decimal. I tried changing fertility to a decimal by `trans2.3$fertility <- trans2.3$fertility/sum(trans2.3$fertility)` (not really correct way to get the value), but it still didn't work. I think maybe you should email the package maintainer. check the documentation for the address. – shea Dec 21 '18 at 22:53
  • Thanks for your help Shea it's much appreciated, I did contact the package maintainer. – Kaiser Dec 22 '18 at 16:17

0 Answers0