# stats0: Descriptive Statistics for a Vector or a Data Frame In miceadds: Some Additional Multiple Imputation Functions, Especially for 'mice'

## Description

Applies descriptive statistics to a vector or a data frame. The function `stats0` is a general function. This function is used for extending the basic descriptive statistics functions from the base and stats package. The function `prop_miss` computes the proportion of missing data for each variable.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ```stats0(x, FUN, na.rm=TRUE,...) max0(x, na.rm=TRUE) mean0(x, na.rm=TRUE) min0(x, na.rm=TRUE) quantile0(x, probs = seq(0, 1, 0.25), na.rm=TRUE) sd0(x, na.rm=TRUE) var0(x, na.rm=TRUE) prop_miss(x) ```

## Arguments

 `x` Vector or a data frame `FUN` Function which is applied to `x` `na.rm` Logical indicating whether missing data should be removed `probs` Probabilities `...` Further arguments to be passed

## Value

A vector or a matrix

## Author(s)

Alexander Robitzsch

`base::max`, `base::mean`, `base::min`, `stats::quantile`, `stats::sd`, `stats::var`

## Examples

 ``` 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``` ```############################################################################# # EXAMPLE 1: Descriptive statistics toy datasets ############################################################################# #--- simulate vector y and data frame dat set.seed(765) N <- 25 # number of observations y <- stats::rnorm(N) V <- 4 # number of variables dat <- matrix( stats::rnorm( N*V ) , ncol=V ) colnames(dat) <- paste0("V",1:V) #-- standard deviation apply( dat , 2 , stats::sd ) sd0( dat ) #-- mean apply( dat , 2 , base::mean ) mean0( dat ) #-- quantile apply( dat , 2 , stats::quantile ) quantile0( dat ) #-- minimum and maximum min0(dat) max0(dat) #*** apply functions to missing data dat1 <- dat dat1[ cbind( c(2,5) ,2) ] <- NA #-- proportion of missing data prop_miss( dat1 ) #-- MAD statistic stats0( dat , FUN = stats::mad ) #-- SD sd0(y) ```

### Example output

```Loading required package: mice
V1        V2        V3        V4
0.9480664 1.1013884 0.9019879 0.7371857
V1        V2        V3        V4
0.9480664 1.1013884 0.9019879 0.7371857
V1           V2           V3           V4
-0.226196785  0.574153533  0.112860173 -0.004732666
V1           V2           V3           V4
-0.226196785  0.574153533  0.112860173 -0.004732666
V1         V2         V3          V4
0%   -2.24235286 -0.8546087 -1.4362801 -1.07327985
25%  -0.83641426 -0.3645960 -0.5983010 -0.52963615
50%  -0.06835345  0.4787022 -0.1094036  0.06631764
75%   0.54462543  0.9859189  0.8828221  0.32541820
100%  1.18778051  3.1118669  1.6148352  2.15683057
V1         V2         V3          V4
0%   -2.24235286 -0.8546087 -1.4362801 -1.07327985
25%  -0.83641426 -0.3645960 -0.5983010 -0.52963615
50%  -0.06835345  0.4787022 -0.1094036  0.06631764
75%   0.54462543  0.9859189  0.8828221  0.32541820
100%  1.18778051  3.1118669  1.6148352  2.15683057
V1         V2         V3         V4
-2.2423529 -0.8546087 -1.4362801 -1.0732798
V1       V2       V3       V4
1.187781 3.111867 1.614835 2.156831
V1   V2   V3   V4
0.00 0.08 0.00 0.00
V1        V2        V3        V4
1.1070882 1.1221094 1.1156242 0.8516409
[1] 1.02124
```

miceadds documentation built on Aug. 25, 2017, 1:03 a.m.