lsa.corr {RALSA} | R Documentation |
Compute correlations between variables within specified groups
Description
lsa.corr
computes correlation coefficients between variables within groups defined by one or more variables.
Usage
lsa.corr(
data.file,
data.object,
split.vars,
bckg.corr.vars,
PV.root.corr,
corr.type,
weight.var,
include.missing = FALSE,
shortcut = FALSE,
save.output = TRUE,
output.file,
open.output = TRUE
)
Arguments
data.file |
The file containing |
data.object |
The object in the memory containing |
split.vars |
Categorical variable(s) to split the results by. If no split variables are provided, the results will be for the overall countries' populations. If one or more variables are provided, the results will be split by all but the last variable and the percentages of respondents will be computed by the unique values of the last splitting variable. |
bckg.corr.vars |
Names of continuous background or contextual variables to compute the correlation coefficients for. The results will be computed by all groups specified by the splitting variables. See details. |
PV.root.corr |
The root names for the sets of plausible values to compute the correlation coefficients for. See details. |
corr.type |
String of length one, specifying the type of the correlations to compute,
either |
weight.var |
The name of the variable containing the weights. If no name of a weight variable is provide, the function will automatically select the default weight variable for the provided data, depending on the respondent type. |
include.missing |
Logical, shall the missing values of the splitting variables be included
as categories to split by and all statistics produced for them? The
default ( |
shortcut |
Logical, shall the "shortcut" method for IEA TIMSS, TIMSS Advanced,
TIMSS Numeracy, eTIMSS PSI, PIRLS, ePIRLS, PIRLS Literacy and RLII be
applied? The default ( |
save.output |
Logical, shall the output be saved in MS Excel file (default) or not (printed to the console or assigned to an object). |
output.file |
If |
open.output |
Logical, shall the output be open after it has been written? The default
( |
Details
Either data.file
or data.object
shall be provided as source of data. If both of them are provided, the function will stop with an error message.
The function computes correlation coefficients by the categories of the splitting variables. The percentages of respondents in each group are computed within the groups specified by the last splitting variable. If no splitting variables are added, the results will be computed only by country.
Multiple continuous background variables and/or sets of plausible values can be provided to compute correlation coefficients for. Please note that in this case the results will slightly differ compared to using each pair of the same background continuous variables or PVs in separate analysis. This is because the cases with the missing values are removed in advance and the more variables are provided to compute correlations for, the more cases are likely to be removed. That is, the function support only listwisie deletion.
Computation of correlation coefficients involving plausible values requires providing a root of the plausible values names in PV.root.corr
. All studies (except CivED, TEDS-M, SITES, TALIS and TALIS Starting Strong Survey) have a set of PVs per construct (e.g. in TIMSS five for overall mathematics, five for algebra, five for geometry, etc.). In some studies (say TIMSS and PIRLS) the names of the PVs in a set always start with character string and end with sequential number of the PV. For example, the names of the set of PVs for overall mathematics in TIMSS are BSMMAT01, BSMMAT02, BSMMAT03, BSMMAT04 and BSMMAT05. The root of the PVs for this set to be added to PV.root.corr
will be "BSMMAT". The function will automatically find all the variables in this set of PVs and include them in the analysis. In other studies like OECD PISA and IEA ICCS and ICILS the sequential number of each PV is included in the middle of the name. For example, in ICCS the names of the set of PVs are PV1CIV, PV2CIV, PV3CIV, PV4CIV and PV5CIV. The root PV name has to be specified in PV.root.corr
as "PV#CIV". More than one set of PVs can be added. Note, however, that providing multiple continuous variables for the bckg.avg.corr
argument and multiple PV roots for the PV.root.corr
argument will affect the results for the correlation coefficients for the PVs because the cases with missing on bckg.corr.vars
will be removed and this will also affect the results from the PVs (i.e. listwise deletion). On the other hand, using only sets of PVs to correlate should not affect the results on any PV estimates because PVs shall not have any missing values.
A sufficient number of variable names (background/contextual) or PV roots have to be provided - either two background variables, or two PV roots, or mixture of them with total length of two (i.e. one background/contextual variable and one PV root).
If include.missing = FALSE
(default), all cases with missing values on the splitting variables will be removed and only cases with valid values will be retained in the statistics. Note that the data from the studies can be exported in two different ways: (1) setting all user-defined missing values to NA
; and (2) importing all user-defined missing values as valid ones and adding their codes in an additional attribute to each variable. If the include.missing
is set to FALSE
(default) and the data used is exported using option (2), the output will remove all values from the variable matching the values in its missings
attribute. Otherwise, it will include them as valid values and compute statistics for them.
The shortcut
argument is valid only for TIMSS, eTIMSS PSI, TIMSS Advanced, TIMSS Numeracy, PIRLS, ePIRLS, PIRLS Literacy and RLII. Previously, in computing the standard errors, these studies were using 75 replicates because one of the schools in the 75 JK zones had its weights doubled and the other one has been taken out. Since TIMSS 2015 and PIRLS 2016 the studies use 150 replicates and in each JK zone once a school has its weights doubled and once taken out, i.e. the computations are done twice for each zone. For more details see Foy & LaRoche (2016) and Foy & LaRoche (2017). If replication of the tables and figures is needed, the shortcut
argument has to be changed to TRUE
.
The function provides two-tailed t-test and p-values for the correlation coefficients.
Value
If save.output = FALSE
, a list containing the estimates and analysis information. If save.output = TRUE
(default), an MS Excel (.xlsx
) file (which can be opened in any spreadsheet program), as specified with the full path in the output.file
. If the argument is missing, an Excel file with the generic file name "Analysis.xlsx" will be saved in the working directory (getwd()
). The workbook contains three spreadsheets. The first one ("Estimates") contains a table with the results by country and the final part of the table contains averaged results from all countries' statistics. The results are presented as a correlation matrices by the splitting variables. The following columns can be found in the table, depending on the specification of the analysis:
-
<
Country ID>
- a column containing the names of the countries in the file for which statistics are computed. The exact column header will depend on the country identifier used in the particular study. -
<
Split variable 1>
,<
Split variable 2>
... - columns containing the categories by which the statistics were split by. The exact names will depend on the variables insplit.vars
. n_Cases - the number of cases in the sample used to compute the statistics.
Sum_
<
Weight variable>
- the estimated population number of elements per group after applying the weights. The actual name of the weight variable will depend on the weight variable used in the analysis.Sum_
<
Weight variable>
_
SE - the standard error of the the estimated population number of elements per group. The actual name of the weight variable will depend on the weight variable used in the analysis.Percentages_
<
Last split variable>
- the percentages of respondents (population estimates) per groups defined by the splitting variables insplit.vars
. The percentages will be for the last splitting variable which defines the final groups.Percentages_
<
Last split variable>
_
SE - the standard errors of the percentages from above.Variable - the variable names (background/contextual or PV root names) to be matched against the rows of the following columns, forming the correlation matrices together.
Correlation_
<
Background variable>
- the correlation coefficient of each continuous<
Background variable>
specified inbckg.corr.vars
against itself and each of the variables in the column "Variable". There will be one column with correlation coefficient estimate for each variable specified inbckg.corr.vars
and/or set of PVs specified inPV.root.corr
.Correlation_
<
Background variable>
_
SE - the standard error of the correlation of each continuous<
Background variable>
specified inbckg.corr.vars
. There will be one column with the SE of the correlation coefficient estimate for each variable specified inbckg.corr.vars
and/or set of PVs specified inPV.root.corr
.Correlation_
<
root PV>
- the correlation coefficient of each set of PVs specified as PV root name inPV.root.corr
against itself and each of the variables in the column "Variable". There will be one column with correlation coefficient estimate for each set of PVs specified inPV.root.corr
and each other set of PVs specified inPV.root.corr
and/or each continuous background variable specified inbckg.corr.vars
.Correlation_
<
root PV>
_
SE - the standard error of the correlation of each set of PVs specified as PV root name inPV.root.corr
. There will be one column with the SE of the correlation coefficient estimate for each set of root PVs specified inPV.root.corr
and another set of PVs specified inPV.root.corr
and/or each continuous background variable specified inbckg.corr.vars
.Correlation_
<
root PV>
_
SVR - the sampling variance component for the correlation of the PVs with the same<
root PV>
specified inPV.root.corr
. There will be one column with the sampling variance component for the correlation coefficient estimate for each set of PVs specified inPV.root.corr
with the other variables (other sets of PVs or background/contextual variables).Mean_
<
root PV>
_
MVR - the measurement variance component for the correlation of the PVs with the same<
root PV>
specified inPV.root.corr
. There will be one column with the measurement variance component for the correlation coefficient estimate for each set of PVs specified inPV.root.corr
with the other variables (other sets of PVs or background/contextual variables).Correlation_
<
Background variable>
_
SVR - the sampling variance component for the correlation of the particular background variable with a set of PVs specified inPV.root.corr
it is correlated with. There will be one column with the sampling variance component for the average estimate for each background/contextual variable correlated with a set of PVs specified inPV.root.corr
.Correlation_
<
Background variable>
_
MVR - the measurement variance component for the correlation of the particular background variable PVs with a set of PVs specified inPV.root.corr
. There will be one column with the measurement variance component for the correlation coefficient estimate for each background/contextual variable correlated with a set of PVs specified inPV.root.corr
.t_
<
root PV>
- the t-test value for the correlation coefficients of a set of PVs when correlating them with other variables (background/contextual or other sets of PVs).t_
<
Background variable>
- the t-test value for the correlation coefficients of background variables when correlating them with other variables (background/contextual or other sets of PVs).p_
<
root PV>
- the p-value for the correlation coefficients of a set of PVs when correlating them with other variables (background/contextual or other sets of PVs).p_
<
Background variable>
- the p-value value for the correlation coefficients of background variables when correlating them with other variables (background/contextual or other sets of PVs).
The second sheet contains some additional information related to the analysis per country in columns:
DATA - used
data.file
ordata.object
.STUDY - which study the data comes from.
CYCLE - which cycle of the study the data comes from.
WEIGHT - which weight variable was used.
DESIGN - which resampling technique was used (JRR or BRR).
SHORTCUT - logical, whether the shortcut method was used.
NREPS - how many replication weights were used.
ANALYSIS_DATE - on which date the analysis was performed.
START_TIME - at what time the analysis started.
END_TIME - at what time the analysis finished.
DURATION - how long the analysis took in hours, minutes, seconds and milliseconds.
The third sheet contains the call to the function with values for all parameters as it was executed. This is useful if the analysis needs to be replicated later.
References
LaRoche, S., Joncas, M., & Foy, P. (2016). Sample Design in TIMSS 2015. In M. O. Martin, I. V. S. Mullis, & M. Hooper (Eds.), Methods and Procedures in TIMSS 2015 (pp. 3.1-3.37). Chestnut Hill, MA: TIMSS & PIRLS International Study Center.
LaRoche, S., Joncas, M., & Foy, P. (2017). Sample Design in PIRLS 2016. In M. O. Martin, I. V. S. Mullis, & M. Hooper (Eds.), Methods and Procedures in PIRLS 2016 (pp. 3.1-3.34). Chestnut Hill, MA: Lynch School of Education, Boston College.
See Also
Examples
# Compute correlations between the complex student background scales
# "Home Educational Resources/SCL", "Students Sense of School Belonging/SCL" and
# "Students Value Mathematics/SCL" by sex of students in TIMSS 2015 grade 8
# using data file, omit missing from the splitting variable (female and male
# as answered by the students), without shortcut, and open the output after the
# computations are done
## Not run:
lsa.corr(data.file = "C:/Data/TIMSS_2015_G8_Student_Miss_to_NA.RData", split.vars = "BSBG01",
bckg.corr.vars = c("BSBGHER", "BSBGSSB", "BSBGSVM"), include.missing = FALSE,
output.file = "C:/temp/test.xlsx", open.output = TRUE)
## End(Not run)
# Compute correlations between the complex student background scales
# "Home Educational Resources/SCL" and "Students Sense of School Belonging/SCL"
# and the plausible values in overall mathematics and overall science by student
# sex and frequency of using computer or tablet at home using TIMSS 2015 grade 8
# data loaded in memory, using the shortcut, include the missing values in the
# splitting variables, and use the senate weights
## Not run:
lsa.corr(data.object = T15_G8_student_data, split.vars = c("BSBG01", "BSBG13A"),
bckg.corr.vars = c("BSBGHER", "BSBGSSB"), PV.root.corr = c("BSMMAT", "BSSSCI"),
weight.var = "SENWGT", include.missing = FALSE, shortcut = TRUE,
output.file = "C:/temp/test.xlsx", open.output = TRUE)
## End(Not run)
# Compute the correlations between student overall reading achievement, overall mathematics
# scores (i.e. using a set of PVs) and student family wealth, using PISA 2018 student data
# loaded as object in the memory, by country, and do not open the output after the computations
# are finished
## Not run:
lsa.corr(data.object = CY07_MSU_STU_QQQ, bckg.corr.vars = "WEALTH",
PV.root.corr = c("PV#MATH", "PV#READ"), include.missing = TRUE,
output.file = "C:/temp/test.xlsx", open.output = FALSE)
## End(Not run)