Description Usage Arguments Details Value Author(s) Examples
These utility functions compute (weighted) means, variances and covariances for dataframe partitioned by a factor. The scale transforms a numeric matrix in a centred and scaled matrix for any weighting.
1 2 3 4 5 6 7 | covwt(x, wt, na.rm = FALSE)
varwt(x, wt, na.rm = FALSE)
scalewt(df, wt = rep(1/nrow(df), nrow(df)), center = TRUE, scale = TRUE)
meanfacwt(df, fac = NULL, wt = rep(1/nrow(df), nrow(df)), drop = FALSE)
varfacwt(df, fac = NULL, wt = rep(1/nrow(df), nrow(df)), drop = FALSE)
covfacwt(df, fac = NULL, wt = rep(1/nrow(df), nrow(df)), drop = FALSE)
scalefacwt(df, fac = NULL, wt = rep(1/nrow(df), nrow(df)), scale = TRUE, drop = FALSE)
|
x |
a numeric vector ( |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
df |
a dataframe containing the data. |
fac |
a factor partitioning the data. |
wt |
a numeric vector of weights. |
drop |
a logical value indicating whether unused levels should be kept. |
scale |
a logical value indicating whether data should be scaled or not. |
center |
a logical value indicating whether data should be centered or not. |
Functions returns biased estimates of variances and covariances (i.e. divided by n and not n-1)
For varwt
, the weighted variance. For covwt
,
the matrix of weighted co-variances. For scalewt
, the scaled
dataframe. For other function a list (if fac
is not null) of dataframes with approriate values
Stephane Dray stephane.dray@univ-lyon1.fr
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.