# man/examples/DoFCorrection.R In EdSurvey: Analysis of NCES Education Survey and Assessment Data

```sdf <- readNAEP(system.file("extdata/data", "M36NT2PM.dat", package="NAEPprimer"))
lm1 <- lm.sdf(composite ~ dsex + b017451, sdf, returnVarEstInputs=TRUE)
summary(lm1)
# this output agrees with summary of lm1 coefficient for dsex
DoFCorrection(lm1\$varEstInputs,
varA="dsexFemale",
method="JR")
# second example, a covariance term requires more work
# first, estimate the covariance between two regression coefficients
# note that the variable names are parallel to what they are called in lm1 output
covFEveryDay <- varEstToCov(lm1\$varEstInputs,
varA="dsexFemale",
varB="b017451Every day",
jkSumMultiplier=EdSurvey:::getAttributes(sdf, "jkSumMultiplier"))
# second, find the difference and the SE of the difference
se <- lm1\$coefmat["dsexFemale","se"] + lm1\$coefmat["b017451Every day","se"] +
-2*covFEveryDay
# third, calculate the t-statistic
tv <- (coef(lm1)["dsexFemale"] - coef(lm1)["b017451Every day"])/se
# fourth, calculate the p-value, which requires the estimated degrees of freedom
dofFEveryDay <- DoFCorrection(lm1\$varEstInputs,
varA="dsexFemale",
varB="b017451Every day",
method="JR")
# finally, the p-value
2*(1-pt(abs(tv), df=dofFEveryDay))
```

## Try the EdSurvey package in your browser

Any scripts or data that you put into this service are public.

EdSurvey documentation built on May 2, 2019, 7:30 a.m.