ds.var {dsBaseClient} | R Documentation |
Computes the variance of a given vector
This function is similar to the R function var
.
ds.var(x = NULL, type = "split", checks = FALSE, datasources = NULL)
x |
a character, the name of a numerical vector. |
type |
a character which represents the type of analysis to carry out.
If |
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 |
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)}
$
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.
Amadou Gaye, Demetris Avraam, for DataSHIELD Development Team
## Not run: # load that contains the login details data(logindata) # login and assign specific variable(s) myvar <- list('LAB_TSC') opals <- datashield.login(logins=logindata,assign=TRUE,variables=myvar) # Example 1: compute the pooled variance of the variable 'LAB_TSC' - default behaviour ds.var(x='D$LAB_TSC') # Example 2: compute the variance of each study separately ds.var(x='D$LAB_TSC', type='split') # clear the Datashield R sessions and logout datashield.logout(opals) ## End(Not run)