whale                 package:popbio                 R Documentation

_T _a_n_d _F _m_a_t_r_i_x _f_o_r _k_i_l_l_e_r _w_h_a_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     Transition and Fertility matrices for killer whales

_U_s_a_g_e:

     data(whale)

_F_o_r_m_a_t:

     A list with T and F matrices

_S_o_u_r_c_e:

     see Chapter 5 in Caswell (2001)

_R_e_f_e_r_e_n_c_e_s:

     Brault, S., and H. Caswell. 1993. Pod-specific demography of
     killer whales (_Orcinus orca_). Ecology 74:1444-1454.

     Caswell, H. 2001. Matrix population models: construction,
     analysis, and interpretation, Second edition. Sinauer, Sunderland,
     Massachusetts, USA.

_E_x_a_m_p_l_e_s:

     data(whale)
     A <- whale$T + whale$F
     A
     n <- c(4, 38, 36, 22)

     ## matrix multiplication (see pop.projection)
     A %*% n
     A %*% A %*% n

     ######### section 5.3.1 Age-specific survival  ###########
     #  equation 5.35
     fundamental.matrix(whale$T)$N

     # Survivorship plot like figure 5.1 in Caswell.  
     # Note example on page 120 uses matrix powers and not element by element 
     # which is R default.  Matrix power is not part of base R, but for simple cases 
     # this works to do A %*% A %*% A %*% A...

     mp<-function(A,pow){
       if(pow==1){A}
       else{
         x<-A
         for(i in (2:pow)){
           A<-x%*%A
         }
       }
       A
     }

     ## also use colSums for sum of matrix columns e^T
     surv<-matrix(numeric(150*4), ncol=4)
     for(x in 1:150)
     {
        surv[x,]<-colSums(mp(whale$T,x))
     }
     ## Just plot first stage column?
     plot(surv[,1]/surv[1,1], type="l", ylim=c(0,1), las=1, 
       xlab="Age (years)", ylab=expression(paste("Survivorship ", italic(l(x)))))

     ######### section 5.3.2 Age-specific fertility  ###########
     #  equation 5.44
     T<- mp(whale$T,20)
     whale$F %*% T %*% diag(1/colSums(T))

     ##  Figure 5.2 in Caswell
     fert<-numeric(200)
     for(x in 1:200)
     {
       T<-mp(whale$T,x)
       phi<-whale$F %*% T %*% diag(1/colSums(T))
       fert[x]<-phi[1,1]
     }

     plot(fert, type="l", ylim=c(0,0.07), las=1,
       xlab="Age (years)", ylab="Age-specific fertility")

