You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @pistacliffcho, I found that icenReg cannot handle na.action as most other model fitting packages when NA values appear in the response and predictors.
When any observation has missing value in any predictor, model fitting functions produce the follow error message.
Errorinif (any(weights<0)) stop("weights supplied cannot be less than 0") :missingvaluewhereTRUE/FALSEneeded
It does not matter whether the response is specified using Surv() or cbind() or the missing cases is treated specially in factor().
ic_np(cbind(left, right) ~gender, data=IR_diabetes)
"Works"
ic_np(
cbind(left, right) ~gender,
data=IR_diabetes|>
transform(gender= c(rep(NA, 20), gender[21:nrow(IR_diabetes)])))
ic_np(
Surv(left, right, type="interval2") ~gender,
data=IR_diabetes|>
transform(gender= c(rep(NA, 20), gender[21:nrow(IR_diabetes)])))
ic_np(
Surv(left, right, type="interval2") ~gender,
data=IR_diabetes|>
transform(gender= c(rep(NA, 20), gender[21:nrow(IR_diabetes)])) |>
transform(gender=factor(gender, exclude=NULL)))
"Error in if (any(weights < 0)) stop(weights supplied cannot be less than 0) : missing value where TRUE/FALSE needed"
A temporary solution is to remove NA cases manually.
icenReg also does not allow NA values in the left limit of the response interval, and -Inf value is allowed only when the response is specified using cbind().
ic_np( # ic_npSINGLE() error
Surv(left, right, type="interval2") ~gender,
data=IR_diabetes|>
transform(left= c(rep(NA, 20), left[21:nrow(IR_diabetes)])))
ic_np( # ic_npSINGLE() error
Surv(left, right, type="interval2") ~gender,
data=IR_diabetes|>
transform(left= c(rep(-Inf, 20), left[21:nrow(IR_diabetes)])))
"Error in ic_npSINGLE(thisData, maxIter = maxIter, tol = tol, B = B, weights = this_w) : data[,1] > data[,2].This is impossible for interval censored data"
ic_np( # yMat[] error
cbind(left, right) ~gender,
data=IR_diabetes|>
transform(left= c(rep(NA, 20), left[21:nrow(IR_diabetes)])))
"Error in yMat[isCensored, 1] <- yMat[isCensored, 1] + eps : NAs are not allowed in subscripted assignments"
ic_np( # worked
cbind(left, right) ~gender,
data=IR_diabetes|>
transform(left= c(rep(-Inf, 20), left[21:nrow(IR_diabetes)])))
On the other hand, the right limit seems quite flexible, with both NA and Inf values allowed in both cbind() and Surv() format.
When the response is totally missing, errors about yMat[] are produced. It permits setting missing lower limits to -Inf and missing upper limits to Inf in the cbind() format. But I do not know whether the result that accounts for (-Inf, Inf) intervals should be trustworthy--is it equivalent to removing the cases with missing responses?
ic_np( # Error in yMat[]
Surv(left, right, type="interval2") ~gender,
data=IR_diabetes|>
transform(left= c(rep(NA, 20), left[21:nrow(IR_diabetes)])) |>
transform(right= c(rep(NA, 20), right[21:nrow(IR_diabetes)])))
ic_np( # Error in yMat[]
Surv(left, right, type="interval2") ~gender,
data=IR_diabetes|>
transform(left= c(rep(-Inf, 20), left[21:nrow(IR_diabetes)])) |>
transform(right= c(rep(Inf, 20), right[21:nrow(IR_diabetes)])))
"Error in yMat[exact, 2] <- yMat[exact, 1] : NAs are not allowed in subscripted assignments"
ic_np( # Error in yMat[]
cbind(left, right) ~gender,
data=IR_diabetes|>
transform(left= c(rep(NA, 20), left[21:nrow(IR_diabetes)])) |>
transform(right= c(rep(NA, 20), right[21:nrow(IR_diabetes)])))
"Error in yMat[isCensored, 1] <- yMat[isCensored, 1] + eps : NAs are not allowed in subscripted assignments"
ic_np( # Worked
cbind(left, right) ~gender,
data=IR_diabetes|>
transform(left= c(rep(-Inf, 20), left[21:nrow(IR_diabetes)])) |>
transform(right= c(rep(Inf, 20), right[21:nrow(IR_diabetes)])))
The text was updated successfully, but these errors were encountered:
DrJerryTAO
changed the title
Error about weights and TRUE/FALSE needed due to NA values
Error due to NA values in responses and predictors
Aug 26, 2024
Hi @pistacliffcho, I found that icenReg cannot handle na.action as most other model fitting packages when NA values appear in the response and predictors.
When any observation has missing value in any predictor, model fitting functions produce the follow error message.
It does not matter whether the response is specified using
Surv()
orcbind()
or the missing cases is treated specially infactor()
.A temporary solution is to remove NA cases manually.
icenReg also does not allow NA values in the left limit of the response interval, and -Inf value is allowed only when the response is specified using
cbind()
.On the other hand, the right limit seems quite flexible, with both NA and Inf values allowed in both
cbind()
andSurv()
format.When the response is totally missing, errors about
yMat[]
are produced. It permits setting missing lower limits to -Inf and missing upper limits to Inf in thecbind()
format. But I do not know whether the result that accounts for (-Inf, Inf) intervals should be trustworthy--is it equivalent to removing the cases with missing responses?The text was updated successfully, but these errors were encountered: