library('intsvy')

Read data for selected education systems and variables

dir <- "/home/eldani/MEGA/Work/international LSA/TIMSS/TIMSS 11/Grade 8/Data" # enter your directory (eg. C:/TIMSS 2011/Data)
timss8g <- timssg8.select.merge(folder=dir, countries=c("AUS", "BHR", "ARM", "CHL"),
           student =c("BSDGEDUP", "ITSEX", "BSDAGE", "BSBGSLM", "BSDGSLM"),
           school=c("BCBGDAS", "BCDG03"))

Calculate mean math performance by education system

timss.mean.pv(pvlabel="BSMMAT", by= "IDCNTRYL", data=timss8g)
##    IDCNTRYL Freq   Mean s.e.    SD  s.e
## 1   Armenia 5846 466.59 2.73 90.68 1.73
## 2 Australia 7556 504.80 5.09 85.42 3.36
## 3   Bahrain 4640 409.22 1.96 99.57 1.72
## 4     Chile 5835 416.27 2.59 79.65 1.85

Calculate mean performance results by education system and student’s sex

timss.mean.pv(pvlabel="BSMMAT", by= c("IDCNTRYL", "ITSEX"), data=timss8g)
##    IDCNTRYL ITSEX Freq   Mean s.e.     SD  s.e
## 1   Armenia  GIRL 2894 471.52 3.07  87.13 1.81
## 2   Armenia   BOY 2952 461.86 3.21  93.72 2.24
## 3 Australia  GIRL 3747 500.41 4.72  82.72 3.59
## 4 Australia   BOY 3809 509.16 7.26  87.80 4.82
## 5   Bahrain  GIRL 2288 430.78 2.51  87.23 1.93
## 6   Bahrain   BOY 2352 387.89 3.07 106.20 2.26
## 7     Chile  GIRL 3133 409.46 3.23  79.97 2.39
## 8     Chile   BOY 2702 423.94 3.05  78.59 2.03

Calculate mean of scale by education system

BSBGSLM is a scale reflecting the extent to which the students like learning mathematics.

timss.mean(variable="BSBGSLM", by='IDCNTRYL', data=timss8g)
##    IDCNTRYL Freq  Mean s.e.
## 1   Armenia 5626 10.87 0.05
## 2 Australia 7389  9.32 0.06
## 3   Bahrain 4581  9.77 0.03
## 4     Chile 5772  9.76 0.04

Regression mean differences between boys and girls

Reported mean differences between boys and girls can be tested for statistical significance

timss.reg.pv(pvlabel="BSMMAT", by="IDCNTRYL", x="ITSEX", data=timss8g)
## $Armenia
##             Estimate Std. Error t value
## (Intercept)   471.52       3.07  153.75
## ITSEXBOY       -9.66       3.10   -3.12
## R-squared       0.00       0.00    1.61
## 
## $Australia
##             Estimate Std. Error t value
## (Intercept)   500.41       4.72  105.93
## ITSEXBOY        8.75       6.90    1.27
## R-squared       0.00       0.00    0.83
## 
## $Bahrain
##             Estimate Std. Error t value
## (Intercept)   430.78       2.51  171.50
## ITSEXBOY      -42.89       3.99  -10.74
## R-squared       0.05       0.01    5.44
## 
## $Chile
##             Estimate Std. Error t value
## (Intercept)   409.46       3.23  126.86
## ITSEXBOY       14.48       3.63    3.99
## R-squared       0.01       0.00    1.89

The ITSEXBOY coefficient indicates whether differences between boys and girls are statistically significant.

Frequency table: Percentage of students who like learning maths

timss.table(variable="BSDGSLM", by="IDCNTRYL", data=timss8g)
##     IDCNTRYL                            BSDGSLM Freq Percentage Std.err.
## 1    Armenia          LIKE LEARNING MATHEMATICS 2421      42.92     0.97
## 2    Armenia SOMEWHAT LIKE LEARNING MATHEMATICS 2181      39.48     0.76
## 3    Armenia   DO NOT LIKE LEARNING MATHEMATICS 1024      17.60     0.97
## 4  Australia          LIKE LEARNING MATHEMATICS 1068      15.67     0.94
## 5  Australia SOMEWHAT LIKE LEARNING MATHEMATICS 2985      39.81     0.87
## 6  Australia   DO NOT LIKE LEARNING MATHEMATICS 3336      44.53     1.41
## 7    Bahrain          LIKE LEARNING MATHEMATICS 1072      23.75     0.64
## 8    Bahrain SOMEWHAT LIKE LEARNING MATHEMATICS 1756      38.37     0.86
## 9    Bahrain   DO NOT LIKE LEARNING MATHEMATICS 1753      37.88     0.84
## 10     Chile          LIKE LEARNING MATHEMATICS 1289      22.06     0.86
## 11     Chile SOMEWHAT LIKE LEARNING MATHEMATICS 2291      40.21     0.89
## 12     Chile   DO NOT LIKE LEARNING MATHEMATICS 2192      37.73     0.97

Percentiles by education system

timss.per.pv(pvlabel="BSMMAT", per = c(5, 10, 25, 50, 75, 90, 95), by="IDCNTRYL", data=timss8g)
##     IDCNTRYL Percentiles  Score Std. err.
## 1    Armenia           5 310.38      5.89
## 2    Armenia          10 344.07      4.55
## 3    Armenia          25 404.74      4.65
## 4    Armenia          50 472.69      3.32
## 5    Armenia          75 530.60      2.64
## 6    Armenia          90 577.63      3.91
## 7    Armenia          95 607.55      3.61
## 8  Australia           5 368.61      4.82
## 9  Australia          10 396.72      3.35
## 10 Australia          25 444.93      5.09
## 11 Australia          50 502.64      6.03
## 12 Australia          75 559.54      6.98
## 13 Australia          90 617.77      7.80
## 14 Australia          95 652.46     12.02
## 15   Bahrain           5 246.26      6.02
## 16   Bahrain          10 279.18      5.70
## 17   Bahrain          25 339.02      3.35
## 18   Bahrain          50 409.02      2.09
## 19   Bahrain          75 478.77      1.99
## 20   Bahrain          90 538.51      3.55
## 21   Bahrain          95 570.44      4.00
## 22     Chile           5 290.42      8.12
## 23     Chile          10 314.53      3.60
## 24     Chile          25 360.52      3.09
## 25     Chile          50 413.67      4.02
## 26     Chile          75 468.99      4.09
## 27     Chile          90 521.81      4.16
## 28     Chile          95 552.64      4.34

Regression analysis and graphical representation

A regression of mathematics performance against parental education (BSDGEDUP) and the school SES composition according to head teachers (BCDG03):

(myreg <- timss.reg.pv(pvlabel="BSMMAT", x=c("BSDGEDUP", "BCDG03"), by= "IDCNTRYL", data=timss8g))
## $Armenia
##                                                    Estimate Std. Error t value
## (Intercept)                                          500.49       5.91   84.66
## BSDGEDUPPOST-SECONDARY BUT NOT UNIVERSITY            -20.37       4.60   -4.43
## BSDGEDUPUPPER SECONDARY                              -48.63       6.15   -7.90
## BSDGEDUPLOWER SECONDARY                              -60.22      12.99   -4.64
## BSDGEDUPSOME PRIMARY, LOWER SECONDARY OR NO SCHOOL   -50.23     101.62   -0.49
## BCDG03NEITHER MORE AFFLUENT NOR MORE DISADVANTAGED   -17.98       8.96   -2.01
## BCDG03MORE DISADVANTAGED                             -25.80       7.46   -3.46
## R-squared                                              0.06       0.02    4.17
## 
## $Australia
##                                                    Estimate Std. Error t value
## (Intercept)                                          579.73      12.08   48.01
## BSDGEDUPPOST-SECONDARY BUT NOT UNIVERSITY            -54.95       7.09   -7.75
## BSDGEDUPUPPER SECONDARY                              -69.06       8.41   -8.21
## BSDGEDUPLOWER SECONDARY                             -105.09      10.81   -9.72
## BSDGEDUPSOME PRIMARY, LOWER SECONDARY OR NO SCHOOL   -97.33      19.76   -4.93
## BCDG03NEITHER MORE AFFLUENT NOR MORE DISADVANTAGED   -19.72      10.67   -1.85
## BCDG03MORE DISADVANTAGED                             -42.56      11.57   -3.68
## R-squared                                              0.23       0.04    5.72
## 
## $Bahrain
##                                                    Estimate Std. Error t value
## (Intercept)                                          463.50       4.31  107.59
## BSDGEDUPPOST-SECONDARY BUT NOT UNIVERSITY            -36.86       6.77   -5.45
## BSDGEDUPUPPER SECONDARY                              -75.04       4.68  -16.03
## BSDGEDUPLOWER SECONDARY                             -102.33       5.21  -19.64
## BSDGEDUPSOME PRIMARY, LOWER SECONDARY OR NO SCHOOL   -87.08      10.36   -8.41
## BCDG03NEITHER MORE AFFLUENT NOR MORE DISADVANTAGED     0.53       4.02    0.13
## BCDG03MORE DISADVANTAGED                              -4.41       4.16   -1.06
## R-squared                                              0.16       0.01   13.64
## 
## $Chile
##                                                    Estimate Std. Error t value
## (Intercept)                                          491.77       9.08   54.16
## BSDGEDUPPOST-SECONDARY BUT NOT UNIVERSITY            -16.55       5.24   -3.16
## BSDGEDUPUPPER SECONDARY                              -31.90       6.20   -5.14
## BSDGEDUPLOWER SECONDARY                              -52.43       8.69   -6.04
## BSDGEDUPSOME PRIMARY, LOWER SECONDARY OR NO SCHOOL   -56.22      13.74   -4.09
## BCDG03NEITHER MORE AFFLUENT NOR MORE DISADVANTAGED   -26.26      10.80   -2.43
## BCDG03MORE DISADVANTAGED                             -53.14      11.88   -4.47
## R-squared                                              0.17       0.03    5.69

BSDGEDUP and BCDG03 are factors and therefore dichotomised in regression models. References categories are “UNIVERSITY OR HIGHER” for BSDGEDUP and “MORE AFFLUENT” for BCDG03, which explains negative coefficients.

levels(timss8g$BSDGEDUP) and levels(timss8g$BCDG03) print variable categories.

Factors can be converted to numeric variables for producing a single effect for each variable. Another alternative is to import the data as numeric with the use.labels=FALSE option.

timss8g$BSDGEDUPn <- 6 - as.numeric(timss8g$BSDGEDUP)
timss8g$BCDG03n <- 4-as.numeric(timss8g$BCDG03)

Numeric variables are introduced as independent variables in the regression.

(myreg <- timss.reg.pv(pvlabel="BSMMAT", x=c("BSDGEDUPn", "BCDG03n"), by= "IDCNTRYL", data=timss8g))
## $Armenia
##             Estimate Std. Error t value
## (Intercept)   348.24      15.32   22.73
## BSDGEDUPn      22.54       3.03    7.43
## BCDG03n        12.84       3.76    3.42
## R-squared       0.06       0.02    4.10
## 
## $Australia
##             Estimate Std. Error t value
## (Intercept)   341.03      17.20   19.83
## BSDGEDUPn      32.57       3.61    9.03
## BCDG03n        22.95       6.22    3.69
## R-squared       0.22       0.04    5.68
## 
## $Bahrain
##             Estimate Std. Error t value
## (Intercept)   291.65       7.29   39.98
## BSDGEDUPn      32.15       1.48   21.72
## BCDG03n         2.68       2.17    1.23
## R-squared       0.15       0.01   14.06
## 
## $Chile
##             Estimate Std. Error t value
## (Intercept)   330.51       8.94   36.97
## BSDGEDUPn      16.21       2.75    5.89
## BCDG03n        26.78       5.73    4.67
## R-squared       0.17       0.03    5.63

Regression results can be plotted with plot(myreg)

A plot of selected effects can be produced with plot(myreg, vars=c("BSDGEDUPn", "BCDG03n"))

The association with parental education and the school SES appears to be positive.

str(myreg) stores regression output, including residuals, replicate estimates, variance within and between, as well as the regression table reported by myreg.

Replicate estimates of BSDGEDUPn by education system can be retrieved with

library('reshape2')
mydata <- melt(lapply(myreg, function(x) x$replicates[2, ]))

A plot of the distribution of BSDGEDUPn replicate estimates is produced with

library(ggplot2)
ggplot(mydata, aes(x=value)) + geom_density() + facet_wrap(~ L1)