Chapter07_power {DanielBiostatistics10th}R Documentation

Chapter 7: Power Curve

Description

Functions for Chapter 7, Hypothesis Testing.

Usage

power_z(
  x,
  null.value,
  sd,
  n,
  alternative = c("two.sided", "less", "greater"),
  sig.level = 0.05
)

Arguments

x

numeric vector, mean parameter(s) \mu_1 in the alternative hypothesis

null.value

numeric scalar, mean parameter \mu_0 in the null hypothesis

sd

numeric scalar, population standard deviation \sigma

n

integer scalar, sample size n

alternative

character scalar, alternative hypothesis, either 'two.sided' (default), 'greater' or 'less'

sig.level

numeric scalar, significance level (i.e., Type-I-error rate), default .05

Details

Function power_z calculates the powers at each element of the alternative parameters \mu_1, for one-sample z-test

Value

Function power_z returns a 'power_z' object, which inherits from 'power.htest' class.

See Also

power.t.test

Examples

library(DanielBiostatistics10th)

# Example 7.9.1; Page 272 (10th ed), Page 245 (11th ed) 
(p791 = power_z(seq.int(from = 16, to = 19, by = .5), null.value = 17.5, sd = 3.6, n = 100L))
# Table 7.9.1

# Example 7.9.2; Page 276 (10th ed), Page 248 (11th ed) 
(p792 = power_z(seq.int(from = 50, to = 70, by = 5), null.value = 65, sd = 15, n = 20L, 
                sig.level = .01, alternative = 'less'))

# Example 7.10.1; Page 278, 
(n_d7101 <- uniroot(f = function(x) {
  power_z(55, null.value = 65, sd = 15, n = x, sig.level = .01, alternative = 'less')$power - .95
}, interval = c(0, 50))$root)
power_z(55, null.value = 65, sd = 15, n = ceiling(n_d7101), sig.level = .01, alternative = 'less')

[Package DanielBiostatistics10th version 0.2.2 Index]