title: (Homework Question) alternative hypothesis argument
body: <p>I apologize for the vague title, but I don't really know to explain it well cause I just don't understand what it is I'm supposed to do.</p>
  <p><a href="https://i.stack.imgur.com/l4XFq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l4XFq.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/CqWJn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CqWJn.png" alt="enter image description here" /></a></p>
  <p>Below is my code which I believe provides everything e (ii) asks for, but I don't know what to do for the alt = &quot;two-sided&quot; argument. Any help in clarifying it would be appreciated and please let me know if what I have is wrong</p>
  <pre><code>ev &lt;- function(x, mu0 = y, lev = 0.95) {
    ts&lt;- ((mean(x)-mu0)/(sd(x)/sqrt(length(x))))
    pval &lt;- 2*pnorm(-abs(ts))
    ci&lt;- mean(x) + qt(lev / 2, length(x) - 1) * sd(x) / sqrt(length(x)) * c(-1, 1)
      return(list(c(ts,pval, ci)))
  }
  s&lt;- rnorm(20)
  &gt; ev(s,0.2)
  [[1]]
  [1] -0.65345075  0.51346573  0.10089696  0.07954784
  
  
  ev &lt;- function(x, mu0 = y, alt = &quot;two-sided&quot;, lev = 0.95) {
    ts&lt;- ((mean(x)-mu0)/(sd(x)/sqrt(length(x))))
    if(alt == &quot;two-sided&quot;) {
      pval &lt;- 2*pnorm(-abs(ts))
    ci&lt;- c((mu0- pval*(length(x)/ts)), mu0 + pval*(length(x)/ts))
    }
    else if(alt == &quot;greater&quot;){
      pval &lt;- (1- pnorm(-abs(ts)))
      ci&lt;- c((mu0- pval*(length(x)/ts)), mu0 + pval*(length(x)/ts))
    }
    else if(alt == &quot;less&quot;) {
      pval &lt;- pnorm(-abs(ts))
      ci&lt;- c((mu0- pval*(length(x)/ts)), mu0 + pval*(length(x)/ts))
    }
      return(list(c(ts,pval, ci)))
  }
  </code></pre>