Hi I'm trying to plot the power functions of a t-test and a sign test using simulated data from a normal distribution N(theta,1). The power function of the t-test is Pr(TS1>c1) and the power function of the sign test is Pr(TS2>c2). where TS1 is the test statistic of the t-test which is mean(x)/(sd(x)*sqrt(n)) and TS2 is the test statistic of the sign test which is sum(x>0). I have to do this for 0<theta<2

I have produced the following code but can't figure out where I'm going wrong. Any help would be appreciated - thanks!

c1 <- 1.9

c2 <- 8

n <- 10

thetaVals = seq(0,2,length.out = 1000)

set.seed(1)

P1 <- vector("numeric", length = 1000)

P2 <- vector("numeric", length = 1000)

estimators <- vector("numeric", length = 1000)

for (n in seq(1,10)) {

for (i in 1:1000) {

x <- rnorm(thetaVals, sd = 1)

TS1[i] = mean(x)/(sd(x)*sqrt(n))

TS2[i] = sum(x>0)

}

P1[n] <- Pr(TS1 > c1)

P2[n] <- PR(TS2 > c2)

}

nVal <- seq(1, 1000 , by = 1)

plot(thetaVals, P1)

plot(thetaVals, P2)