diff --git a/sim/theo.R b/sim/theo.R index 7d931dc78924f4eba50867ddaf019d1bdbcaa19e..c24ec8a057fc462bd6b8296f579deb21c0c52923 100644 --- a/sim/theo.R +++ b/sim/theo.R @@ -43,7 +43,7 @@ d <- list( d$m$rand <- rep(NA, d$N) d$c$rand <- rep(NA, d$N) - d$p$rand <- rep(NA, d$N) + d$p$randMean <- rep(NA, d$N) d$t$randMean <- rep(NA, d$N) @@ -59,8 +59,8 @@ d <- list( d$p$lower[i], length.out = d$M) - d$p$rand[i,] <- d$p.pure[i,] + rnorm(d$M, 0, d$p$randSd) - d$t$rand[i,] <- d$t.pure[i,] + rnorm(d$M, 0, d$t$randSd) + d$p$rand[i,] <- d$p$pure[i,] + rnorm(d$M, 0, d$p$randSd) + d$t$rand[i,] <- d$t$pure[i,] + rnorm(d$M, 0, d$t$randSd) temp.lm <- lm( d$p$rand[i,] ~ d$t$rand[i,]) d$c$rand[i] <- coefficients(temp.lm)[1] @@ -78,14 +78,14 @@ d <- list( ### --- plot --- - pt.df <- data.frame(d$p$pure = as.vector(d$p$pure), - d$t$pure = as.vector(d$t$pure), - d$p$rand = as.vector(d$p$rand), - d$t$rand = as.vector(d$t$rand)) + pt.df <- data.frame(d.p.pure = as.vector(d$p$pure), + d.t.pure = as.vector(d$t$pure), + d.p.rand = as.vector(d$p$rand), + d.t.rand = as.vector(d$t$rand)) ggplot(pt.df) + - geom_point(aes(x = d$t$pure, y = d$p$pure), color='black') + - geom_point(aes(x = d$t$rand, y = d$p$rand), color='red') + - geom_abline(aes(intercept = c.rand, slope = m.rand), color='red') + - geom_vline(xintercept = d$t$rand.0, linetype = "longdash") + - geom_point(aes(y = d$p$rand.mean, x = d$t$rand.mean), color="black", size=4) + + geom_point(aes(x = d.t.pure, y = d.p.pure), color='black') + + geom_point(aes(x = d.t.rand, y = d.p.rand), color='red') + + geom_abline(aes(intercept = d$c$rand, slope = d$m$rand), color='red') + + geom_vline(xintercept = d$t$rand0, linetype = "longdash") + + geom_point(aes(y = d$p$randMean, x = d$t$randMean), color="black", size=4) + ggtitle("dp vs. dt")