Given the appropriate input values, the function computes the power (sample size) corresponding to the specifed sample size (power). If a segmented fit object is provided, the power is computed taking the parameter estimates as input values.
pwr.seg(oseg, pow, n, z = "1:n/n", psi, d, s, n.range = c(10,300),
X = NULL, break.type=1, alpha = 0.01, round.n = TRUE,
alternative = c("two.sided", "greater", "less"), msg = TRUE, ci.pow=0)
The computed power or sample size, with or without message (depending on msg
)
The fitted segmented object. If provided, the power is computed at the model parameter estimates, and all the remaining arguments but alternative
and alpha
are ignored.
The desired power level. If provided n
has to be missing
The fixed sample size. If provided pow
has to be missing
The covariate understood to have a segmented effect. Default is "1:n/n"
, i.e. equispaced values in (0,1). More generally a string indicating the quantile function having p
and possible other numerical values as arguments. For istance "qunif(p,0,1)"
, "qnorm(p,2,5)"
, or "qexp(p)"
. "qunif(p,1,n)"
can be also specified, but attention should be paid to guarantee psi
within the covariate range. Finally, it could be also a numerical vector meaning the actual covariate, but pow
has to be missing. Namely if the covariate is supplied (and n is known), only the relevant power can be estimated.
The breakpoint value within the covariate range
The slope difference
The response standard deviation
When pow
is provided and the relevant sample size estimate has to be returned, the function evaluates 50 sample sizes equally spaced in n.range
. However the function can also compute, via spline interpolation, sample sizes outside the
specified range.
The design matrix including additional linear variables in the regression equation. Default to NULL
which means intercept and linear term for the segmented covariate.
Numerical, meaning the type of breakpoint. break.type=1
means piecewise linear (segmented), break.type=2
refers to piecewise constant.
The type-I error probability. Default to 0.01.
logical. If TRUE
the (possible) returned sample size value is rounded.
a character string specifying the alternative hypothesis, must be one of "two.sided", "greater" or "less". Note, this refers to the sign of the slope difference.
logical. If TRUE
the output is returned along with a simple message, otherwise only the values are returned
Numerical. If oseg
has been supplied, ci.pow
replicates are drawn to build a 95% confidence interval for the power.
Nicoletta D'Angelo and Vito Muggeo
The function exploits the sampling distribution of the pseudo Score statistic under the alternative hypothesis of one breakpoint.
D'Angelo N, Muggeo V.M.R. (2021) Power analysis in segmented regression, working paper
https://www.researchgate.net/publication/355885747.
Muggeo, V.M.R. (2016) Testing with a nuisance parameter present only under the alternative: a score-based approach with application to segmented modelling. J of Statistical Computation and Simulation, 86, 3059--3067.
pscore.test
## pwr.seg(pow=.7, psi=.5, d=1.5, s=.5) #returns the sample size
## pwr.seg(n=219, psi=.5, d=1.5, s=.5) #returns the power
## pwr.seg(n=20,z="qnorm(p, 2,5)", psi=3, d=.5, s=2) #the covariate is N(2,5)
## pwr.seg(n=20,z="qexp(p)", psi=.1, d=.5, s=.1) #the covariate is Exp(1)
Run the code above in your browser using DataLab