bsgw.crossval {BSGW} | R Documentation |

`bsgw.crossval`

calculates cross-validation-based, out-of-sample log-likelihood of a bsgw model for a data set, given the supplied folds. `bsgw.crossval.wrapper`

applies `bsgw.crossval`

to a set of combinations of shrinkage parameters (`lambda`

,`lambdas`

) and produces the resulting vector of log-likelihood values as well as the specific combination of shrinkage parameters associated with the maximum log-likelihood. `bsgw.generate.folds`

generates random partitions, while `bsgw.generate.folds.eventbalanced`

generates random partitions with events evenly distributed across partitions. The latter feature is useful for cross-valiation of small data sets with low event rates, since it prevents over-accumulation of events in one or two partitions, and lack of events altogether in other partitions.

bsgw.generate.folds(ntot, nfold=5) bsgw.generate.folds.eventbalanced(formula, data, nfold=5) bsgw.crossval(data, folds, all=FALSE, print.level=1 , control=bsgw.control(), ncores=1, ...) bsgw.crossval.wrapper(data, folds, all=FALSE, print.level=1 , control=bsgw.control(), ncores=1 , lambda.vec=exp(seq(from=log(0.01), to=log(100), length.out = 10)), lambdas.vec=NULL , lambda2=if (is.null(lambdas.vec)) cbind(lambda=lambda.vec, lambdas=lambda.vec) else as.matrix(expand.grid(lambda=lambda.vec, lambdas=lambdas.vec)) , plot=TRUE, ...)

`ntot` |
Number of observations to create partitions for. It must typically be set to |

`nfold` |
Number of folds or partitions to generate. |

`formula` |
Survival formula, used to extract the binary |

`data` |
Data frame used in model training and prediction. |

`folds` |
An integer vector of length |

`all` |
If |

`print.level` |
Verbosity of progress report. |

`control` |
List of control parameters, usually the output of bsgw.control. |

`ncores` |
Number of cores for parallel execution of cross-validation code. |

`lambda.vec` |
Vector of shrinkage parameters to be tested for scale-parameter coefficients. |

`lambdas.vec` |
Vector of shrinkage parameters to be tested for shape-parameter coefficients. |

`lambda2` |
A data frame that enumerates all combinations of |

`plot` |
If |

`...` |
Other arguments to be passed to bsgw. |

Functions `bsgw.generate.folds`

and `bsgw.generate.folds.eventbalanced`

produce integer vectors of length `ntot`

or `nrow(data)`

respectively. The output of these functions can be directly passed to `bsgw.crossval`

or `bsgw.crossval.wrapper`

. Function `bsgw.crossval`

returns the log-likelihood of data under the assumed bsgw model, calculated using a cross-validation scheme with the supplied `fold`

parameter. If `all=TRUE`

, the estimation objects for each of the `nfold`

estimation jobs will be returned as the "estobjs" attribute of the returned value. Function `bsgw.crossval.wrapper`

returns a list with elements `lambda`

and `lambdas`

, the optimal shrinkage parameters for scale and shape coefficients, respectively. Additionally, the following attributes are attached:

`loglike.vec` |
Vector of log-likelihood values, one for each tested combination of |

`loglike.opt` |
The maximum log-likelihood value from the |

`lambda2` |
Data frame with columns |

`estobjs` |
If |

Alireza S. Mahani, Mansour T.A. Sharabiani

library("survival") data(ovarian) folds <- bsgw.generate.folds.eventbalanced(Surv(futime, fustat) ~ 1, ovarian, 5) cv <- bsgw.crossval(ovarian, folds, formula=Surv(futime, fustat) ~ ecog.ps + rx , control=bsgw.control(iter=50, nskip=10), print.level = 3) cv2 <- bsgw.crossval.wrapper(ovarian, folds, formula=Surv(futime, fustat) ~ ecog.ps + rx , control=bsgw.control(iter=50, nskip=10) , print.level=3, lambda.vec=exp(seq(from=log(0.1), to=log(1), length.out = 3)))

[Package *BSGW* version 0.9.2 Index]