Learn R Programming

MSPRT (version 2.1)

find.samplesize: Sample size required to achieve a higher significance for one-sample tests in a fixed design

Description

This function finds the sample size that is required to maintain a desired power at a point alternative when we decrease the level of significance of a fixed design one-sample test. This can be calculated in one-sample proportion tests, and one-sample Z & T-tests.

Usage

find.samplesize(test.type, N, lower.signif = 0.05, higher.signif = 0.005,
                null, side = "right", pow = 0.8, alt, sigma0 = 1,
                n.seq, verbose=T, plot.it = T)

Arguments

test.type

a character; denotes the type of test;

``oneProp'' for a one-sample proportion tests.

``oneZ'' for a one-sample Z-tests.

``oneT'' for a one-sample T-tests.

N

a positive numeric (integer); required only in one-sample tests; number of samples on which the fixed design one-sample test is based on.

lower.signif

a numeric in (0,1); denotes the lower level of significance.

Default: 0.05.

higher.signif

a numeric in (0,1); denotes the higher level of significance.

Default: 0.005.

null

a numeric; denotes the hypothesized value of the parameter under the null hypothesis.

The hypothesized parameters are proportion in one-sample proportion tests, and population mean in one-sample Z & T-tests.

Default: 0.5 in one-sample proportion tests, and 0 in one-sample Z and T-tests.

side

a character; direction of the alternative hypothesis H1.

Has to be one of "right" or "left".

Default: "right".

pow

a numeric in (0,1); desired level of power at the point alternative alt.

Default: 0.8. This means \(80\) percent power.

alt

missing or a numeric; value of the point alternative where we want to maintain the power pow.

Default: the `fixed design alternative' at the lower.signif using N samples.

sigma0

a positive numeric; required only in one-sample Z-tests. known population standard deviation.

Default: 1.

n.seq

missing or a numeric vector; the final value of increased sample size is searched over this vector.

Default: N:(4*N).

verbose

logical; if TRUE, returns a message of the achieved results; otherwise it doesn't.

Default: TRUE.

plot.it

a logical; if TRUE, returns a plot; otherwise it doesn't.

Default: TRUE.

Value

Returns a numeric. In a fixed design for the specified one-sample test, this is the sample size that we require to achieve higher.signif while still mainting at least pow amount of power at alt.

References

Main article and supplemental file of MSPRT

Examples

Run this code
# NOT RUN {
find.samplesize(test.type = "oneProp", N = 30, null = .2)

# In this case, the fixed design alternative at 0.05 is 0.4263. As it seems,
# we need to increase the sample size to 51 to achieve the higher significance
# of 0.005 while still maintaining at least 80% power at 0.4263.


find.samplesize(test.type = "oneProp", N = 30, null = .2, side = "left")

# In this case, the fixed design alternative at 0.05 is 0.0516. For testing
# against the left sided alternative, we need to increase the sample size to
# 66 to achieve the higher significance of 0.005 while still maintaining at
# least 80% power at 0.0516.

find.samplesize(test.type = "oneZ", N = 30)
find.samplesize(test.type = "oneZ", N = 30, side = "left")

find.samplesize(test.type = "oneT", N = 30)
find.samplesize(test.type = "oneT", N = 30, side = "left")
# }

Run the code above in your browser using DataLab