science                 package:DAAG                 R Documentation

_S_c_h_o_o_l _S_c_i_e_n_c_e _S_u_r_v_e_y _D_a_t_a

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

     The 'science' data frame has 1385 rows and 7 columns.

     The data are on attitudes to science, from a survey where there
     were results from 20 classes in private schools and 46 classes in
     public schools.

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

     science

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

     This data frame contains the following columns:

     _S_t_a_t_e a factor with levels 'ACT' Australian Capital Territory, 
          'NSW' New South Wales

     _P_r_i_v_P_u_b a factor with levels 'private' school,  'public' school

     _s_c_h_o_o_l a numeric code identifying the school

     _c_l_a_s_s a numeric vector identifying the class

     _s_e_x a factor with levels 'f', 'm' 

     _l_i_k_e a summary score based on two of the questions, on a scale
          from 1 (dislike) to 12 (like)

     _C_l_a_s_s a factor with levels corresponding to each class

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

     Francine Adams,  Rosemary Martin and Murali Nayadu, Australian
     National University

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

     attach(science)
     classmeans <- aggregate(like, by=list(PrivPub, Class), mean)
     names(classmeans) <- c("PrivPub","Class","like")
     dim(classmeans)

     attach(classmeans)
     boxplot(split(like, PrivPub), ylab = "Class average of attitude to science score", boxwex = 0.4)
     rug(like[PrivPub == "private"], side = 2)
     rug(like[PrivPub == "public"], side = 4)
     detach(classmeans)

     require(nlme)
     science.lme <- lme(fixed = like ~ sex + PrivPub,
       data = science, random = ~ 1 | school/Class, na.action=na.omit)
     summary(science.lme)$tTable # Print coefficients.

     science1.lme <- lme(fixed = like ~ sex + PrivPub, data = science,
     random = ~ 1 | Class, na.action=na.exclude)
     summary(science1.lme)$tTable # Table of coefficients

     intervals(science1.lme, which="var-cov")[[1]]$Class^2
     intervals(science1.lme, which="var-cov")[[2]]^2 

     science.lme <- lme(fixed = like ~ sex + PrivPub,
       data = science, random =  ~ 1 | Class/school, na.action=na.exclude)
     res <- residuals(science.lme)
     hat <- fitted(science.lme)
     coplot(res ~ hat|science$PrivPub[is.na(science$sex)!=TRUE],
       xlab="Fitted values", ylab="Residuals")
     detach(science)

