if (FALSE) {
## Estimation of covariace matrices from simulated data
# Variables and parameters
d <- 3
n <- 30
N <- c(10,10,10)
LeslieMatrix <- matrix( c(0.08, 1.06, 0.07,
0.99, 0, 0,
0, 0.98, 0), 3, 3 )
# offspring distributions from the Leslie matrix
# (with independent distributions)
Dists.pois <- data.frame( name=rep( "pois", d ),
param1=LeslieMatrix[,1],
param2=NA,
stringsAsFactors=FALSE )
Dists.binom <- data.frame( name=rep( "binom", 2*d ),
param1=rep( 1, 2*d ),
param2=c(t(LeslieMatrix[,-1])),
stringsAsFactors=FALSE )
Dists.i <- rbind(Dists.pois,Dists.binom)
Dists.i <- Dists.i[c(1,4,5,2,6,7,3,8,9),]
Dists.i
# covariance matrices of the process from its offspring distributions
V <- BGWM.covar(Dists.i,"independents",d)
# generated trajectories of the process from its offspring distributions
simulated.data <- rBGWM(Dists.i, "independents", d, n, N,
TRUE, FALSE, FALSE)$o.c.s
# estimation of covariance matrices using mean matrix empiric estimate
# from generated trajectories of the process
V.EE.m <- BGWM.covar.estim( simulated.data, "EE-m", d, n, N )$V
# estimation of covariance matrices using mean matrix maximum likelihood
# estimate from generated trajectories of the process
V.MLE.m <- BGWM.covar.estim( simulated.data, "MLE-m", d, n, N )$V
# Comparison of exact and estimated covariance matrices
V
V - V.EE.m
V - V.MLE.m
}
Run the code above in your browser using DataLab