[R] power of a matrix
Rau, Roland
Rau at demogr.mpg.de
Wed Aug 17 12:15:46 CEST 2005
Dear all,
I have a population with three age-classes, at time t=0 the population
is:
n.zero <- c(1,0,0)
I have a transition matrix A which denotes "fertility" and "survival":
A <- matrix(c(0,1,5, 0.3,0,0, 0,0.5,0), ncol=3, byrow=TRUE)
To obtain the population at t=1, I calculate:
A %*% n.zero
To obtain the population t=2, I calculate:
A %*% (A %*% n.zero)
... and so on ...
I thought now to obtain the population at time x, I should simply do:
A^x %*% n.zero
But this, of course, does not work since the following two statements
are not equivalent for matrices:
A %*% A
A * A
Is there something like a "powermatrix"-function?
Thanks,
Roland
P.S. The example is taken from:
Example 3.1 ("A linear, time-invariant model") from Keyfitz/Caswell:
"Applied Mathematical Demography", 3rd Edition, 2005, p. 52f
+++++
This mail has been sent through the MPI for Demographic Rese...{{dropped}}
More information about the R-help
mailing list