Skip to content
Snippets Groups Projects
Commit c6b3ef6b authored by Ben Anderson's avatar Ben Anderson
Browse files

restructured in move to git.soton

parent deb163d2
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -10,4 +10,4 @@ Description: Code to support a paper on statistical power analysis. ...@@ -10,4 +10,4 @@ Description: Code to support a paper on statistical power analysis.
License: What license it uses License: What license it uses
Encoding: UTF-8 Encoding: UTF-8
LazyData: true LazyData: true
RoxygenNote: 6.1.0 RoxygenNote: 6.1.1
# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand
export(estimateMeanEffectSizes) export(estimateMeanEffectSizes)
export(estimateProportionEffectSizes) export(estimateProportionSampleSizes)
import(data.table) import(data.table)
import(pwr) import(pwr)
import(reshape2) import(reshape2)
File moved
# run this to knit the .Rmd to an html file
library(markdown)
library(bookdown)
library(dkUtils)
library(weGotThePower)
repoLoc <- dkUtils::findParentDirectory("weGotThePower")
# this will fail if you do not have access to the UoO GREENGrid Data archive (via HCS)
# it will also sometimes fail on the small sample section due to random processes. Just re-run it.
rmdFile <- paste0(repoLoc, "/code/weGotThePower.Rmd")
rmarkdown::render(input = rmdFile,
output_format = "html_document2",
output_file = paste0(repoLoc, "/output/weGotThePower.html")
)
\ No newline at end of file
...@@ -468,12 +468,11 @@ linkedTestDT <- linkedTestDT[season == "Winter" & !is.na(nPeople)] ...@@ -468,12 +468,11 @@ linkedTestDT <- linkedTestDT[season == "Winter" & !is.na(nPeople)]
# create small sample - be warned, this is a random process so you will get different results each time you run it # create small sample - be warned, this is a random process so you will get different results each time you run it
smallTestDT <- sample_frac(linkedTestDT, 2, replace = TRUE) smallTestDT <- data.table::as.data.table(sample_frac(linkedTestDT, 2, replace = TRUE))
t <- smallTestDT[, .("mean W" = mean(meanW), t <- smallTestDT[, .("mean W" = mean(meanW),
"sd W" = sd(meanW), "sd W" = sd(meanW),
"n households" = .N), "n households" = .N), keyby = .(nPeople)]
keyby = .(nPeople)]
knitr::kable(t, caption = "Number of households and summary statistics per group (winter heat pump use)") knitr::kable(t, caption = "Number of households and summary statistics per group (winter heat pump use)")
``` ```
...@@ -574,7 +573,7 @@ Now: ...@@ -574,7 +573,7 @@ Now:
```{r creatLargeN} ```{r creatLargeN}
# fix. # fix.
# we just randomly re-sample the GREEN Grid data # we just randomly re-sample the GREEN Grid data
largeTestDT <- sample_frac(linkedTestDT, 40, replace = TRUE) largeTestDT <- data.table::as.data.table(sample_frac(linkedTestDT, 40, replace = TRUE))
t <- largeTestDT[, .("mean W" = mean(meanW), t <- largeTestDT[, .("mean W" = mean(meanW),
"sd W" = sd(meanW), "sd W" = sd(meanW),
......
# We Got The Power: Analysis for a short paper on statistical power & statistical significance
And the various confusions that arise...
* Latest draft:
* [.Rmd](https://github.com/dataknut/weGotThePower/blob/master/paper/weGotThePower.Rmd) code (mostly stats & notes, little text)
* [.html](weGotThePower.html) output (as above)
theme: jekyll-theme-slate
\ No newline at end of file
...@@ -22,7 +22,7 @@ estimateMeanEffectSizes(mean, sd, samples, power) ...@@ -22,7 +22,7 @@ estimateMeanEffectSizes(mean, sd, samples, power)
Returns a data.table of effect sizes for a given sample size. Calculates these for p = 0.01, 0.05, 0.1 & 0.2. Pick out the ones you want. Returns a data.table of effect sizes for a given sample size. Calculates these for p = 0.01, 0.05, 0.1 & 0.2. Pick out the ones you want.
} }
\seealso{ \seealso{
Other Power functions: \code{\link{estimateProportionEffectSizes}} Other Power functions: \code{\link{estimateProportionSampleSizes}}
} }
\author{ \author{
Ben Anderson, \email{b.anderson@soton.ac.uk} Ben Anderson, \email{b.anderson@soton.ac.uk}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/power.R % Please edit documentation in R/power.R
\name{estimateProportionEffectSizes} \name{estimateProportionSampleSizes}
\alias{estimateProportionEffectSizes} \alias{estimateProportionSampleSizes}
\title{Estimate detectable proportion differences for given sample sizes using statistical power analysis} \title{Estimate detectable proportion differences for given sample sizes using statistical power analysis}
\usage{ \usage{
estimateProportionEffectSizes(samples, power) estimateProportionSampleSizes(p1, p2, samples, power)
} }
\arguments{ \arguments{
\item{p1}{the estimated proportion in sample 1}
\item{samples}{a list of sample sizes to iterate over} \item{samples}{a list of sample sizes to iterate over}
\item{power}{power value to use} \item{power}{power value to use}
\item{mean}{the estimated mean value to use} \item{sd}{the estimated proportion in sample 2}
\item{sd}{the estimated stadnard deviation to use}
} }
\description{ \description{
\code{estimateProportionEffectSizes} calculates required sample sizes for a given set of p values and samples. \code{estimateProportionEffectSizes} calculates required sample sizes for a given set of p values and samples.
......
File moved
Source diff could not be displayed: it is too large. Options to address this: view the blob.
# run this to knit the .Rmd to an html file in the docs/ directory for github pages
library(markdown)
library(bookdown)
library(dkUtils)
myParams$repoLoc <- dkUtils::findParentDirectory("weGotThePower")
rmdFile <- paste0(myParams$repoLoc, "/paper/weGotThePower.Rmd")
rmarkdown::render(input = rmdFile,
output_format = "html_document2",
output_file = paste0(myParams$repoLoc, "/docs/weGotThePower.html")
)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment