Questions are below. My solutions will be available after the tutorials are all finished. The whole point of these worksheets is for you to use your lecture notes to figure out what to do. In tutorial, the TAs are available to guide you if you get stuck. Once you have figured out how to do this worksheet, you will be prepared to tackle the assignment that depends on it.
If you are not able to finish in an hour, I encourage you to continue later with what you were unable to finish in tutorial.
Packages
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.3 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(smmr)
Drawing a power curve
You are the statistician on a research team, in the planning stage of a study. The principal investigator (PI) wants to test an intervention that, they hope, will raise scores on a standard test from the current mean of 100 to a mean of 115. A small pilot study has revealed that scores have a standard deviation of 50, and the PI is willing to assume that scores have a normal distribution. The PI wants you to make a graph that will clearly show how the power of a one-sided test depends on sample size, and in particular would like to be able to read from the graph what sample sizes will yield power of 0.7, 0.8, 0.9 and a power “indistinguishable from 1”.
Using power.t.test to calculate power, make such a graph. Hint: you will need to decide for yourself what sample sizes to use on your graph.
The procedure to follow is that of the first power curve in lecture. In that, I used sample sizes from 10 to 100 in steps of 10, which turned out to give a good graph there, but there is no reason to suppose that those sample sizes will also work here. You have a couple of ways you might go here:
use sample sizes from 10 to 100 in steps of 10, draw the graph, see if you like it, and if not fix it up
do some preliminary investigation to see what sample sizes yield power of 0.7 or less and “nearly 1”, and then use those sample sizes as the lower and upper limits of sample size for your graph.
The other thing to incorporate here is the one-sidedness of the test (which means you do not need the strict = TRUE that we had in lecture, because that applies to two-sided tests).
I’ll use my second idea, since you may not have thought of that. We can take advantage of the fact that power.t.test will also give us the sample size to achieve a given power. The model from lecture is this:
power.t.test(power =0.80, delta =10-8, sd =4,type="one.sample", alternative ="one.sided")
so let’s use that, changing some numbers. We’ll start with power 0.7:
power.t.test(power =0.70, delta =115-100, sd =50,type="one.sample", alternative ="one.sided")
One-sample t test power calculation
n = 53.66191
delta = 15
sd = 50
sig.level = 0.05
power = 0.7
alternative = one.sided
so it looks as if we will need to start our graph at something like \(n = 50\).
Likewise, pick a number like 0.999 to be a power “indistinguishable from 1”:
power.t.test(power =0.999, delta =115-100, sd =50,type="one.sample", alternative ="one.sided")
One-sample t test power calculation
n = 250.4843
delta = 15
sd = 50
sig.level = 0.05
power = 0.999
alternative = one.sided
This gives a sample size of 251,1 so maybe having the graph go up to 250 or a bit beyond would be good. It’s up to you how “densely” you want to include sample sizes in between those; since your PI would like to be able to read values reasonably accurately off the graph, you might go in steps of 5 rather than the 10 we did in lecture:
The vertical tick marks are 25 apart, so the required sample sizes are about 55 for power 0.7, 70 for power 0.8, maybe 95 for power 0.9, and something like 240 for power “indistinguishable from 1”.
Now the PI can go back to their office with this graph and try to choose a sample size that balances a decent power with the sample size the research grant allows them to collect.
A final remark that you should consider what your reader will want to see. If you were doing this kind of thing on an assignment for me, I would want to see your whole thought process including your code (because I am interested in why you chose to do it the way you did), but in a report for your PI, they most likely only want to see the final graph, and, unless they were curious about how you got there, they will most likely not want to see any of your code or thought process.4
Extra: if you went with the same sample sizes as in lecture, this is what you get:
ns <-seq(10, 100, 10)ans <-power.t.test(n = ns, delta =115-100, sd =50,type="one.sample", alternative ="one.sided")d <-tibble(n = ns, power = ans$power)ggplot(d, aes(x = n, y = power)) +geom_point() +geom_line() +geom_hline(yintercept =1, linetype ="dashed")
These sample sizes don’t go up big enough, because the power has only just reached 0.9, and is certainly not “indistinguishable from 1”. Also, we don’t need the smallest sample sizes, because we are not interested in power below 0.5 for sure. To decide how far up to go, you can either find the sample size that gives you a power like 0.999 (as I did above), or you can use trial and error. Guessing that \(n = 200\) is how far up to go gives you this (starting at \(n = 40\)), copying, pasting and making two edits:
ns <-seq(40, 200, 10)ans <-power.t.test(n = ns, delta =115-100, sd =50,type="one.sample", alternative ="one.sided")d <-tibble(n = ns, power = ans$power)ggplot(d, aes(x = n, y = power)) +geom_point() +geom_line() +geom_hline(yintercept =1, linetype ="dashed")
and from here you might decide to go up a bit further, such as to a sample size of \(n = 250\), and to add the horizontal lines at 0.7, 0.8, and 0.9 as before.
Two-sample power
Suppose we have two populations, which we are supposing to both be normally distributed. The first population has a mean of 20, and the second population has a mean of 25. Both populations have the same SD of 9.
Suppose we take samples of 30 observations from each population. Use power.t.test to find the probability that a two-sample \(t\)-test will (correctly) reject the null hypothesis that the two populations have the same mean, in favour of a one-sided alternative. (Hint: delta should be positive.)
Solution
Note first that power.t.test works here because (i) the populations have normal distributions, (ii) the SDs are the same, (iii) the sample sizes from each population are the same.
Then, subtracting the means so that the bigger one is first (and thus delta is positive):
power.t.test(n =30, delta =25-20, sd =9, type ="two.sample", alternative ="one.sided")
Two-sample t test power calculation
n = 30
delta = 5
sd = 9
sig.level = 0.05
power = 0.6849538
alternative = one.sided
NOTE: n is number in *each* group
The power is about 0.68. (Give about one more decimal if you prefer.)
You’ll recall that we don’t say which one side we want to reject for. The way power.t.test does it is to assume the first population has the bigger mean, which is why I said to use a positive delta.5
\(\blacksquare\)
Find the sample size needed to obtain a power of 0.75. Comment briefly on whether your sample size makes sense.
Solution
The coding part is not meant to be hard: take what you just did, and replace the n with the power you are shooting for:
power.t.test(power =0.75, delta =25-20, sd =9, type ="two.sample", alternative ="one.sided")
Two-sample t test power calculation
n = 35.55396
delta = 5
sd = 9
sig.level = 0.05
power = 0.75
alternative = one.sided
NOTE: n is number in *each* group
The required sample size is 36 in each group, which, were you doing this on an assignment, you would need to say. (Remember also to round up to the next whole number, since you want at least that much power.)
As to why the answer makes sense, well, before we had a sample size of 30 in each group and a power about 0.68. Our target power here was slightly bigger than that, and to increase the power (all else fixed) we need to increase the sample size as well. The sample size needed is slightly bigger than 30, which matches with the power desired being slightly bigger than 0.68.
\(\blacksquare\)
Reproduce your power result from Question 2 by simulation. Some things to consider:
you will need to generate two columns of random samples, one from each population
t.test can also run a two-sample \(t\)-test by giving the two columns separately, rather than as we have done it before by having a column with all the measurements and a separate column saying which group they came from.
you will need to get the right alternative. With two columns input like this, the alternative is relative to the column you give first.
My estimated power is 0.675, entirely consistent with Question 2. The rule of thumb says that with 1000 simulations, our estimated power here should be within 0.03 of the correct answer, 95% of the time. If your answer here is not between about 0.650 and 0.720, that would be a good reason to look at your code carefully. Did you miss something, like the alternative?
Code notes:
generate two columns of random samples, one from each population
feed the two columns of samples into t.test one after the other, without using a model formula (with a squiggle in it) or data =. The first population actually had the smaller mean, so that is the one side that you would like the test to reject in favour of.
\(\blacksquare\)
Give an example of a situation where the simulation approach could be used and power.t.test not.
Solution
In my solution to an earlier question I said
Note first that power.t.test works here because (i) the populations have normal distributions, (ii) the SDs are the same, (iii) the sample sizes from each population are the same.
These all need to be true in order to use the two-sample version of power.t.test,6 so to answer this one, describe a situation where one of them fails, for example:
the population distributions are something other than normal (“child psychology revisited” is an example of this)
the two populations have different SDs (spreads). I think power.t.test is using the pooled test behind the scenes.
the sample sizes are different (for example, sampling from one population might be more expensive than sampling from the other, and you might want to achieve a certain power with one sample size being twice the other).
It is also worth noting that you could make these changes in your simulation code without great difficulty:
change rnorm to something else
change the 9’s in rnorm to something else (the one in sample1 different from the one in sample2)
change the 30’s in rnorm to something else.
\(\blacksquare\)
The thickness of stamps
Collectors of postage stamps know that the same stamp may be made from several different batches of paper of different thicknesses. Our data set, in http://ritsokiguess.site/datafiles/stamp.csv, contains the thickness, in millimetres, of each of 485 stamps that were printed in 1872. It is suspected that the paper used in that year was thinner than in previous years.
Rows: 485 Columns: 1
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (1): Thickness
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stamp
Note for yourself that there is one column called Thickness with an uppercase T, and that the thicknesses appear to be arranged in ascending order.
\(\blacksquare\)
Make a suitable graph of these data. Justify your choice briefly.
Solution
The obvious justification and graph is that you have one quantitative variable, so that what you need is a histogram. This is absolutely fine:
There are almost 500 observations, so you can certainly justify something like 8–10 bins. There is actually a bit of extra shape here that 10 bins helps you see (that maybe-extra-peak around 0.10mm); the guiding principle is that if there are more details of shape that you want to convey, you’ll need more bins that you would if everything were nicely bell-shaped. I discuss that funky shape in an Extra.
Your other option here is a normal quantile plot. For this, you need to say why specifically normality is of interest to you here. You can do that by looking ahead and seeing that you will be doing a sign test, and at that point you realize the data are probably going to be non-normal, so that normality is a concern here. Or, more simply, you can say that the distribution of thicknesses being normal (or not) will tell you which test to do (a one-sample \(t\) or a sign test). This is why I asked you for a brief justification: you should be choosing a normal quantile plot because what matters to you is whether or not the data values have a normal distribution:
This, plus something that justifies a normal quantile plot over a histogram, would also be full marks (if there were marks attached to this).
Extra 1: you can sort of see the bimodality in the normal quantile plot as well, if you know where to look. The idea is that when the pattern of points is steeper than the line, there are fewer observations there than you would expect with a normal distribution; when the pattern is less steep than the line, there are more observations than expected with a normal. Thus, places where the points are suddenly less steep are places to look at an extra peak.
I’m going to come back to our data in a moment, but an easier-to-see one is here (scroll down to near the bottom to the three-humped multimodal example there in Figure 5.12). On their histogram, there is a “hole” just under 0.75 (no data between the second and third peaks), and this shows up on the normal quantile plot also as a gap below 0.75 on the \(y\)-axis,7 or, said differently, the points jump upwards very fast between 0.625 and 0.75 on the \(y\)-axis. With that in mind, you can see another quick jump between about 0.26 and 0.35 (on the \(y\)-axis), which corresponds to the other “hole” between the first and second peaks.
To find where the peaks might be, you look for places where the points on the normal quantile plot are close to flat. I see one place around 0.125 (on the \(y\)-axis again), which is the first peak, around 0.5 (in between the two “gaps”; the second peak), and another approaching 1 (the third peak).
As an aside, in that example they also show a boxplot of the same data. You can see that the boxplot for a three-humped distribution and a uniform (flat-topped) distribution are almost identical. Hence, boxplots are no help in searching for multiple modes.
That example was (presumably) made-up data to illustrate what happens; ours are real data, where things are going to be more messy. In ours, I think it is easier to search for places where the points are steeper than the line (the gaps between peaks). There is a steep bit that extends from about 0.08 to about 0.10, with flatter sections at each end, which suggests peaks around 0.08 and 0.10 and a “hole” in between, relative to the normal at least. The points on the normal quantile plot have an odd shape, odder than the simple curve you would expect for right-skewness, so there might be more peaks as well, for example around 0.12 or around 0.11.
Extra 2: in my original source for these data, the interest was actually not in the mean or median thickness, but in something else: the stamps issued in that year were thought to be a “philatelic mixture”, that is, printed on more than one type of paper. You would expect different types of paper to have different thicknesses (especially in 1872, when manufacturing processes were a good deal less uniform than they are now).
If you go back to my histogram above, you see that the histogram is skewed to the right (which we take up shortly), but also there looks if there is a second mode (peak) just above 0.10 mm. This would support the idea that these stamps were made from two different types of paper: one with average thickness around 0.08 mm, and one with average thickness just above 0.10 mm. (The relatively small number of stamps of thickness around 0.09 mm supports this: stamps of thickness 0.09 could be unusually thick ones from the 0.08 mm paper, or unusually thin ones from the 0.10 mm paper).8
Going back to the histogram, you might be wondering whether there are more modes that this histogram hides. This is one of the rare cases where looking at a lot more bins is helpful, in this case 30:
Looking at that, you could make the case for as many as 7 modes, though how many of them are real and how many are just chance is another question. In Efron and Tibshirani’s book on the bootstrap (reference below), they use a bootstrap-based method to show how you might test for more than 1 mode (and thus more than 1 type of paper), or more than any number of modes. Our library has this book, or you may be able to find it in your favourite quasi-legal source. The example starts on page 227. (It is surprisingly readable for an academic book.)
Reference:
Efron, B. and Tibshirani, R. (1993) An Introduction to the Bootstrap. Chapman and Hall, New York, London
\(\blacksquare\)
From your graph, why do think it might be a good idea to do a sign test rather than a one-sample \(t\)-test on these data? Explain briefly.
Solution
Looking at the graph you drew, the distribution of thicknesses is skewed to the right (or bimodal or multimodal or whatever you saw), and definitely not normal. The sample size is large, but it is not clear that it is large enough to overcome the severe skewness and/or bimodality and/or multimodality.9
I am not asking for a bootstrap sampling distribution of the sample mean, just for a consideration of shape and sample size. I do this just below if you want to see what it looks like.
Extra: if you are interested in that bootstrap sampling distribution:
library(bstrap)plot_dist(stamp$Thickness)
The normality here is in fact absolutely fine, so there would be no problem with a \(t\)-test for the mean. This is because the sample size is so large: the sampling distribution of the sample mean, with the large sample, “smooths out” the multiple modes as well as overcoming the skewness. But I wanted to give you a sign test to do. The mean, though, would be pulled to the right by the skewness, so you could still argue that the median is the right summary statistic and the sign test is the right test, as in the IRS example in lecture.
\(\blacksquare\)
The median thickness in years prior to 1872 was 0.082 mm. Is there evidence that the paper on which stamps were printed in 1872 is thinner than in previous years? Explain briefly.
Solution
A sign test for the median. Input is dataframe, column, and null median:
We are testing the null that the (population) median thickness is 0.082 mm, against the alternative that the median thickness is less than 0.082 mm, so the P-value we need is \(2.2 \times 10^{-5} = 0.000022\) from the lower line. This is (much) smaller than 0.05, so we (clearly) reject the null hypothesis in favour of the alternative. That is, we do have evidence that the paper was thinner in 1872.
Say what your P-value is, to make it clear that you are reading the right one off the output. (I might have put an alternative option in sign_test, but I didn’t, opting instead to give you all three P-values.)
Extra 1: having rejected the null, you might be interested in what the median actually is in 1872. This calls for ci_median, but if you run it the obvious way you get something that seems to make no sense:
ci_median(stamp, Thickness)
[1] 0.08 0.08
Well, the lower and upper limits of the confidence interval can’t be the same, can they?
The resolution comes from realizing about three things:
the ends of a CI for the median are data values.
the data values are given to three decimal places (go back and look)
to make ci_median give more decimals, set tol to something smaller. To find out that this is what to do, look at the help for ci_median by typing ?ci_median in the console. This reveals that the accuracy to which the ends of the CI are determined is controlled by tol and the default value of tol is 0.01, which will only give us two decimals.
Hence, what we need is this. I’m getting four decimals so that we can confirm that the last one is, or rounds to, zero:
ci_median(stamp, Thickness, tol =1e-4)
[1] 0.07900391 0.08096222
and therefore the interval is from 0.079 to 0.081. These are both data values:
This is a very short interval, because we have such a large sample size. In other words, we are confident that the median is less than 0.082 (from the test), but we are also very confident that the median is only a little less than 0.082 (from the confidence interval).
Extra 2: if you go back and look at the test results, you see that 189 of the observed thicknesses are above 0.082 and 278 are below (of the 467 that are not exactly equal to 0.082; the others are thrown away). This might seem to you close to a 50–50 split, but in fact the P-value is telling you that if you tossed a fair coin 467 times, you would actually be very unlikely to observe 189 heads or fewer (“more extreme”). To get a bit of intuition about whether this is reasonable, recall that if the number of trials is large (467; it is), the number of values above the hypothesized median has a binomial distribution that is well approximated by a normal distribution with the same mean and SD as the binomial:
bin_mean <-467*0.5# npbin_mean
[1] 233.5
bin_sd <-sqrt(467*0.5* (1-0.5)) # variance is np(1-p)bin_sd
[1] 10.80509
z <- (189+0.5- bin_mean) / bin_sdz
[1] -4.072154
pnorm(z)
[1] 2.329015e-05
and so you see that 189 or fewer observations out of 467 above the null median is very unlikely if the null median is correct, as you might already suspect from the z that is very large10 in absolute value.11 The probability from this normal approximation is extremely close to the one-sided P-value that was calculated using the (exact) binomial distribution, indicating that the normal approximation is extremely good here.
\(\blacksquare\)
Canned tuna
Light tuna is sold in 170-gram cans. The tuna can be canned in either water or oil. Is there a difference in the typical selling price of tuna canned in water or in oil? To find out, 25 supermarkets were sampled. In 14 of them (randomly chosen), the price of a (randomly chosen) brand of tuna in water was recorded, and in the other 11 supermarkets, the price of a (randomly chosen) brand of tuna in oil was recorded. The data are in http://ritsokiguess.site/datafiles/tuna.csv, with the column canned_in saying whether the tuna was canned in oil or water, and the price being in cents.
Rows: 25 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): canned_in
dbl (1): price
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
tuna
Scrolling down reveals that the cans of tuna canned in oil are at the bottom.
Extra: you might be wondering what happens if we try read_delim with no second input here:
Rows: 25 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): canned_in
dbl (1): price
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
tuna
Exactly the same. If you look at the column specification (click the R Console output above if you don’t see it):
Not too many bins, with 25 observations altogether. If your choice of bins reveals a second peak, I suspect that is just chance (unlike the stamps question).
An option here is a one-sample boxplot (which doesn’t require any thought about bins):
ggplot(tuna, aes(y = price)) +geom_boxplot()
These are both very much skewed to the right, as you would do well to observe (because of the longer upper whisker on the boxplot). The boxplot suggests an outlier, which didn’t show up on the histogram, but which might have done if we had used more bins.12
\(\blacksquare\)
Make a normal quantile plot of the prices (again, ignoring what the tuna was canned in).
Solution
This, remembering that in a normal quantile plot, the thing that you are assessing for normality is called sample:
Now you see why the boxplot found an outlier: the very high price, over 200, does seem to be noticeably higher than the others, but you can also say that it is part of the curved shape of all the points, and so “right-skewed” is maybe a better description of what’s going on.
Extra: transforming the data first might help, like the one you did with the logs of the house prices:
ggplot(tuna, aes(x = canned_in, y =log(price))) +geom_boxplot()
Taking logs is not enough, because these distributions are still very much skewed to the right. So we seem to be stuck with something other than a two-sample \(t\)-test.13
\(\blacksquare\)
What does your normal quantile plot tell you about the distribution of prices? Is that consistent with your first plot? (I would add “explain briefly” if this were for marks, but you should probably think about how your explanation would look in any case.)
Solution
Your histogram (or boxplot) indicated a right-skewed distribution, so you would expect your normal quantile plot to show the same thing. This one certainly does show an upward-opening curve,14 indicating skewness in one direction or the other. To work out which way, look at the lower and upper tails: the lowest values are all very close together, being just over 50 cents, but the highest values are spread out, with the highest one being over $2. This combination of a short left tail and a long right tail means skewed to the right. (The direction of skewness is where the long tail is.)
So the histogram and the normal quantile plot are showing the same thing.
\(\blacksquare\)
Some of the tuna was canned in oil and some in water, which may make a difference to the distribution of price. Make normal quantile plots of price for the tuna packed in oil and packed in water separately, with one ggplot command.
Solution
The key to this is to facet by the grouping variable:
The story is that both groups have a right-skewed distribution of prices. For the tuna packed in water (on the right), this is almost a classic right skew (with a short tail on the left and a long tail on the right). For the tuna packed in oil, things are less clear: it is not obvious that the right tail is really too long, but the left tail is definitely too short. In fact, it looks as if the lowest six prices are from a different distribution entirely than the other five.
\(\blacksquare\)
Why might it be a bad idea to run a two-sample \(t\)-test on these data? Explain briefly.
Solution
For a two-sample \(t\)-test, we assume that both sets of price values are drawn from a normal distribution. These ones are very definitely not, since both distributions are skewed to the right.
The second thing to consider is the sample sizes. These are 14 and 11, not large, and with this amount of skewness the Central Limit Theorem will not help enough (at least, that’s my guess). You could get hold of the bootstrap sampling distributions of the sample means for each group if you wanted to investigate this further.
So, considering these two things, a two-sample \(t\)-test is unwise.
Looking ahead a bit:
The other thing that might have been relevant (but turned out not to be) was that the prices of tuna canned in oil were much more spread out than those canned in water. This shows up on the normal quantile plot as the line for oil on the normal quantile plot being steeper than the one for water. (The two facetted boxplots are on the same scales, so the one that fills more of its facet and has a steeper line is more variable.) This would also show up in the usual way on a boxplot, if you drew one.
This turns out not to be relevant because once we have rejected normality, as we have, it doesn’t matter whether one of the groups is more spread out than the other; the test we’ll see, the Mood median test, will cope perfectly well. You might have run into another nonparametric test for this situation called the rank sum test, or the Mann-Whitney test, or the Wilcoxon test (these are all the same test). For the rank sum test, it matters that both groups have the same spread; the usual way it is phrased is that the two groups have to have the same distribution apart possibly from a difference in medians. I don’t like the rank sum test for this reason; if we can handle a difference in spreads in the \(t\)-test (by using the Welch test), we ought to be able to handle a difference in spreads in the test we use that does not assume normality. I don’t know of a Welch-like version of the rank sum test.15
\(\blacksquare\)
Footnotes
I first tried this with power 0.99, but when I drew this graph there was a clear gap between the point and the power = 1 line.↩︎
This is the same power.t.test I ran just above, except that I have changed power = back to n =, because we now have sample sizes.↩︎
The lines joining the points are made with geom_line, so they are straight lines, but there are lots of them, so the overall effect looks like a curve rather than a bunch of straight lines glued together.↩︎
If you think they may be interested in the process, you describe this in an appendix to your report, so that they know that they don’t have to read it, but it’s there if they want to read it.↩︎
Otherwise you’ll get an extremely small power, which corresponds to concluding that the population that actually has the smaller mean in fact has the bigger one, which you could imagine is not going to happen much.↩︎
and therefore power.t.test in the two-sample case is quite restrictive.↩︎
Because the \(y\)-axis is the data axis on this kind of plot.↩︎
This is why a one-sample boxplot is not on the table here; that plot effectively assumes unimodality (one peak). If you have a unimodal distribution, a boxplot tells you about the centre, spread, and shape, but if you have a multimodal distribution, those peaks just disappear on a boxplot and you never see them.↩︎
You can use some words like these to make it clear that you have considered both the distribution shape and the sample size. I am giving you the conclusion to come to; it’s up to you to come up with a reason why I could have done so, which is why I used the word “might”.↩︎
The extra 0.5 is a continuity correction. The binomial is discrete (the number of “successes” can only be an integer), while the normal is continuous. To approximate a discrete distribution by a continuous one, you have to say that “less than or equal to 189” means, in a continuous distribution, “less than anything that rounds to 189”, ie. \(< 189.5\). In a continuous distribution, you don’t have to worry about \(<\) vs \(\le\).↩︎
Also note that there is no indication on the boxplot that there might be an extra peak, because an assumption hiding behind the boxplot is that there is “a” centre (the median) and some deviation about that, possibly including outliers (but not a second mode).↩︎
There might be a different transformation that would work. But things like 1/price go too far the other way.↩︎
Albeit a curve with a rather sharp corner in this case.↩︎
Having said that, the rank sum test, particularly the large-sample version based on a normal approximation, is more or less the (pooled) two-sample \(t\)-test on the ranks, so you could do a Welch two-sample \(t\)-test on the ranks as well. At this writing, I don’t know whether such a test properly handles groups with different spreads or not.↩︎