Description Usage Arguments Details Value See Also Examples
sdMean
calculates estimates of standard deviatitions
and confidence intervals
for weighted means with minimax weights by observations
from the mixture with varying concentrations.
1 2 |
x |
numeric vector with the observed sample or a
|
p |
matrix (or data frame) of mixing probabilities with rows corresponding to subjects and columns coresponding to the mixture components. |
comp |
a numeric vector with numbers of components for which the standard deviations are estimated. |
means |
logical, if |
CI |
logical, if |
alpha |
confidense level for the confidence interval. |
If CI=TRUE
then the function calculates
confidence intervals for the components' means
with covering probability 1-alpha
.
If x
is a vector then the weights for components' means and variances
are calculated as lsweight(p)
. If x
is a wtsamp
object than its own weights are used.
if CI & means =FALSE
the function returns a vector
of the estimated standard deviations
with NA for the components which were not estimated.
Else a data frame is returned in which there can be variables:
sd
are standard deviations of estimates;
means
are the estimates of means;
lower
and upper
are lower and upper bounds
of the confidence intervals for means.
Maiboroda R. and Kubaichuk O. Asymptotic normality of improved weighted empirical distribution functions. Theor. Probability and Math. Statist. 69 (2004), 95-102
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | set.seed(3)
M<-3 # number of mixture components
p <- genunifp(1000,M) # create mixing probabilities
m<-c(0,1,2) # true means of components
sd<-c(1,1,0.5) # true sd of components
x<-genormixt(p,m,sd) # sample generation
# Calculate sd only:
sdMean(x,p)
# the same:
sdMean(wtsamp(x,indiv=lsweight(p)),p)
# Calculate confidence intervals:
sdMean(x,p,means=TRUE,CI=TRUE)
# Plot confidence intervals:
CI<-sdMean(x,p,means=TRUE,CI=TRUE)
library(plotrix)
plotCI(1:M,CI$means,ui=CI$upper,li=CI$lower,
xlab=" ",ylab="means",xaxt="n")
axis(1,at=1:M,labels=row.names(CI))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.