train() function and rate model (poisson regression with offset) with caret

I fitted a rate model using glm() (poisson link with offset, like

y ~ offset(log(x1)) + x2 + x3

the response is y/x1 in this case).

Then I wanted to do cross validation using caret package so I used 'train()' function with k-fold CV control. It turns out the 2 models I have are very different. It seems that train() can't handle offset : I change the variable within offset to be offset(log(log(x1)) or offset(log(sqrt(x1)) , the models remain the same.

Any one have this kind of experience before and how did you deal with it? Thanks!

btw I want to save the prediction on each validation set so so far I only know caret can do that, thats why I didnt choose to use cv.glm.


I cannot claim to have prior experience with this exact process, and have not done any testing in the absence of you offering a reproducible example and code. But I do have experience with moving offsets to the LHS of a glm -Poission regression call, so why not change the formula (and family) to:

 glm( I(y/x1) ~ x2 + x3, family=quasipoisson, data= , ...)
链接地址: http://www.djcxy.com/p/38382.html

上一篇: ROC在rfe()中为caret package for R

下一篇: train()函数和速率模型(具有偏移量的泊松回归)与脱字符号