You could use the group argument, in connection with a statistic
that returns a vector, one value for each group. The basic idea is:
bootstrap(data, group = Year,
statistic = groupSums(TotalTrout, Year) / groupSums(TotalHours, Year))
Tim Hesterberg
>Hello,
>
>I am using the resample library with angler catch rate data. Each row in the
>data table represents information from one fishing trip. The formula used to
>calculate the catch rate is the sum of all fish caught divided by the total
>number of hours spent fishing. I am bootstrapping to get confidence limits as
>follows:
>
>Delaware=AnglerDiarySummaryData[AnglerDiarySummaryData$river==3,] #Getting
>data for river of interest
>DelawareBoot = bootstrap(Delaware, sum(TotalTrout)/sum(TotalHours),B=5000)
>
>This seems to work fine. However, I would like to do this repeatedly by year
>- there is a year variable in the data table. I could do the following for
>each year:
>
>All2007=AnglerDiarySummaryData[AnglerDiarySummaryData$river==3
>&AnglerDiarySummaryData$Year==2007,] #Data for river and year
>All2007Boot = bootstrap(All2007, sum(TotalTrout)/sum(TotalHours),B=5000)
>
>I could do this manually for each year, or write a function to loop through
>all the years, but I'm wondering if there is a more efficient way to this in
>SPlus. I imagine there is. The "group" argument for bootstrap does not seem
>to be what I want.
>
>Also - I would like to put the results from each run into one matrix or data
>frame so that I can plot the means with error bars when all runs are done.
>
>Any help would be greatly appreciated.
>
>Thanks,
>
>Jim Daley
>Coldwater Fisheries Unit Leader
>NYSDEC Bureau of Fisheries
>625 Broadway, 5th Floor
>Albany, NY 12233-4753
>jgdaley@gw.dec.state.ny.us
|