ds.var {dsBaseClient} R Documentation

## ds.var calling aggregate function varDS

### Description

Computes the variance of a given vector This function is similar to the R function var.

### Usage

ds.var(x = NULL, type = "split", checks = FALSE,
datasources = NULL)


### Arguments

 x a character, the name of a numerical vector. type a character which represents the type of analysis to carry out. If type is set to 'combine', 'combined', 'combines' or 'c', a global variance is calculated if type is set to 'split', 'splits' or 's', the variance is calculated separately for each study. if type is set to 'both' or 'b', both sets of outputs are produced checks a Boolean indicator of whether to undertake optional checks of model components. Defaults to checks=FALSE to save time. It is suggested that checks should only be undertaken once the function call has failed datasources a list of opal object(s) obtained after login in to opal servers; these objects hold also the data assign to R, as dataframe, from opal datasources.

### Details

It is a wrapper for the server side function. The server side function returns a list with the sum of the input variable, the sum of squares of the input variable, the number of missing values, the number of valid values, the number of total lenght of the variable, and a study message indicating whether the number of valid is less than the disclosure threshold. The variance is calculated at the client side by the formula $\frac{∑{x_i^2}}{N-1}-\frac{(∑{x_i})^2}{N(N-1)}$

### Value

a list including: Variance.by.Study = estimated variance in each study separately (if type = split or both), with Nmissing (number of missing observations), Nvalid (number of valid observations), Ntotal (sum of missing and valid observations) also reported separately for each study; Global.Variance = Variance, Nmissing, Nvalid, Ntotal across all studies combined (if type = combine or both); Nstudies = number of studies being analysed; ValidityMessage indicates whether a full analysis was possible or whether one or more studies had fewer valid observations than the nfilter threshold for the minimum cell size in a contingency table.

### Author(s)

Amadou Gaye, Demetris Avraam, for DataSHIELD Development Team

### Examples

## Not run:

# login and assign specific variable(s)
myvar <- list('LAB_TSC')
ds.var(x='D$LAB_TSC') # Example 2: compute the variance of each study separately ds.var(x='D$LAB_TSC', type='split')