vitalsim               package:popbio               R Documentation

_C_a_l_c_u_l_a_t_e _s_t_o_c_h_a_s_t_i_c _g_r_o_w_t_h _r_a_t_e _a_n_d _e_x_t_i_n_c_t_i_o_n _t_i_m_e _C_D_F _u_s_i_n_g
_v_i_t_a_l _r_a_t_e_s _w_i_t_h _w_i_t_h_i_n-_y_e_a_r, _a_u_t_o-, _a_n_d _c_r_o_s_s-_c_o_r_r_e_l_a_t_i_o_n_s

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

     This function runs a series of stochastic PVA population
     projections by sampling vital rates from a beta, stretched beta,
     or lognormal distribution and includes within-year, auto-, and
     cross-correlations.

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

     vitalsim(vrmeans, vrvars, corrin, corrout, makemx, n0,
     yrspan, Ne=500, tmax=50,runs=500, vrtypes=NULL,
     vrmins=NULL, vrmaxs=NULL, sumweight=NULL)

_A_r_g_u_m_e_n_t_s:

 vrmeans: means of vital rates

  vrvars: variance of vital rates

  corrin: within year correlation

 corrout: between year correlations

  makemx: a function that creates a square projection matrix from a
          vector of 'vrmeans'

      n0: initial population vector

  yrspan: the number of years of correlations to build into the M12
          matrix

      Ne: quasi-extinction threshold 

    tmax: latest time to calculate extinction probability, default 50

    runs: the number of trajectories, default is 500.  1000 is
          recommended

 vrtypes: identifies the distribution for each rate in vrmeans where 1
          = beta, 2 = stretched beta, 3 = lognormal, default is all
          ones

  vrmins: minimum value for each vital rate; use zeros for rates that
          are not stretched betas, default is all zeros

  vrmaxs: maximum value for each vital rate; use zeros for rates that
          are not stretched betas, default is all zeros

sumweight: a vector of weights, with 0 to omit a class and 1 to include
          it when computing the summed density to compare to the
          quasi-extinction threshold, default is to include all classes

_D_e_t_a_i_l_s:

     Vital rates used must be either fertility values or binomial
     probabilities, i.e., probabilities for events with only two
     possible outcomes (such as survival). Means and variances of the
     vital rates should preferably be corrected to remove sampling
     errors and demographic stochasticity.  Note that this version of
     the function does not simulate demographic stochasticity and is
     density-independent.

_V_a_l_u_e:

     The function plots a histogram of log stochastic growth rates and
     the cumulative probability of quasi-extinction and returns a list
     with 4 items: 

detLambda: the deterministic population growth rate computed from the
          mean matrix

stochlambda: the mean stochastic growth rate with 95% confidence
          intervals.

logLambdas: a vector of all log stochastic growth rates in first plot

  CDFExt: a vector of cumulative probabilities of quasi-extinction in
          second plot

_N_o_t_e:

     The correlation matrices for _Hudsonia_ in <URL:
     http://www.sinauer.com/PVA/hudcorrs.mat> include some
     correlations>1.  A corrected set of correlations was sent by D.
     Doak on 8/4/2007.  Therefore the results from the simulation below
     are different than the book.

_A_u_t_h_o_r(_s):

     Original MATLAB program by Morris and Doak (2002: 301 - 304).
     Adapted to R by Patrick Nantel, 12 July 2005.

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

     converted Matlab code from Box 8.10 in Morris and Doak (2002)

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

     Morris, W. F., and D. F. Doak. 2002. Quantitative conservation
     biology: Theory and practice of population viability analysis.
     Sinauer, Sunderland, Massachusetts, USA.

_S_e_e _A_l_s_o:

     'hudmxdef', 'hudvrs' and 'hudcorrs'

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

     ## load vital rates and correlation matrices
     data(hudvrs)
     data(hudcorrs)
     ## set vrtypes
     hudvrtypes<-c(rep(1,13), rep(3,5), rep(1,6))

     ## run Full model- using 100 runs here for speed
     full<-vitalsim(hudvrs$mean, hudvrs$var, hudcorrs$corrin,
     hudcorrs$corrout, hudmxdef, vrtypes=hudvrtypes,
     n0=c(4264,3,30,16,25,5), yrspan=20 , runs=100)
     ## deterministic and stochastic lambda
     full[1:2]
     ## log stochastic lambda
     log(full$stochLambda)
     sd(full$logLambdas)

     ## SKIP the next two simulations- however, sample output is included for plotting
     #NO between year correlations so corrout = diag(0,13)  - all zeros
     # no.between<-vitalsim(hudvrs$mean, hudvrs$var, hudcorrs$corrin,
     # diag(0,13), hudmxdef, vrtypes=hudvrtypes,
     # n0=c(4264,3,30,16,25,5), yrspan=20 )
     no.between<-list(CDFExt=c(rep(0,40),0.01,0.04,0.12,0.15,
     0.20,0.31,0.49,0.58,0.72,0.78))

     #NO correlations so corrout = diag(0,13) AND corrin=diag(13) - ones on diagonal
     # no.corr<-vitalsim(hudvrs$mean, hudvrs$var, diag(13),
     # diag(0,13), hudmxdef, vrtypes=hudvrtypes,
     # n0=c(4264,3,30,16,25,5), yrspan=20 )
     no.corr<-list(CDFExt=c(rep(0,39),0.03,0.03,0.06,0.12,0.20,
     0.30,0.42,0.52,0.65,0.76,0.83))

     ## Figure 8.3 with corrected correlation matrices for full model
     matplot(cbind(a=full$CDFExt, no.between$CDFExt, no.corr$CDFExt), type='l',
      ylim=c(0,1), lty=1:3, col=2:4, lwd=2, las=1,
      xlab="Years into the future", ylab="Cumulative probability of quasi-extinction")
     legend(2,1, c("Full model", "No between-year correlations", "No correlations"),
      lty=1:3, col=2:4, lwd=2)

