RMC.mod: Estimation of categorical discrete-time non-stationary Markov...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Estimation of categorical Markov chain models whose parameterisation is based on a simple reversible Markov model and that can be extended to non-stationary cases. The model is parameterised by two vectors of parameters: one describing the probability of moving from each state (phi) and the other describing the probability of moving into each state given that a movement will occur (pi). Non-stationary models are incorporated by letting each of these vectors depend on covariates.

Usage

1
RMC.mod( states, chain.id=NULL, X=NULL, phi.id=NULL, pi.id=NULL, vcov=FALSE, inits=NULL, contr=list( maxit=1000, epsg=1e-8, epsf=1e-8, epsx=1e-8), quiet=FALSE, penalty=0)

Arguments

states

observed ordered chained data. If there are multiple chains then chains are stacked on top of each other. Argument must be supplied

chain.id

vector (length matches states) of identifiers for the individual chains. If NULL then it is assumed that all observations form a single chain.

X

design matrix (covariates) for the two vectors of probabilities. If NULL then X is assumed to contain an intercept term only. If not NULL then model will depend on phi.id and pi.id matrices (see below). X must be of dimensions nrow(X)=length(states) and ncol(X)=number of covariates. Typically will be created with a call to model.matrix

phi.id

indicator matrix of zeros and ones showing which covariates to include in the model for which element of phi (zero means not included and one means included). Each element of phi corresponds to the probability of moving from an observed state. phi.id must be of dimensions nrow(phi.id)=ncol(X)=number of covariates and ncol(phi.id)=number of states. If NULL then all covariates are included. Covariates are included via a logistic model for each element of phi

pi.id

indicator vector of zeros and ones showing which covariates to include in the model for all elements of pi (zero means not included and one means included). Each element of pi correspond to the probability of moving to that state given that a movement will occur. pi.id must have length equal to the number of covariates and indicates if that covariate is included in the model for pi. Covariates are included via the additive logistic transformation (Aitchison 1982)

vcov

boolean indicating if the variance matrix of the parameter estimates should be calculated. TRUE indicates that it is calculated

inits

initial values for the parameters. Must be of appropriate length and ordered as phi parameters and the pi parameters. If NULL then initial values are assumed to be zero. The ordering of this vector is:phi parameters for category 1, category 2, etc followed by pi parameters for transformed category 1, transformed category 2, etc.

contr

list containing control values for the optimisation procedure. maxit specifies the maximum number of iterations before optimisation is stopped. epsg, epsf and epsx give the stopping tolerances for gradients, relative function and estimates respectively

quiet

boolean indicating if any output is wanted. TRUE indicates that output is generated

penalty

experimental argument for an optional quadratic penalty on the parameters. A non-zero value indicates that the sum of the squared parameters must be less than or equal to the value. A value of zero indicates no penalty and is the default.

Details

The observed chained categorical data (in argument states) is modelled according to that described in Foster et al (2009). The Markov process is assumed to be parameterised by two vectors, phi and pi. The phi parameters indicate the probability of moving from each state and the pi probabilities prescribe the probability of moving to each state given that a move will occur. This process is reversible if the parameters do not change within a chain. The probabilities are allowed to vary within a chain by specifying these two vectors of probabilities as functions of covariates (possibly index number).

Since the model has simple form then the stationary distribution is known (up to normalisation constant) and hence, the (log-)likelihood is calculated exactly.

Optimisation is performed using a quasi-Newton method implemented in the LBFGS code from the ALGLIB website (see references). First derivatives for the optimisation are obtained using automatic differentiation (Griewank 2001) using the CppAD tool for C++ (Bell 2007). This saves an awful lot of mucking around with derivative free methods and increases speed. If you do not already use automatic differentiation then you may want to look into it.

Value

Upon successful completion the function returns
pars

the parameter estimates ordered as phi parameters and then pi parameters. The ordering of this vector is:phi parameters for category 1, category 2, etc followed by pi parameters for transformed category 1, transformed category 2, etc.

like

the maximised log-likelihood

scores

the gradients calculated at the estimates. Ordered to match the pars vector

vcov

the variance matrix of the estimates if vcov==TRUE and NULL if vcov==FALSE

conv

the convergence code from the quasi-Newton optimiser

time

the time taken to perform the fit

niter

the number of iterations required by the optimiser

stuff

quite literal:stuff used for model specification and optimisation. Generally not of use to the user

Author(s)

Scott D. Foster

References

Aitchison J. (1982) The statistical analysis of compositional data. The Journal of the Royal Statistical Society-series B 44: 139-177.

ALGLIB http://www.alglib.net/ (accessed June 2008)

Bell BM. 2007. CppAD: a package for C++ algorithmic differentiation, COIN-OR. http://www.coin-or.org/CppAD/, version 2007/02/07.

Griewank A. (2001) Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation. SIAM. Philadelphia.

Foster, S.D., Bravington, M.V., Williams, A., Althaus, F, Laslett, G.M., and Kloser, R.J. (2008) Analysis and prediction of faunal distributions from video and multi-beam sonar data using Markov models. Environmetrics, 20: 541-560.

See Also

RMC.pred for predicting the stationary distribution at arbitrary combinations of covariates. diagnos and diagnos.envel for graphical diagnostic methods for models of class RMC.

Examples

1
2
3
4
#estimate a model for the stationary example data, dataEG1
fm.est1 <- RMC.mod( states=dataEG1[,2], chain.id=dataEG1[,1], X=dataEG1[,3])
#estimate a model for the non-stationary example data, dataEG2
fm.est2 <- RMC.mod( states=dataEG2[,2], chain.id=dataEG2[,1], X=dataEG2[,-(1:2)])

Example output

Incidence matrix for phi not given or doesn't match design matrix - all variables included 
Incidence vector for pi not given or doesn't match design matrix - all variables included 
All initial values assigned to zero 

 Performing Estimation of Parameters for Reversible Markov Model 

 Convergence trace 
  iter   -pllike:  phi_1    phi_2    phi_3    phi_4    pi_11    pi_12    pi_13    
   0   5700.621020:  0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 
   1   5626.622241:  0.227163 0.006192 0.407606 -0.111209 0.582179 -0.611771 0.238018 
   2   5582.966976:  0.240168 0.118793 0.442679 -0.097045 0.374133 -0.395855 0.201297 
   3   5570.422789:  0.303297 0.209435 0.579048 -0.084146 0.361690 -0.267697 0.129139 
   4   5563.134759:  0.388733 0.308325 0.804129 -0.116524 0.395015 -0.226761 0.139932 
   5   5561.953731:  0.368670 0.298453 0.990829 -0.132273 0.462675 -0.202569 0.090409 
   6   5561.010291:  0.378124 0.312039 0.993362 -0.142722 0.440338 -0.210113 0.129703 
   7   5560.953758:  0.371950 0.307796 1.002382 -0.143312 0.437105 -0.206996 0.134673 
   8   5560.899197:  0.357394 0.294945 1.019619 -0.140580 0.434300 -0.198722 0.141432 
   9   5560.892563:  0.356287 0.290938 1.021508 -0.135133 0.436692 -0.194922 0.145373 
   10   5560.892372:  0.355670 0.291024 1.021506 -0.135252 0.437451 -0.194484 0.145444 
   11   5560.892337:  0.355342 0.291232 1.021295 -0.135319 0.437790 -0.194301 0.145560 
 Function Convergence
 Computing Done 
Incidence matrix for phi not given or doesn't match design matrix - all variables included 
Incidence vector for pi not given or doesn't match design matrix - all variables included 
All initial values assigned to zero 

 Performing Estimation of Parameters for Reversible Markov Model 

 Convergence trace 
  iter   -pllike:  phi_1    phi_2    phi_3    phi_4    phi_5    phi_6    phi_7    phi_8    pi_11    pi_12    pi_13    pi_21    pi_22    pi_23    
   0   3836.891917:  0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 
   1   3468.414775:  -0.009434 0.003725 -0.100880 0.754996 -0.038446 0.087688 -0.100096 -0.532963 -0.049529 -0.159504 0.056194 -0.248781 0.063970 0.139390 
   2   2734.009576:  -0.015750 0.009289 -0.114820 0.860229 -0.043356 0.052030 -0.142216 -0.535959 -0.101101 0.008573 0.070763 -0.222126 0.120364 -0.140861 
   3   2552.434318:  -0.022691 0.016598 -0.125601 0.949978 -0.052745 0.032274 -0.173403 -0.629022 -0.137199 0.084999 0.087477 -0.182815 0.161736 -0.358386 
   4   2488.083328:  -0.028494 0.023224 -0.132569 1.010039 -0.065964 0.047511 -0.195606 -0.689875 -0.162151 0.132685 0.117145 -0.253467 0.168859 -0.391790 
   5   2400.599944:  -0.053874 0.053252 -0.148159 1.169764 -0.101250 0.020287 -0.271153 -0.874044 -0.245414 0.249790 0.222023 -0.426872 0.175591 -0.491343 
   6   2369.886826:  -0.077465 0.078532 -0.155212 1.267472 -0.129908 -0.004388 -0.329742 -1.006032 -0.311053 0.316566 0.301341 -0.493594 0.173707 -0.586974 
   7   2345.128244:  -0.121474 0.111170 -0.156066 1.369891 -0.176979 -0.024962 -0.420159 -1.167607 -0.418224 0.378004 0.432486 -0.550353 0.140160 -0.680056 
   8   2316.508831:  -0.200691 0.120379 -0.135760 1.429860 -0.236345 -0.030907 -0.564149 -1.333640 -0.596902 0.402534 0.632662 -0.544225 0.041307 -0.732318 
   9   2299.472529:  -0.377388 0.079173 -0.040744 1.341171 -0.183934 -0.195579 -0.903312 -1.554996 -0.933719 0.405380 0.874371 -0.416141 -0.155940 -0.634948 
   10   2279.976261:  -0.410323 0.075411 -0.018541 1.314339 -0.186996 -0.063999 -0.973810 -1.573242 -0.982603 0.392906 0.897789 -0.376836 -0.184629 -0.638126 
   11   2277.232016:  -0.423635 0.070143 -0.005219 1.287717 -0.174141 -0.012608 -1.006141 -1.572298 -0.995675 0.386557 0.888210 -0.353127 -0.192600 -0.631078 
   12   2274.957460:  -0.445468 0.059210 0.016736 1.244830 -0.137637 -0.009813 -1.060102 -1.579170 -1.019113 0.384238 0.872788 -0.330571 -0.206174 -0.606061 
   13   2269.145967:  -0.509132 0.033442 0.087753 1.142463 -0.012082 0.004950 -1.247217 -1.624870 -1.073383 0.390107 0.815334 -0.326145 -0.236893 -0.593076 
   14   2264.925212:  -0.561355 0.055643 0.178246 1.076046 0.120816 0.021422 -1.495408 -1.699423 -1.126467 0.408605 0.801353 -0.358947 -0.306006 -0.633143 
   15   2264.087873:  -0.540645 0.004068 0.236782 1.084836 0.181229 0.028559 -1.659041 -1.745226 -1.144921 0.431912 0.827492 -0.386961 -0.369514 -0.675985 
   16   2263.340094:  -0.532072 0.044835 0.245796 1.095150 0.183799 0.028655 -1.676793 -1.741776 -1.137808 0.436381 0.832886 -0.384771 -0.381205 -0.677643 
   17   2263.088361:  -0.511237 0.057077 0.255942 1.107079 0.183424 0.029184 -1.690058 -1.729192 -1.125220 0.436451 0.835814 -0.381539 -0.391141 -0.677628 
   18   2262.747118:  -0.464036 0.068906 0.285686 1.128765 0.187150 0.030028 -1.727238 -1.695742 -1.098537 0.430298 0.838165 -0.375633 -0.413604 -0.676551 
   19   2262.567380:  -0.444173 0.069610 0.318982 1.143330 0.188478 0.029512 -1.753054 -1.664643 -1.087649 0.413274 0.835492 -0.377794 -0.424139 -0.678687 
   20   2262.477927:  -0.440304 0.064069 0.349183 1.153900 0.187730 0.028680 -1.764802 -1.644261 -1.082151 0.405568 0.829855 -0.379686 -0.429180 -0.679766 
   21   2262.391668:  -0.446230 0.057569 0.386990 1.166320 0.183675 0.027474 -1.768356 -1.626482 -1.079579 0.403481 0.824223 -0.380624 -0.433312 -0.680042 
   22   2262.256915:  -0.463086 0.050223 0.459929 1.189501 0.173601 0.025413 -1.763490 -1.600085 -1.077630 0.406409 0.817131 -0.380921 -0.439394 -0.680018 
   23   2262.106437:  -0.477836 0.048942 0.557857 1.215005 0.164146 0.023902 -1.743129 -1.576043 -1.078379 0.413167 0.814971 -0.380573 -0.442820 -0.680385 
   24   2262.001201:  -0.483847 0.053081 0.651631 1.237162 0.162227 0.023895 -1.717802 -1.565743 -1.082603 0.422797 0.818322 -0.380195 -0.442871 -0.680874 
   25   2261.962429:  -0.478747 0.057291 0.692080 1.245735 0.167381 0.025002 -1.705678 -1.570066 -1.086685 0.425906 0.822638 -0.379868 -0.439829 -0.680860 
   26   2261.938737:  -0.469953 0.060030 0.718687 1.252170 0.175418 0.026450 -1.700923 -1.579330 -1.089490 0.426164 0.826027 -0.379627 -0.436255 -0.680489 
   27   2261.923914:  -0.463924 0.060290 0.736898 1.258731 0.181303 0.027406 -1.701941 -1.588567 -1.089209 0.424248 0.826947 -0.379572 -0.433544 -0.680011 
   28   2261.912565:  -0.461683 0.059158 0.754901 1.266692 0.184056 0.027828 -1.706947 -1.597794 -1.085333 0.421501 0.826269 -0.379529 -0.432042 -0.679532 
   29   2261.905819:  -0.463424 0.057814 0.769185 1.273419 0.182564 0.027600 -1.712269 -1.604295 -1.079538 0.419261 0.824936 -0.379520 -0.431416 -0.679219 
   30   2261.901690:  -0.466744 0.057207 0.778887 1.277431 0.178144 0.026962 -1.715926 -1.608728 -1.073303 0.418220 0.823999 -0.379517 -0.430614 -0.679039 
   31   2261.899753:  -0.468620 0.057577 0.782879 1.277166 0.172953 0.026228 -1.717329 -1.611550 -1.068896 0.418205 0.824224 -0.379468 -0.428339 -0.678769 
   32   2261.899605:  -0.468916 0.057750 0.781472 1.276408 0.171701 0.026059 -1.717207 -1.611830 -1.068581 0.418576 0.824503 -0.379505 -0.427688 -0.678705 
   33   2261.899599:  -0.468858 0.057798 0.780838 1.276154 0.171628 0.026057 -1.717088 -1.611771 -1.068736 0.418640 0.824574 -0.379490 -0.427600 -0.678684 
 Function Convergence
 Computing Done 

RMC documentation built on May 30, 2017, 2:55 a.m.

Related to RMC.mod in RMC...