sdMedian: Estimates for standard deviations and CI for weighted medians...

Description Usage Arguments Details Value Examples

Description

sdMedian calculates estimates of standard deviatitions and confidence intervals for weighted medians with minimax weights by observations from the mixture with varying concentrations.

Usage

1
2
sdMedian(x, p, comp = 1:ncol(p), medians = FALSE, CI = FALSE,
  alpha = 0.05)

Arguments

x

numeric vector with the observed sample or a wtsamp object.

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 TRUE then the estimates for components' medians are included in the function value.

CI

logical, if TRUE then confidence bounds for components' means are inculded in the function value.

If x is a vector then the weights for components' medians and variances are calculated as lsweight(p). If x is a wtsamp object than its own weights are used.

alpha

confidense level for the confidence interval.

Details

if CI=TRUE then the function calculates confidence intervals for the components' medians with covering probability 1-alpha.

Value

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

Examples

 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))

RostyslavMaiboroda/mixvconc documentation built on June 12, 2019, 12:34 a.m.