Description Usage Arguments Details Value Examples
sdMedian
calculates estimates of standard deviatitions
and confidence intervals
for weighted medians 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. |
medians |
logical, if |
CI |
logical, if If |
alpha |
confidense level for the confidence interval. |
if CI=TRUE
then the function calculates
confidence intervals for the components' medians
with covering probability 1-alpha
.
if CI & medians =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;
medians
are the estimates of medians;
lower
and b nupper
are lower and upper bounds
of the confidence intervals for medians.
c
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:
sdMedian(x,p)
# the same result:
sdMedian(wtsamp(x,indiv=lsweight(p)),p)
# Calculate confidence intervals:
sdMedian(x,p,medians=TRUE,CI=TRUE)
# Plot confidence intervals:
CI<-sdMedian(x,p,medians=TRUE,CI=TRUE)
library(plotrix)
plotCI(1:M,CI$medians,ui=CI$upper,li=CI$lower,
xlab=" ",ylab="medians",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.