Description Usage Arguments Details Value Author(s) See Also Examples
Computes the correlation of two variables on an edsurvey.data.frame
,
a light.edsurvey.data.frame
, or an edsurvey.data.frame.list
.
The correlation accounts for plausible values and the survey design.
1 2 3 4 
x 
a character variable name from the 
y 
a character variable name from the 
data 
an 
method 
a character string indicating which correlation coefficient (or covariance) is to be computed.
One of 
weightVar 
character indicating the weight variable to use. See Details. 
reorder 
a list of variables to reorder. Defaults to 
omittedLevels 
a logical value. When set to the default value of 
defaultConditions 
a logical value. When set to the default value of 
recode 
a list of lists to recode variables. Defaults to 
condenseLevels 
a logical value. When set to the default value of

Note that the getData
arguments and recode.sdf
may be useful. (See Examples.)
The correlation methods are calculated as described in the documentation for the wCorr
package—see browseVignettes(package="wCorr")
.
An edsurvey.cor
that has print and summary methods.
The class includes the following elements:

numeric estimated correlation coefficient 

standard error of the correlation ( 

a vector of length two showing the columns for which the correlation coefficient was calculated 



a list that shows the order of each variable 

the type of correlation estimated 

the jackknife component of the variance estimate. For Pearson, in the atanh space. 

the imputation component of the variance estimate. For Pearson, in the atanh space. 

the weight variable used 

the number of plausible values used 

the number of the jackknife replicates used 
Paul Bailey; relies heavily on the wCorr
package, written by Ahmad Emad and Paul Bailey
cor
and weightedCorr
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67  ## Not run:
# read in the example data (generated, not real student data)
sdf < readNAEP(system.file("extdata/data", "M36NT2PM.dat", package = "NAEPprimer"))
# for two categorical variables any of the following work
c1_pears < cor.sdf(x="b017451", y="b003501", data=sdf, method="Pearson",
weightVar="origwt")
c1_spear < cor.sdf(x="b017451", y="b003501", data=sdf, method="Spearman",
weightVar="origwt")
c1_polyc < cor.sdf(x="b017451", y="b003501", data=sdf, method="Polychoric",
weightVar="origwt")
c1_pears
c1_spear
c1_polyc
# for categorical variables, users can either keep the original numeric levels of the variables
# or condense the levels (default)
# The following call condenses the levels of the variable 'c046501'
cor.sdf(x="c046501", y="c044006", data=sdf)
# The following call keeps the original levels of the variable 'c046501'
cor.sdf(x="c046501", y="c044006", data=sdf, condenseLevels = FALSE)
# these take awhile to calculate for large datasets, so limit to a subset
sdf_dnf < subset(sdf, b003601 == 1)
# for a categorical variable and a scale score any of the following work
c2_pears < cor.sdf(x="composite", y="b017451", data=sdf_dnf, method="Pearson",
weightVar="origwt")
c2_spear < cor.sdf(x="composite", y="b017451", data=sdf_dnf, method="Spearman",
weightVar="origwt")
c2_polys < cor.sdf(x="composite", y="b017451", data=sdf_dnf, method="Polyserial",
weightVar="origwt")
c2_pears
c2_spear
c2_polys
# recode two variables
cor.sdf(x="c046501", y="c044006", data=sdf, method="Spearman", weightVar="origwt",
recode=list(c046501=list(from="0%",to="None"),
c046501=list(from=c("15%", "610%", "1125%", "2650%",
"5175%", "7690%", "Over 90%"),
to="Between 0% and 100%"),
c044006=list(from=c("15%", "610%", "1125%", "2650%",
"5175%", "7690%", "Over 90%"),
to="Between 0% and 100%")))
# reorder two variables
cor.sdf(x="b017451", y="sdracem", data=sdf, method="Spearman", weightVar="origwt",
reorder=list(sdracem=c("White", "Hispanic", "Black", "Asian/Pacific Island",
"Amer Ind/Alaska Natv", "Other"),
b017451=c("Every day", "2 or 3 times a week", "About once a week",
"Once every few weeks", "Never or hardly ever")))
# recode two variables and reorder
cor.sdf(x="pared", y="b013801", data=subset(sdf, !pared %in% "I Don\'t Know"),
method="Spearman", weightVar = "origwt",
recode=list(pared=list(from="Some ed after H.S.", to="Graduated H.S."),
pared=list(from="Graduated college", to="Graduated H.S."),
b013801=list(from="010", to="Less than 100"),
b013801=list(from="1125", to="Less than 100"),
b013801=list(from="26100", to="Less than 100")),
reorder=list(b013801=c("Less than 100", ">100")))
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.