0

I'm trying to do the following problem,

Inside the function, two Shapiro-Wilk tests of normality are conducted separately for the two samples (note the normality assumption at the beginning of the problem). If one or both p-values are less than 0.05, a warning message is printed out explaining the situation.

but don't know how I could save the p-value to do something like

if(shap1.pval < 0.05) { warrning...etc}

Also would already having an if elseif staement within my function mess with this? Below is something I already have within the function I was told to make

 if(alt== "two-sided") {
    p.val<- 2*pf(test.stat, df1, df2, lower.tail = FALSE)
    lower.bound <- (x1.variance/x2.variance) * lower.crit
    upper.bound <- (x1.variance/x2.variance) * upper.crit
  }

  else if(alt == "greater"){
    p.val<- pf(test.stat, df1, df2, lower.tail = FALSE)
    lower.bound <- (x1.variance/x2.variance) * lower.crit
    upper.bound <- (x1.variance/x2.variance) * upper.crit
  }
redwoods
  • 59
  • 5
  • 1
    Assuming `x1` and `x2` are vectors of numeric data, the logical test would be `shapiro.test(x1)$p.value < .05 | shapiro.test(x2)$p.value < .05`. If `TRUE` that would indicate that at least one sample fails the test at the .05 level. With a reproducible example, it would be possible to be more specific. – dcarlson Apr 05 '22 at 00:13
  • Please provide a minimal working example of your code and what you want the output to look like. See here for how to do this: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – socialscientist Jul 25 '22 at 01:51

1 Answers1

0

A simple method would be to save the p-values from the Shapiro-Wilk tests and then perform a ifelse with the condition min(pvals)>0.05