[Depmix-commits] r251 - trunk/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 17 17:09:57 CET 2009
Author: ingmarvisser
Date: 2009-02-17 17:09:56 +0100 (Tue, 17 Feb 2009)
New Revision: 251
Modified:
trunk/R/transInit.R
Log:
Added newx (newdata) argument for predict method of transInit objects (useful in eg plotting logit functions depending on covariates)
Modified: trunk/R/transInit.R
===================================================================
--- trunk/R/transInit.R 2009-02-17 14:22:50 UTC (rev 250)
+++ trunk/R/transInit.R 2009-02-17 16:09:56 UTC (rev 251)
@@ -73,9 +73,16 @@
)
setMethod("predict","transInit",
- function(object) {
- if(object at family$link=="identity") object at family$linkinv(object at x%*%object at parameters$coefficients)
- else object at family$linkinv(object at x%*%object at parameters$coefficients,base=object at family$base)
+ function(object,newx) {
+ if(missing(newx)) {
+ if(object at family$link=="identity") object at family$linkinv(object at x%*%object at parameters$coefficients)
+ else object at family$linkinv(object at x%*%object at parameters$coefficients,base=object at family$base)
+ } else {
+ if(!(is.matrix(newx))) stop("'newx' must be matrix in predict (GLMresponse)")
+ if(!(ncol(newx)==nrow(object at parameters$coefficients))) stop("Incorrect dimension of 'newx' in predict (GLMresponse)")
+ if(object at family$link=="identity") object at family$linkinv(newx%*%object at parameters$coefficients)
+ else object at family$linkinv(newx%*%object at parameters$coefficients,base=object at family$base)
+ }
}
)
More information about the depmix-commits
mailing list