svyttest.Rd
One-sample or two-sample t-test. This function is a wrapper for
svymean
in the one-sample case and for
svyglm
in the two-sample case. Degrees of freedom are
degf(design)-1
for the one-sample test and degf(design)-2
for the two-sample case.
svyttest(formula, design, ...)
Formula, outcome~group
for two-sample,
outcome~0
or outcome~1
for one-sample. The group
variable
must be a factor or character with two levels, or be coded 0/1 or 1/2
survey design object
for methods
Object of class htest
data(api)
dclus2<-svydesign(id=~dnum+snum, fpc=~fpc1+fpc2, data=apiclus2)
tt<-svyttest(enroll~comp.imp, dclus2)
tt
#>
#> Design-based t-test
#>
#> data: enroll ~ comp.imp
#> t = -2.8882, df = 36, p-value = 0.006518
#> alternative hypothesis: true difference in mean is not equal to 0
#> 95 percent confidence interval:
#> -384.24757 -67.22654
#> sample estimates:
#> difference in mean
#> -225.7371
#>
confint(tt, level=0.9)
#> [1] -357.68999 -93.78413
#> attr(,"conf.level")
#> [1] 0.9
svyttest(enroll~I(stype=="E"),dclus2)
#>
#> Design-based t-test
#>
#> data: enroll ~ I(stype == "E")
#> t = -9.8291, df = 36, p-value = 9.826e-12
#> alternative hypothesis: true difference in mean is not equal to 0
#> 95 percent confidence interval:
#> -706.306 -464.688
#> sample estimates:
#> difference in mean
#> -585.497
#>
svyttest(I(api00-api99)~0, dclus2)
#>
#> Design-based one-sample t-test
#>
#> data: I(api00 - api99) ~ 0
#> t = 9.0704, df = 38, p-value = 4.782e-11
#> alternative hypothesis: true mean is not equal to 0
#> 95 percent confidence interval:
#> 20.02455 31.53117
#> sample estimates:
#> mean
#> 25.77786
#>