From: David Winsemius <dwinsemius_at_comcast.net>

Date: Tue, 24 May 2011 10:51:22 -0400

Date: Tue, 24 May 2011 10:51:22 -0400

On May 24, 2011, at 8:44 AM, stocdarf_at_mail.tu-berlin.de wrote:

> Dear R-User,

*>
**> I'm trying to visualize the results of the power calculation with
**> the function power.t.test(). Therefore I want to plot the related t-
**> distributions and shade the surfaces indicatingt the type I error,
**> the type II error and the power. For sample sizes greater 30 I got
**> results which are very satisfying. For small sample sizes I got
**> stuck and did'nt find a mistake.
**> To show you the problem I wrote some lines in R:
**>
**> par(mfrow = c(4,2))
**> for(n in c(2,6,10,14,18,22,26,30))
**> {
**> temp = power.t.test(n = n, sd = 1, power = 0.5, sig.level =
**> 0.05, # power
**> calculation --> power is specified with 50%
**> type = "one.sample", alternative = "one.sided")
**> s = temp
**> $
**> sd
**> # get
**> standard deviation out of test distribution
**> n = temp
**> $
**> n
**> # get
**> sample size out of test distribution
**> delta = temp
**> $
**> delta
**> # get
**> delta (distance between centrality points) out of test ditribution
**>
**> plot(1:10, xlim = c(-5,10), ylim = c(0, 0.5), type =
**> "n")
**> # create plot window
**>
**> x = seq(-5, 10, length =
**> 400
**> ) # x
**> -values
**> y1 = dt(x, df =
**> n
**> -1
**> ) # y
**> -values calculated with related t-distribution (df=n-1)
**>
**> lines(x, y1, col =
**> 2
**> ) # plot
**> related t-distribution
**> lines(x + delta/(s/sqrt(n)),
**> y1
**> ) # plot
**> related t-distribution shifted with normalized delta
**>
**> abline(v = qt(0.95, df =
**> n
**> -1
**> )) # draws
**> a vertical line at the
**> abline(v=delta/(s/sqrt(n)),lty=2)
**>
**> legend("topright",legend=c(paste("n=",n),
**> paste("bias=",round(qt(0.95, df = n-1)-delta/(s/sqrt(n)),
**> 2)))) # creates legend
**> }
**>
**> This code creates some plots with different sample size n. I would
**> expect the solid vertical line and the dotted vertical line one
**> above the other. But indeed the space between both of them is
**> increasing with a decreasing sample size.
**> Whe re is my mistake? Is it a error in reasoning or is it "just"
**> not possible to visualize this problem for small sample sizes?
*

You do realize that you should be using the non-central t distribution when considering the alternate hypothesis, right? By the time you get down to sample sizes of 6 there should be a visible skew to the distribution of "observed" differences.

*>
*

> I look foward to any suggestions and hints. So much thanks in advance.

*>
**> Étienne
*

-- David Winsemius, MD West Hartford, CT ______________________________________________ R-help_at_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.Received on Tue 24 May 2011 - 15:17:12 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 24 May 2011 - 15:50:08 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*