Description Usage Arguments Value Background History/development log Author(s) See Also Examples

View source: R/plotCIcorrelation.R

Function outputting a plot of confidence interval around a correlation for a range of sample sizes

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
plotCIcorrelation(
corr,
minN,
maxN,
step = 1,
conf = 0.95,
minY = NULL,
maxY = NULL
)
plotCIPearson(
corr,
minN,
maxN,
step = 1,
conf = 0.95,
minY = NULL,
maxY = NULL
)
``` |

`corr` |
numeric: observed correlation (assumes Pearson correlation, approximately OK for Spearman) |

`minN` |
numeric: the smallest n for which you want the CI |

`maxN` |
numeric: the largest n for which you want the CI |

`step` |
numeric: the step by which you want n to increment (default is 1), with minN and maxN should give no more than 200 values of n |

`conf` |
numeric: the confidence interval you want, defaults to .95 |

`minY` |
numeric: if you want to set the y axis limits input a number greater than -1 here |

`maxY` |
numeric: if you want to set the y axis limits input a number smaller than 1 here |

a ggplot object so if you don't capture it it will plot to your default plot device

This is another function like `plotBinconf`

which plots the width of confidence
intervals (CIs) for a range of sample/dataset sizes.

Version 1: 5.iv.21

Chris Evans

Other confidence interval functions:
`plotBinconf()`

Other demonstration functions:
`plotBinconf()`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
## Not run:
### simple example for observed 95% confidence interval (CI) around observed correlation of .7
### for sample sizes between 10 and 100
plotCIcorrelation(.7, 10, 100)
### similar but for dataset sizes between 10 and 500 by steps of 5
plotCIcorrelation(.7, 10, 500, 5)
### similar but asking for 99% CI
plotCIcorrelation(.7, 10, 500, 5, conf = .99)
### similar but setting lower y axis limit to -1
plotCIcorrelation(.7, 10, 500, 5, conf = .99, minY = -1)
### and you can set the upper y limit, observed R = 0 for a change
plotCIcorrelation(0, 10, 500, 5, conf = .99, minY = -1, maxY = 1)
### same but exporting to tmpPlot and then changing plot
plotCIcorrelation(0, 10, 500, 5, conf = .99, minY = -1, maxY = 1) -> tmpPlot
tmpPlot +
ggtitle("95% CI around observed Pearson correlation of zero for n from 10 to 500") +
theme_bw()
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.