I just looked more carefully at your code.

You are computing the unequal-variance (Welch) version of the t-test, so
that's why there isn't a problem.  Compare it with the equal-variance
t-test, using the pooled variance estimate, which does have a problem, as
below

    -thomas

tstat4 <- function() {

    n1 = 7

    mu1 = 100

    sigma1 = 25

    n2 = 14

    mu2 = 100

    sigma2 = 10

    x1 = rnorm(n1, mu1, sigma1)

    x1bar = mean(x1)

    s1 = sd(x1)

    x2 = rnorm(n2, mu2, sigma2)

    x2bar = mean(x2)

    s2 = sd(x2)

    t = ((x1bar - x2bar) - (mu1 - mu2))/sqrt(s1^2/n1 + s2^2/n2)

    t2= ((x1bar - x2bar) - (mu1 - mu2))/sqrt(((n1-1)*s1^2 + (n2-1)*s2^2)/(n1
+n2-2)*(1/n1+1/n2))

    return(c(t,t2))

}


tstats4 = replicate(10000, tstat4())


hist(tstats4[1,], breaks = "scott", prob = TRUE, xlim = c(-4, 4), ylim = c(0
, 0.4))

x = seq(-4, 4, length = 200)

y = dt(x, df = 48)

lines(x, y, type = "l", col = "red")


hist(tstats4[2,], breaks = "scott", prob = TRUE, xlim = c(-4, 4), ylim = c(0
, 0.4))

x = seq(-4, 4, length = 200)

y = dt(x, df = 48)

lines(x, y, type = "l", col = "red")


On Thu, Apr 18, 2013 at 12:28 PM, David Arnold <dwarnol...@suddenlink.net>wrote:

> OK,although the variance ratio was already 2.25 to 1,  tried sigma1=10,
> sigma2=25, which makes the ratios of the variances 6.25 to 1.
>
> Still no change. See:
>
> http://msemac.redwoods.edu/~darnold/math15/R/chapter11/DistributionForTwoIndependentSamplesPartII.html
>
> D.
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/t-statistic-for-independent-samples-tp4664553p4664556.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to