Description Usage Arguments Details Value Authors Examples
Predict values for S and E(S) given a model for S and new covariates.
1 2 3 |
object |
a fitted model from truncMod, of class truncMod |
new.obs |
new covariates used to predict S. Must contain the same names as in the formula for truncMod |
N |
if S is conditional on N, then N is the predicted values returned from predict.N |
offset |
offset for sampling |
dist |
distribution used for S, either negative binomial ("NB") or poisson ("poisson") |
... |
additional arguments to be passed to predict |
Uses mvtnorm to obtain new parameters for the glm using calculated variance-covariance matrix, assuming multivariate normal for parameters.
new.obs will be automatically scaled using details in model.S if scale.covar==TRUE
S |
predicted S |
expect.S |
expected S |
Piers Dunstan and Scott Foster
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | N.form <- N~1 + depth + O2_AV + temp_AV + offset(log(area))
model.N <- negBinMod(N.form,data=fish.data,est.var=TRUE,scale.covar =FALSE)
fish.data$N.scale <- fish.data$N/fish.data$area
S.form <- S~1 + N.scale + depth + O2_AV + temp_AV + offset(log(area))
model.S <- truncMod(S.form,fish.data$N,data=fish.data,est.var=TRUE,scale.covar=TRUE)
new.obs <- as.data.frame(t(apply(fish.data,2,mean)))
N.pred <- rep(NA,100)
S.pred <- rep(NA,100)
for(n in 1:100){
N.pred[n] <- predict(model.N,new.obs,offset=10)$N
# insert estimate for N into data frame for it is used, not the original value
new.obs$N.scale <- N.pred[n]/10
S.pred[n] <- predict(model.S,new.obs,N.pred[n],offset=10)$S
}
hist(S.pred)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.