• Analyze Survey Data for Free
  • archived asdfree.com website
  • archived github repository
  • Step by Step Instructions to Explore Public Microdata from an Easy to Type Website
  • Prerequisites
  • The Census of 82 Countries Made Laptop-Friendly
  • Maps and the Art of Survey-Weighted Maintenance
  • Statistically Significant Trends with Multiple Years of Complex Survey Data
    • Data Importation
    • Load Required Packages, Options, External Functions
    • Harmonize and Stack Multiple Years of Survey Data
    • Construct a Multi-Year Stacked Complex Survey Design Object
    • Review the unadjusted results
    • Calculate the Number of Joinpoints Needed
    • Calculate the Adjusted Prevalence and Predicted Marginals
    • Identify the Breakpoint/Changepoint
    • Make statistically defensible statements about linear trends with complex survey data
  • Structural Equation Models (SEM) with Complex Survey Data
    • Load the 2008 Wave of the European Social Survey German and Spanish Microdata
    • Two-factor CFA of attitudes toward the welfare state
    • Invariance testing on Schwarz human values while accounting for the survey design.
    • An example with a Latent Variable Regression
  • Balancing Respondent Confidentiality with Variance Estimation Precision
  • American Community Survey (ACS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • National Longitudinal Study of Adolescent to Adult Health (ADDHEALTH)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Area Health Resource File (AHRF)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • American Housing Survey (AHS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • American National Election Study (ANES)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • American Time Use Survey (ATUS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Behavioral Risk Factor Surveillance System (BRFSS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • Basic Stand Alone Public Use File (BSAPUF)
    • Simplified Download and Importation
    • Analysis Examples with SQL and RSQLite  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • Brazilian Censo Demografico (CENSO)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • Consumer Expenditure Survey (CES)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • California Health Interview Survey (CHIS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Current Population Survey - Annual Social and Economic Supplement (CPSASEC)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • Current Population Survey - Basic Monthly (CPSBASIC)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Demographic and Health Surveys (DHS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Exame Nacional de Desempenho de Estudantes (ENADE)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • Exame Nacional do Ensino Medio (ENEM)
    • Simplified Download and Importation
    • Analysis Examples with SQL and RSQLite  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
    • Replication Example
  • European Social Survey (ESS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • FDA Adverse Event Reporting System (FAERS)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • General Social Survey (GSS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
  • Home Mortgage Disclosure Act (HMDA)
    • Simplified Download and Importation
    • Analysis Examples with SQL and RSQLite  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
    • Replication Example
  • Health and Retirement Study (HRS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Medical Expenditure Panel Survey (MEPS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Medical Large Claims Experience Study (MLCES)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • National Beneficiary Survey (NBS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Youth Risk Behavior Surveillance System (NCVS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Health and Nutrition Examination Survey (NHANES)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Health Interview Survey (NHIS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • Pesquisa Nacional por Amostra de Domicilios (NHTS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • National Immunization Survey (NIS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Longitudinal Surveys (NLS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
  • National Plan and Provider Enumeration System (NPPES)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • National Survey of OAA Participants (NPS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Survey of Children’s Health (NSCH)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • National Study on Drug Use and Health (NSDUH)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Survey of Family Growth (NSFG)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Plan and Provider Enumeration System (NVSS)
    • Simplified Download and Importation
    • Analysis Examples with SQL and RSQLite  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
    • Replication Example
  • New York City Housing and Vacancy Survey (NYCHVS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Pew Research Center (PEW)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Programme for the International Assessment of Adult Competencies (PIAAC)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • Progress in International Reading Literacy Study (PIRLS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • Program for International Student Assessment (PISA)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • Public Libraries Survey (PLS)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • Pesquisa Mensal de Emprego (PME)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Pesquisa Nacional por Amostra de Domicilios (PNAD)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • Pesquisa Nacional por Amostra de Domicilios - Continua (PNADC)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • Pesquisa Nacional de Saude (PNS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Pesquisa de Orcamentos Familiares (POF)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Panel Study of Income Dynamics (PSID)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • National Plan and Provider Enumeration System (SAEB)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
    • Replication Example
  • Survey of Business Owners (SBO)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • Survey of Consumer Finances (SCF)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • Surveillance Epidemiology and End Results (SEER)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • Survey of Health, Ageing and Retirement in Europe (SHARE)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Pesquisa Nacional por Amostra de Domicilios (SIPP)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • Social Security Administration Public Use Microdata (SSA)
    • Simplified Download and Importation
    • Analysis Examples with base R  
      • Variable Recoding
      • Unweighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with dplyr  
  • Trends in International Mathematics and Science Study (TIMSS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Replication Example
  • United States Decennial Census Public Use Microdata Sample (USPUMS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Poverty and Inequality Estimation with convey  
    • Replication Example
  • World Values Survey (WVS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Youth Risk Behavior Surveillance System (YRBSS)
    • Simplified Download and Importation
    • Analysis Examples with the survey library  
      • Variable Recoding
      • Unweighted Counts
      • Weighted Counts
      • Descriptive Statistics
      • Subsetting
      • Measures of Uncertainty
      • Regression Models and Tests of Association
    • Analysis Examples with srvyr  
    • Replication Example
  • Published with bookdown

Analyze Survey Data for Free

Trends in International Mathematics and Science Study (TIMSS)

Build Status Build status

The Trends in International Mathematics and Science Study (TIMSS) tracks the math and science competency of fourth graders across about fifty nations.

  • A series of tables with one record per school (ACG), per student (ASG), per teacher (ATG), as well as files containing student achievement (ASA), home background (ASH), student-teacher linkage (AST), and within-country scoring reliability (ASR).

  • A complex sample survey designed to generalize to the fourth-grade student population of participating countries.

  • Released quadrennially since 1995.

  • Funded by the International Association for the Evaluation of Educational Achievement and compiled by the Lynch School of Education at Boston College.

Simplified Download and Importation

The R lodown package easily downloads and imports all available TIMSS microdata by simply specifying "timss" with an output_dir = parameter in the lodown() function. Depending on your internet connection and computer processing speed, you might prefer to run this step overnight.

library(lodown)
lodown( "timss" , output_dir = file.path( path.expand( "~" ) , "TIMSS" ) )

lodown also provides a catalog of available microdata extracts with the get_catalog() function. After requesting the TIMSS catalog, you could pass a subsetted catalog through the lodown() function in order to download and import specific extracts (rather than all available extracts).

library(lodown)
# examine all available TIMSS microdata files
timss_cat <-
    get_catalog( "timss" ,
        output_dir = file.path( path.expand( "~" ) , "TIMSS" ) )

# 2015 only
timss_cat <- subset( timss_cat , year == 2015 )
# download the microdata to your local computer
timss_cat <- lodown( "timss" , timss_cat )

Analysis Examples with the survey library  

Construct a multiply-imputed, complex sample survey design:

library(survey)
library(mitools)
library(RSQLite)

# load the ASG (student background) + ASH (home background) merged design
timss_design <- readRDS( file.path( path.expand( "~" ) , "TIMSS" , "2015/asg_design.rds" ) )

design_weights <- readRDS( file.path( path.expand( "~" ) , "TIMSS" , "2015/asg_weights.rds" ) )

five_tablenames <- paste0( "asg_2015_" , 1:5 )

timss_design <- lodown:::svyMDBdesign( timss_design )

Variable Recoding

Add new columns to the data set:

timss_design <- 
    update( 
        timss_design , 
        
        one = 1 ,
        
        idcntry = factor( idcntry ) ,
        
        sex = factor( itsex , labels = c( "male" , "female" ) ) ,
        
        born_2005_or_later = as.numeric( itbirthy >= 2005 )

    )

Unweighted Counts

Count the unweighted number of records in the survey sample, overall and by groups:

MIcombine( with( timss_design , svyby( ~ one , ~ one , unwtd.count ) ) )

MIcombine( with( timss_design , svyby( ~ one , ~ sex , unwtd.count ) ) )

Weighted Counts

Count the weighted size of the generalizable population, overall and by groups:

MIcombine( with( timss_design , svytotal( ~ one ) ) )

MIcombine( with( timss_design ,
    svyby( ~ one , ~ sex , svytotal )
) )

Descriptive Statistics

Calculate the mean (average) of a linear variable, overall and by groups:

MIcombine( with( timss_design , svymean( ~ asmmat ) ) )

MIcombine( with( timss_design ,
    svyby( ~ asmmat , ~ sex , svymean )
) )

Calculate the distribution of a categorical variable, overall and by groups:

MIcombine( with( timss_design , svymean( ~ idcntry ) ) )

MIcombine( with( timss_design ,
    svyby( ~ idcntry , ~ sex , svymean )
) )

Calculate the sum of a linear variable, overall and by groups:

MIcombine( with( timss_design , svytotal( ~ asmmat ) ) )

MIcombine( with( timss_design ,
    svyby( ~ asmmat , ~ sex , svytotal )
) )

Calculate the weighted sum of a categorical variable, overall and by groups:

MIcombine( with( timss_design , svytotal( ~ idcntry ) ) )

MIcombine( with( timss_design ,
    svyby( ~ idcntry , ~ sex , svytotal )
) )

Calculate the median (50th percentile) of a linear variable, overall and by groups:

MIcombine( with( timss_design ,
    svyquantile(
        ~ asmmat ,
        0.5 , se = TRUE 
) ) )

MIcombine( with( timss_design ,
    svyby(
        ~ asmmat , ~ sex , svyquantile ,
        0.5 , se = TRUE ,
        keep.var = TRUE , ci = TRUE 
) ) )

Estimate a ratio:

MIcombine( with( timss_design ,
    svyratio( numerator = ~ asssci , denominator = ~ asmmat )
) )

Subsetting

Restrict the survey design to Australia, Austria, Azerbaijan, Belgium (French):

sub_timss_design <- subset( timss_design , idcntry %in% c( 36 , 40 , 31 , 957 ) )

Calculate the mean (average) of this subset:

MIcombine( with( sub_timss_design , svymean( ~ asmmat ) ) )

Measures of Uncertainty

Extract the coefficient, standard error, confidence interval, and coefficient of variation from any descriptive statistics function result, overall and by groups:

this_result <-
    MIcombine( with( timss_design ,
        svymean( ~ asmmat )
    ) )

coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )

grouped_result <-
    MIcombine( with( timss_design ,
        svyby( ~ asmmat , ~ sex , svymean )
    ) )

coef( grouped_result )
SE( grouped_result )
confint( grouped_result )
cv( grouped_result )

Calculate the degrees of freedom of any survey design object:

degf( timss_design$designs[[1]] )

Calculate the complex sample survey-adjusted variance of any statistic:

MIcombine( with( timss_design , svyvar( ~ asmmat ) ) )

Include the complex sample design effect in the result for a specific statistic:

# SRS without replacement
MIcombine( with( timss_design ,
    svymean( ~ asmmat , deff = TRUE )
) )

# SRS with replacement
MIcombine( with( timss_design ,
    svymean( ~ asmmat , deff = "replace" )
) )

Compute confidence intervals for proportions using methods that may be more accurate near 0 and 1. See ?svyciprop for alternatives:

MIsvyciprop( ~ born_2001_or_later , timss_design ,
    method = "likelihood" , na.rm = TRUE )

Regression Models and Tests of Association

Perform a design-based t-test:

MIsvyttest( asmmat ~ born_2001_or_later , timss_design )

Perform a chi-squared test of association for survey data:

MIsvychisq( ~ born_2001_or_later + idcntry , timss_design )

Perform a survey-weighted generalized linear model:

glm_result <- 
    MIcombine( with( timss_design ,
        svyglm( asmmat ~ born_2001_or_later + idcntry )
    ) )
    
summary( glm_result )

Replication Example