You should be using get.real which provides the real parameter estimates and their v-c matrix. Also, did you look at deltamethod.special? It handles a product of estimates as you need. Below I modified the example in the help for deltamethod.special so it does 2 products of 3 estimates.
- Code: Select all
data(dipper)
# run model
mod=mark(dipper,model.parameters=list(Phi=list(formula=~time)))
# Get estimates of Phi and their v-c matrix
rr=get.real(mod,"Phi",se=TRUE,vcv=TRUE)
# Compute se of the product of the first 3 survivals
deltamethod.special("prod",rr$estimates$estimate[1:3],rr$vcv.real[1:3,1:3])
# Compute se of the product of the last 3 survivals
deltamethod.special("prod",rr$estimates$estimate[4:6],rr$vcv.real[4:6,4:6])
You need to use get.real to get the vector of real parameter estimates and their v-c matrix and then you just need to subset it to meet your needs.
What the above will NOT do is to give you the v-c matrix of sets of products. Products are extremely easy with the delta method because the derivative with respect to the real parameter is just the product divided by that real parameter -- which is the product of the other 2 parameters.
- Code: Select all
#Below I wrote a function in R that will compute the v-c matrix for an abitrary set of products of all the same length. x is the vector of estimates,
#vcv is the variance-covariance matrix of the estimates and indices is a matrix of indices in x for how you want to combine them. The number of rows
#in indices is the number of products and the number of columns is the number of estimates in each product.
dm.prod=function(x,vcv,indices)
{
D=matrix(0,nrow=nrow(indices),ncol=prod(dim(indices)))
for(i in 1:nrow(indices))
{
estimates=x[indices[i,]]
D[i,indices[i,]]=prod(estimates)/estimates
}
return(D%*%vcv%*%t(D))
}
#Here is an example with the dipper data from above
# create 2 products with first 3 and last 3
indices=matrix(1:6,ncol=3,nrow=2,byrow=T)
# show indices
indices
# compute v-c matrix of the 2 products
vcv=dm.prod(rr$estimates$estimate,rr$vcv,indices=indices)
# show that std errors match the results above
sqrt(diag(vcv))
#You can expand to any number of products of any number of estimates by specifying a different index matrix.
# For example here is one that creates 3 products of each pair of estimates
indices=matrix(1:6,ncol=2,nrow=3,byrow=T)
indices
# Note indices do not have to be in order, just easier to do for the example
vcv=dm.prod(rr$estimates$estimate,rr$vcv,indices=indices)
vcv
I hope this helps. --jeff