Takes a combination of 'x', 'r', and 'd' arrays and ensures that the data is feasible. Does not check for the case where r is always decreasing as this is possible in some cases, i.e. when there is left truncation, a.k.a late entry. Parameters ---------- x: array
(x, r, d)
| 214 | |
| 215 | if c is not None: |
| 216 | c = np.array(c) |
| 217 | if c.ndim != 1: |
| 218 | raise ValueError("censoring array must be one dimensional") |
| 219 | |
| 220 | if c.shape[0] != x.shape[0]: |
| 221 | raise ValueError( |
| 222 | "censoring array must be same length as variable array" |
| 223 | ) |
| 224 | |
| 225 | if x.ndim == 2: |
| 226 | if any(c[x[:, 0] == x[:, 1]] == 2): |
| 227 | raise ValueError( |
| 228 | "Censor flag indicates interval censored but only has one \ |
| 229 | failure time" |
| 230 | ) |
| 231 | |
| 232 | if not all(c[x[:, 0] != x[:, 1]] == 2): |
| 233 | raise ValueError( |
| 234 | "Censor flag provided, but case where interval flagged as \ |
| 235 | non interval censoring" |
| 236 | ) |
| 237 | |
| 238 | if any((c != 0) & (c != 1) & (c != -1) & (c != 2)): |
| 239 | raise ValueError( |
| 240 | "Censoring value must only be one of -1, 0, 1, or 2" |
| 241 | ) |
| 242 | |
| 243 | else: |
| 244 | if any((c != 0) & (c != 1) & (c != -1)): |
| 245 | raise ValueError( |
| 246 | "Censoring value must only be one of -1, 0, 1 for single \ |
| 247 | dimension input" |
| 248 | ) |
| 249 | else: |
| 250 | c = np.zeros(x.shape[0]) |
| 251 | if x.ndim != 1: |
| 252 | c[x[:, 0] != x[:, 1]] = 2 |
| 253 | |
| 254 | if n is not None: |
| 255 | n = np.array(n) |
| 256 | if n.ndim != 1: |
| 257 | raise ValueError("Count array must be one dimensional") |
| 258 | if n.shape[0] != x.shape[0]: |
| 259 | raise ValueError( |
| 260 | "count array must be same length as variable array." |
| 261 | ) |
| 262 | if not (n > 0).all(): |
| 263 | raise ValueError("count array can't be 0") |
| 264 | else: |
| 265 | # Do check here for groupby and binning |
| 266 | n = np.ones(x.shape[0]) |
| 267 | |
| 268 | if x.ndim == 2: |
| 269 | if np.isinf(x).all(axis=1).any(): |
| 270 | raise ValueError( |
| 271 | "Interval censored entry has no info: in range (-inf, inf)" |
| 272 | ) |
| 273 | # Convert interval censored from (v, to inf) to |
no outgoing calls