Last active
September 10, 2017 17:31
-
-
Save carbocation/cf772a9437c6ce9e039d55e378be60f8 to your computer and use it in GitHub Desktop.
Monte Carlo simulation to compare two vectors, one of which has no variance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(MonteCarlo) | |
df <- data.frame(x=c(2.2, 2.2, 2.2, 2.2, 2.2), y=c(2.2, 1.2, 1.3, 2.4, 2.6)) | |
df$trend <- seq(1,length(df$x)) | |
pv <- function(noparams) { | |
return(list("p.value"=cor(jitter(df$x), df$y))) | |
} | |
param_list <- list("noparams"=c(0)) | |
MC_result<-MonteCarlo(func=pv, nrep=100000, param_list=param_list) | |
mean(MC_result$results$p.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment