expected              package:epitools              R Documentation

_E_x_p_e_c_t_e_d _v_a_l_u_e_s _i_n _a _t_a_b_l_e

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

     Assuming independence, calculates expected values in a matrix or
     table.

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

     expected(x)

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

       x: is a matrix or table

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

     Assuming independence, calculates expected values in a matrix or
     table.

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

     expected values

_N_o_t_e:

     Visit <URL: http://www.epitools.net> for the latest.

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

     Tomas Aragon, aragon@berkeley.edu, <URL: http://www.medepi.com>

_R_e_f_e_r_e_n_c_e_s:

     Steve Selvin (2001), Epidemiologic Analysis: A Case-Oriented
     Approach, Oxford University Press

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

     See also 'margin.table'

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

     ##From Selvin, 2001, p.2
     ##year = year of birth
     ##one+ = one or more congenital defects
     ##one = one congenital defect
     dat <- scan()
       369  460
       434  434
       506  487
       521  518
       526  488
       605  481
       649  477
       733  395
       688  348

     ##observed
     oi <- matrix(dat, nrow =2)
     colnames(oi) <- 1983:1991
     rownames(oi) <- c("one+", "one")

     ##expected
     ei <- expected(oi)

     ##Pearson chi-square test 
     chi2.T <- sum((oi - ei)^2/ei)
     pchisq(q = chi2.T, df = 8, lower.tail = FALSE)

