indmat.derivmat.func <- function(sp.bootind, h, d, interval) { # indmat.derivmat.func: # Calculates the matrix of 2nd derivative estimates from the # matrix sp.bootind of bootstrapped abundance indices. # # sp.bootind is a matrix of the form sp.bootind.Nrep.df # (e.g. cb.bootind.399.10). # Each row of the output matrix is the vector of 2nd derivative estimates # for the abundance index curve in the corresponding row of the index # matrix (i.e. the curve corresponding to a particular bootstrap # replicate). # See diffop.func for a full explanation of arguments h, d, and interval. # interval is the time lapse between consecutive index points: e.g. if # the index curve measures abundance every 2 years, then interval=2. # Usually interval=1. # h is related to window size for the second derivative estimates: usually # will be chosen to be the smallest possible (h=1) but try # experimenting with h=2 and h=3 to see if the results are any # different. # d is the order of the difference operator: can be 2, 4, or 6, # representing the second derivative estimates obtained from 2nd # differences, 4th differences, or 6th differences (eqns 9, 10, and 11 # in the Ecology paper). d=6 should give the most accurate results. # # The output from this function would normally be named # sp.bootderiv.Nrep.df, although this function is usually only called # from within sp.plot. # example: # cb.bootderiv.399.10 <- indmat.derivmat.func(cb.bootind.399.10, 1, 6, 1) # # t(apply(sp.bootind, 1, diffop.func, h = h, d = d, interval = interval)) }