# closPseudo: Pseudo Value Regression for the Extra Length-of-Stay In etm: Empirical Transition Matrix

## Description

Pseudo Value Regression for the Extra Length-of-Stay

## Usage

 ```1 2``` ```closPseudo(data, state.names, tra, cens.name, s = 0, formula, aw = FALSE, ratio = FALSE, ncores = 1) ```

## Arguments

 `data` data.frame of the form data.frame(id,from,to,time) or (id,from,to,entry,exit) id:patient id from:the state from where the transition occurs to:the state to which a transition occurs time:time when a transition occurs entry:entry time in a state exit:exit time from a state `state.names` A vector of characters giving the states names. `tra` A quadratic matrix of logical values describing the possible transitions within the multistate model. `cens.name` A character giving the code for censored observations in the column 'to' of `data`. If there is no censored observations in your data, put 'NULL'. `s` Starting value for computing the transition probabilities. `formula` A formula with the covariates at the right of a `~` operator. Leave the left part empty. `aw` Logical. Whether to compute the expected change of LOS using alternative weighting. Default is `FALSE`. `ratio` Logical. Compute the ratio of the expected length-of-stay given instermediate event status instead of a difference. Default value is `FALSE` `ncores` Number of cores used if doing parallel computation using the parallel package

## Details

The function calculates the pseudo-observations for the extra length-of-stay for each individual. These pseudo-observations can then be used to fit a direct regression model using generalized estimating equation (e.g., package geepack).

Computation of the pseudo-observations can be parallelised using the `mclapply` function of the parallel package. See argument `ncores`.

## Value

An object of class `closPseudo` with the following components:

 `pseudoData` a data.frame containing `id`, computed pseudo values (see details) and the covariates as specified in the formula `theta` Estimates of excess LoS in the whole sample `aw` like in the function call `call` Function call

## Author(s)

Arthur Allignol [email protected]

## References

Andersen, P.K, Klein, J.P, Rosthoj, S. (2003). Generalised linear models for correlated pseudo-observations, with applications to multi-state models. Biometrika, 90(1):15–27.

`mclapply`, `clos`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37``` ```library(kmi) ## data in kmi package data(icu.pneu) my.icu.pneu <- icu.pneu my.icu.pneu <- my.icu.pneu[order(my.icu.pneu\$id, my.icu.pneu\$start), ] masque <- diff(my.icu.pneu\$id) my.icu.pneu\$from <- 0 my.icu.pneu\$from[c(1, masque) == 0] <- 1 my.icu.pneu\$to2 <- my.icu.pneu\$event my.icu.pneu\$to2[my.icu.pneu\$status == 0] <- "cens" my.icu.pneu\$to2[c(masque, 1) == 0] <- 1 my.icu.pneu\$to <- ifelse(my.icu.pneu\$to2 %in% c(2, 3), 2, my.icu.pneu\$to2) my.icu.pneu <- my.icu.pneu[, c("id", "start", "stop", "from", "to", "to2", "age", "sex")] names(my.icu.pneu)[c(2, 3)] <- c("entry", "exit") ## computation of the pseudo-observations ## Not run: ps.icu.pneu <- closPseudo(my.icu.pneu, c("0", "1", "2"), tra_ill(), "cens", formula = ~ sex + age) ## regression model using geepack require(geepack) fit <- geeglm(ps.e.phi ~ sex + age, id = id, data = ps.icu.pneu\$pseudoData, family = gaussian) summary(fit) ## End(Not run) ```