Description Usage Arguments Value Author(s) See Also Examples
wtd.t.test
produces either one- or two-sample t-tests comparing weighted data streams to one another. Note that weights run with the default parameters here treat the weights as an estimate of the precision of the information. For survey data, users should run this code with bootstrapped standard errors bootse=TRUE
, which are robust to heteroskadesticity, although these will vary slightly each time the weights are run. A prior version of this software was set to default to mean1=FALSE
and bootse=FALSE
.
1 2 3 |
x |
|
y |
|
weight |
|
weighty |
|
samedata |
|
alternative |
|
mean1 |
|
bootse |
|
bootp |
|
bootn |
|
drops |
|
A list element with an identifier for the test; coefficients for the t value, degrees of freedom, and p value of the t-test; and additional statistics of potential interest.
Josh Pasek, Assistant Professor of Communication Studies at the University of Michigan (www.joshpasek.com). Gene Culter added code for a one-tailed version of the test.
1 2 3 4 5 6 7 | test <- c(1,1,1,1,1,1,2,2,2,3,3,3,4,4)
t2 <- rev(test)+1
weight <- c(.5,.5,.5,.5,.5,1,1,1,1,2,2,2,2,2)
wtd.t.test(test, t2)
wtd.t.test(test, t2, weight)
wtd.t.test(test, t2, weight, bootse=TRUE)
|
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2
Attaching package: 'Hmisc'
The following objects are masked from 'package:base':
format.pval, units
Loading required package: gdata
sh: 1: cannot create /dev/null: Permission denied
gdata: Unable to locate valid perl interpreter
gdata:
gdata: read.xls() will be unable to read Excel XLS and XLSX files
gdata: unless the 'perl=' argument is used to specify the location of a
gdata: valid perl intrpreter.
gdata:
gdata: (To avoid display of this message in the future, please ensure
gdata: perl is installed and available on the executable search path.)
sh: 1: cannot create /dev/null: Permission denied
gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLX' (Excel 97-2004) files.
gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLSX' (Excel 2007+) files.
gdata: Run the function 'installXLSXsupport()'
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.
Attaching package: 'gdata'
The following object is masked from 'package:stats':
nobs
The following object is masked from 'package:utils':
object.size
The following object is masked from 'package:base':
startsWith
Loading required package: mice
Attaching package: 'mice'
The following objects are masked from 'package:base':
cbind, rbind
$test
[1] "Two Sample Weighted T-Test (Welch)"
$coefficients
t.value df p.value
-2.3185184 26.0000000 0.0285483
$additional
Difference Mean.x Mean.y Std. Err
-1.0000000 2.0714286 3.0714286 0.4313099
$test
[1] "Two Sample Weighted T-Test (Welch)"
$coefficients
t.value df p.value
0.2357023 25.1885350 0.8155696
$additional
Difference Mean.x Mean.y Std. Err
0.09090909 2.63636364 2.54545455 0.38569461
$test
[1] "Two Sample Weighted T-Test (Welch)"
$coefficients
t.value df p.value
0.2538813 25.1885350 0.8016482
$additional
Difference Mean.x Mean.y Std. Err
0.09090909 2.63636364 2.54545455 0.35807711
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.