DutchConcern               package:cmm               R Documentation

_C_o_n_c_e_r_n _a_b_o_u_t _c_r_i_m_e _a_n_d _s_o_c_i_a_l _s_e_c_u_r_i_t_y _i_n _t_h_e _N_e_t_h_e_r_l_a_n_d_s

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

     Data from a trend study where two survey questions, regarding (i)
     concern about crime and (ii) concern about social security, were
     asked to randomly selected people in the Netherlands at ten
     different time points (November 1977 to July 1981). The data are
     tabulated in Bergsma, Croon, and Hagenaars (2009, Table 4.1, Table
     4.2).

     Section 4.1 in Bergsma, Croon, and Hagenaars (2009).

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

     data(DutchConcern)

_F_o_r_m_a_t:

     A data frame with 5742 observations on the following variables.

     '_S' Concern about social security (ordered): 1 = No (big) problem;
          2 = big problem; 3 = Very big problem.

     '_C' Concern about crime (ordered): 1 = No (big) problem; 2 = big
          problem; 3 = Very big problem.

     '_T' time points (factor): 1 = Nov 1977; 2 = Jan 1978; 3 = Jun
          1978; 4 = Nov 1978; 5 = Mar 1979; 6 = Oct 1979; 7 = Apr 1980;
          8 = Oct 1980; 9 = Dec 1980; 10 = Jan 1981.


_S_o_u_r_c_e:

     Hagenaars (1990, p. 289) and Continuous survey, University of
     Amsterdam / Steinmetz Archives Amsterdam.

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

     Bergsma, W. P., Croon, M. A., & Hagenaars, J. A. P. (2009).
     _Marginal models for dependent, clustered, and longitudinal
     categorical data._ Berlin: Springer

     Hagenaars, J. A. P. (1990). _Categorical longitudinal data:
     Log-linear panel, trend, and cohort analysis_. Newbury Park, CA:
     Sage.

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

     data(DutchConcern)
     n=c(t(ftable(DutchConcern)))

     # Table 4.2
     #NB: PLEASE REMOVE THE "#" BEFORE APPLY IN NEXT LINES, WON'T GO THROUGH R-CHECK OTHERWISE/
     at1 = MarginalMatrix(c("S", "C", "T"), c("S", "T"), c(3, 3, 10));
     print("Concern about social security:")
     #apply(matrix(at1 
     at2 = MarginalMatrix(c("S", "C", "T"), c("C", "T"), c(3, 3, 10));
     print("Concern about crime:")
     #apply(matrix(at2 

     ##############################################################################
     # Define and fit models for marginal table IRT (Section 4.1.1)

     # atIRT 
     atIRT = MarginalMatrix(c("S", "C", "T"), list(c("S", "T"), c("C", "T")), c(3, 3, 10));
     # bt1.Log(atIRT.pi)=0 is marginal model for independence of IT and R \
     bt1 = ConstraintMatrix(c("I", "R", "T"), list(c("I", "T"), c("R")), c(2, 3, 10));
     bt2 = ConstraintMatrix(c("I", "R", "T"), list(c("I", "T"), c("R", "T")), c(2, 3, 10));
     bt3 = ConstraintMatrix(c("I", "R", "T"), list(c("I", "T"), c("I", "R")), c(2, 3, 10));
     bt4 = ConstraintMatrix(c("I", "R", "T"), list(c("I", "T"), c("I", "R"), c("R", "T")), c(2, 3, 10));

     model1 = list(bt1, "log", atIRT);
     model2 = list(bt2, "log", atIRT);
     model3 = list(bt3, "log", atIRT);
     model4 = list(bt4, "log", atIRT);

     #  change model1 to model2 etc to fit different models
     pi1 = MarginalModelFit(n, model4,
        ShowProgress = 5,
        CoefficientDimensions = c(2, 3, 10),
        Labels = c("I", "R", "T"));

     ##############################################################################
     # Simultaneous model for marginal and joint distributions (Section 4.1.2)

     # define x, the design matrix for the loglinear model of Eq. 4.1
     x = DesignMatrix(c("S","C","T"), c("S","C","T"), c(3,3,10), SubsetCoding = list(c("S", "C", "T"),list("Nominal","Nominal","Linear")));
     # model6 is the simultaneous model
     model6 = list(model4, x);

     # NB: when fitting model6 Labels and CoefficientDimensions should be appropriate to get the right output
     # for table IRT, which is different than for model5
     #NB: REMOVE "#" IN NEXT LINE, WON'T GO THROUGH R-CHECK
     #pi5 = MarginalModelFit(DutchConcern, model6, ShowProgress = 5, CoefficientDimensions = c(2, 3, 10), Labels = c("I", "R", "T"), MaxSteps = 500);

