Reputation: 101
I have a dataset with response variable y that takes values between 0 and 100 and an explanatory variable age that takes values between 18 and 70. To construct a model, a GAMMA distribution seemed fine for the response variable y. Since 80% of the values for y are equal to 0, I expanded it to a zero-inflated gamma model (ZAGA) using GAMLSS. Now since values greater than 100 are not realistic for my data, I want to censor the ZAGA distribution (yes censor, not truncate, I want the mass of the values bigger than 100 to be piled up at 100). But when I try to do this, I get the error: 'Ops.Surv(y, mass.p) : Invalid operation on a survival time'
I tried the following code:
### The variables:
y \<- c(0, 0, 0, 35, 0, 0, 0, 0, 100, 100, 0, 0, 0, 0, 40, 50, 0, 0, 0, 40, 0, 0, 45 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0,
0 , 0, 0, 15, 0, 0, 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 100, 0, 0, 35, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 50, 0, 70 , 50, 0, 0, 75, 0, 0, 100, 0, 83, 0, 0,
0 , 0, 100)
age \<- c(60, 47, 63, 44, 54, 60, 54, 40, 58, 57, 49, 63, 53, 46, 52, 41, 39, 41, 51, 33, 54, 66, 47, 65, 44, 59, 32, 42, 46, 58, 31, 56, 25, 49, 36, 53, 61, 40, 40, 38, 47, 64, 57 ,42, 50, 58, 61, 54, 54, 58, 60, 60, 52, 46, 67 ,52, 50, 57, 56, 34, 64, 61, 45, 62, 60, 53, 50, 36, 51, 48, 28, 66, 57, 60, 54, 58, 52, 61 ,62, 52, 57, 47, 42, 49, 58, 42, 41, 54, 57, 38, 41, 59, 55, 30, 60, 46, 57, 52, 56, 56, 54, 64, 65, 55, 39, 61, 66, 64, 43, 57, 58, 59, 53, 43, 50, 44, 62, 50, 58, 48)
### The code:
library('gamlss')
library('survival')
library('gamlss.cens')
ysurv \<- Surv(y, y!=100, type="right")
gen.cens(ZAGA, type = "right")
So far the code works fine, the ysurv variable gets censored to the right (all values at 100 get changed to 100+) and the gen.cens function generates the distributions: dZAGArc pZAGArc qZAGArc ZAGArc. Now when trying to fit the GAMLSS model, the code fails:
Cens <- gamlss(ysurv ~ pb(age), nu.fo = ~ pb(age), family = ZAGArc)
This gives the error: Ops.Surv(y, mass.p) : Invalid operation on a survival time
If I change the ZAGA to a normal distribution, the code works fine, and when just fitting a ZAGA without censoring, it also works fine.
Upvotes: 0
Views: 479
Reputation: 56
Not sure why ZAGArc doesn't work.
One solution is to fit a binary model to y=0, y>0. Then fit a right censored GA to the positive values of Y.
Upvotes: 0