Instantly share code, notes, and snippets.

# Richard Moreyricharddmorey

• Sort options
Last active Feb 27, 2017
posterior for delta given only t and N
View delta_t.R
 ### Data t = 2 N = 20 rscale = sqrt(2)/2 ### Begin utility functions posterior = Vectorize(function(delta, t, N1, N2 = NULL, rscale = sqrt(2)/2, log = FALSE){
Created Dec 23, 2016
Using JAGS to sample missing values in both DVs and IVs in Bayesian regression
View missings_jags.R
 set.seed(123) # make reproducible M = 10000 # Number of posterior samples N = 20 # sample the IV x = rnorm(N, 10, 5) # regression model for DVs y = 100 + 3*x + rnorm(N,0,10) ## Delete missing data (3 in each)
Created Dec 21, 2016
View t1err-sim.R
 ### Utility functions # Do a single t test simulation # report the p value ttest.sim = function(n, func, true.mean = 0, alpha = 0.05){ x = func(n) - true.mean t.test(x)\$p.value } # Do a sequence of M t tests, report significance
Last active Oct 28, 2016
Spooky random numbers
View getSpookyNums.R
 getSpookyNums = function(M){ s = tempfile() # to ensure no caching my.url = paste0("http://richarddmorey.org/spooky.php?n=",M,"&",s) as.numeric(readLines(my.url)) } x = getSpookyNums(10)
Created Oct 28, 2016
example XML for distribution
View normal.xml
 Normal Normal Gaussian normal continuous
Last active Nov 17, 2016
Troubleshooting flexdashboard scrollbars
View solve.Rmd_
 --- title: "Generated data demo" output: flexdashboard::flex_dashboard: orientation: rows vertical_layout: scroll runtime: shiny --- ```{r setup, include=FALSE}
Last active Aug 11, 2016
Run the Essex Data Analysis Summer School JAGS demo in R
View runAll.R