CI                  package:epicalc                  R Documentation

_C_o_n_f_i_d_e_n_c_e _i_n_t_e_r_v_a_l _o_f _p_r_o_b_a_b_i_l_t_y, _m_e_a_n _a_n_d _i_n_c_i_d_e_n_c_e

_D_e_s_c_r_i_p_t_i_o_n:

     Compute confidence interval of variables or values input from
     keyboard.

_U_s_a_g_e:

     ci(x, ...)

     ## Default S3 method:
     ci(x,...)

     ## S3 method for class 'binomial':
     ci(x, size, precision, alpha = 0.05, ...)

     ## S3 method for class 'numeric':
     ci(x, n, sds, alpha = 0.05, ...)

     ## S3 method for class 'poisson':
     ci(x, person.time, precision, alpha = 0.05, ...) 

_A_r_g_u_m_e_n_t_s:

       x: a variable for 'ci', number of success for 'ci.binomial',
          mean(s) for 'ci.numeric', and counts for 'ci.poisson'.

    size: denominator for success.

precision: level of precision used during computation for the
          confidence limits.

   alpha: significance level.

       n: sample size.

     sds: sd(s).

person.time: denominator for count.

     ...: further arguments passed to or used by methods.

_D_e_t_a_i_l_s:

     These functions compute confidence intervals of probability, mean
     and incidence from variables in a dataset or values from keyboard
     input.

     'ci' will try to identify the nature of the variable 'x' and
     determine the appropriate method (between 'ci.binomial' and
     'ci.numeric') for computation. 'ci' without a specified method
     will never call 'ci.poisson'.

     The specific method ie. 'ci.binomial', 'ci.numeric' and
     'ci.poisson' should be used when the values are input from the
     keyboard or from an aggregate data frame with columns of variables
     for the arguments.

     'ci.binomial' and 'ci.numeric' employ exact probability
     computation while 'ci.numeric' is based on the t-distribution
     assumption.

_V_a_l_u_e:

     'ci.binomial' and 'ci.poisson' return a data frame containing the
     number of events, the denominator and the incidence rate.
     'ci.numeric' returns means and standard deviations. All of these
     are followed by the standard error and the confidence limit, the
     level of which is determined by 'alpha'

_A_u_t_h_o_r(_s):

     Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

_S_e_e _A_l_s_o:

     'summ'

_E_x_a_m_p_l_e_s:

     data(Oswego)
     use(Oswego)
     # logical variable
     ci(ill)
     # numeric variable
     ci(age)
     # factor
     ci(sex=="M")
     ci(sex=="F")

     # Example of confidence interval for means
     library(MASS)
     use(Cars93)
     car.price <- aggregate(Price, by=list(type=Type), FUN=c("mean","length","sd"))
     car.price
     ci.numeric(x=car.price$mean, n=car.price$length, sds=car.price$sd.Price )
      
     # Example of confidence interval for probabilty
     data(ANCdata)
     use(ANCdata)
     death1 <- death=="yes"
     death.by.group <- aggregate.numeric(death1, 
             by=list(anc=anc, clinic=clinic), FUN=c("sum","length"))
     death.by.group
     ci.binomial(death.by.group$sum.death1, death.by.group$length)

     # Example of confidence interval for incidence
     data(Montana)
     des(Montana)
     age.Montana <- aggregate.data.frame(Montana[,1:2],
             by=list(agegr=Montana$agegr),FUN="sum")
     age.Montana
     ci.poisson(age.Montana$respdeath, person.time=age.Montana$personyrs)

     # Keyboard input
     # What is the 95 % CI of sensitivity of a test that gives all
     # positive results among 40 diseased individuals
     ci.binomial(40,40)

     # What is the 99 % CI of incidence of a disease if the number
     # of cases is 25 among 340,000 person-years
     ci.poisson(25, 340000, alpha=.01) # 4.1 to 12.0 per 100,000 person-years

