## R-Code for Power in 2×2 Cross-over [🇷 for BE/BA]

Hello Brus,

Here's something basic to get you started. I assume you already have the PowerTOST package on your system.

Can be refined with designs and multipanel options and what not.

PS: Correct, I am not entirely comfy with the

❝ I am not an expert in R, and I am trying to adapt your example of power calculation with plot replesentation, but for the calculation of the sample size. My objetive is to plot a graphicala representation with ratio in X axis and sample size in Y axis and setting the CV and power as a fixed value.

Here's something basic to get you started. I assume you already have the PowerTOST package on your system.

`Try.this=function(CV=0.2, tpow=0.8)`

{

library(PowerTOST)

x=c(85:120)/100

y=rep(NA, length(x))

for (i in 1:length(x))

y[i]= sampleN.TOST(CV=CV, targetpower=tpow, theta0=x[i])[1,7]

plot(x,y, col="red", xlab ="GMR", ylab="Sample size")

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

return(0)

}

Try.this(CV=0.3, tpow=0.9)

Can be refined with designs and multipanel options and what not.

PS: Correct, I am not entirely comfy with the

` tapply, sapply, apply`

family of functions.—

Pass or fail!

ElMaestro

Pass or fail!

ElMaestro

### Complete thread:

- R-Code for Power in 2×2 Cross-over Helmut 2006-12-28 21:33 [🇷 for BE/BA]
- Power in Diletti's sample size table Helmut 2007-01-01 23:59
- Approximate Power Helmut 2007-01-06 15:17
- Power Calculation for replicate crossover design mathews 2008-04-03 13:19
- Power Calculation for replicate crossover design Helmut 2008-04-03 13:49
- Power Calculation for replicate crossover design mathews 2008-04-04 13:21

- Power Calculation for replicate crossover design Helmut 2008-04-03 13:49
- Exact Power Helmut 2009-09-25 19:20
- Exact Power ElMaestro 2009-09-27 23:27
- Software validation Helmut 2009-09-28 15:21
- All the important answers are here! ElMaestro 2009-09-28 19:12
- All the important answers are here! Helmut 2009-09-28 19:52
- All the important answers are here! ElMaestro 2009-09-28 20:18
- All the important answers are here! yjlee168 2009-09-28 21:30
- All the important answers are here! Helmut 2009-09-28 23:18
- 42! SASophylistic power oracle d_labes 2009-09-29 13:37
- Al Gore Rhythms Helmut 2009-09-29 14:52
- Al Gore Rhythms ElMaestro 2009-09-29 18:14
- Al Gore Rhythms yjlee168 2009-09-29 23:55

- Al Gore Rhythms Helmut 2009-09-29 14:52

- 42! SASophylistic power oracle d_labes 2009-09-29 13:37
- All the important answers are here! yjlee168 2009-09-29 23:49

- All the important answers are here! Helmut 2009-09-28 23:18

- All the important answers are here! Helmut 2009-09-28 19:52

- All the important answers are here! ElMaestro 2009-09-28 19:12

- Software validation Helmut 2009-09-28 15:21

- Exact Power ElMaestro 2009-09-27 23:27

- Power Calculation for replicate crossover design mathews 2008-04-03 13:19

- Approximate Power Helmut 2007-01-06 15:17
- R-Code for Power in 2×2 Cross-over KDA 2019-01-23 04:24
- R-Code for Power in 2×2 Cross-over Ohlbe 2019-01-27 18:24

- R-Code for Power in 2×2 Cross-over Brus 2021-12-02 15:00
- R-Code for Power in 2×2 Cross-overElMaestro 2021-12-02 15:15
- R-Code for Power in 2×2 Cross-over Helmut 2021-12-02 17:30

- R-Code for Power in 2×2 Cross-over Helmut 2021-12-02 16:57

- R-Code for Power in 2×2 Cross-overElMaestro 2021-12-02 15:15

- Power in Diletti's sample size table Helmut 2007-01-01 23:59