Created
November 24, 2024 02:19
-
-
Save abikoushi/925b9ad5bc37e80d577c138b27d9248c to your computer and use it in GitHub Desktop.
Comparison the two ratios
This file contains hidden or 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
n <- 1000 | |
rate <- 1 | |
set.seed(1234) | |
tau_x <- rgamma(n,1,1) | |
X <- rpois(n,tau_x*rate) | |
tau_y <- rgamma(n,2,1) | |
Y <- rpois(n,tau_y*rate) | |
#png("ECDF_rate.png") | |
curve(ecdf(X/tau_x)(x), type = "s", xlim = c(0, 15), ylim=c(0,1), col="royalblue", ylab = "ECDF", xlab = "ratio") | |
curve(ecdf(Y/tau_y)(x), type = "s", add=TRUE, col="orangered", lty=2) | |
#dev.off() | |
print(wilcox.test(X/tau_x,Y/tau_y)) | |
target <- c(X,Y) | |
predictor <- rep(c(0,1),each=n) | |
logtau <- log(c(tau_x,tau_y)) | |
fit <- glm(target ~ predictor+offset(logtau), family = poisson(link = "log")) | |
print(summary(fit)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment