Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basic Biostatistics - Day 2

Similar presentations


Presentation on theme: "Basic Biostatistics - Day 2"— Presentation transcript:

1 Basic Biostatistics - Day 2
Erik Parner PhD course in Basic Biostatistics – Day 2 Erik Parner, Department of Biostatistics, Aarhus University© 24 April 2017 Exercise (Triglyceride) Logarithms and exponentials Two independent samples from normal distributions The model, check of the model, estimation Comparing the two means Approximate confidence interval and test Exact confidence interval and test using the t-distribution Comparing two populations using a non-parametric test The Wilcoxon-Mann-Whitney test Type 1 and type 2 errors Statistical power Simple sample size calculations Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

2 Basic Biostatistics - Day 2
Erik Parner Overview 24 April 2017 Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

3 Exercise 1.2+1.4 (Triglyceride)
Erik Parner Exercise (Triglyceride) 24 April 2017 Assuming triglyceride measurements follows a normal distribution gave invalid results: e.g. the PI did not have 2.5% below and above the two limits. The triglyceride may however be analyzed using a normal model on the log-transformed data. We then need to transform the results back to the original scale to obtain useful results on the triglyceride measurements. The method presented on the next overheads rely on the fact that percentiles are preserved when creating a transformation of the data. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

4 Exercise 1.2+1.4 (Triglyceride)
Erik Parner Exercise (Triglyceride) 24 April 2017 PI (-1.54;-0.01) CI mean -0.77(-0.81;-0.74) exp PI (0.21;0.99) CI median 0.46 (0.44;0.48) Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

5 Basic Biostatistics - Day 2
Erik Parner Logarithmic and exponential transformations 24 April 2017 Medians and percentiles are preserved when making a transformation of the data: 50% to the right exp log 16 % to the right Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

6 Basic Biostatistics - Day 2
Erik Parner Logarithmic and exponential transformations 24 April 2017 The basic properties of the logarithms and exponentials that we will use throughout the course: Product Sum log exp Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

7 Basic Biostatistics - Day 2
Erik Parner Logarithms and the normal distribution 24 April 2017 Assume Y is the measurement and that log(Y)=X follows a normal distribution with mean=median=m , and standard deviation=s, then Y = exp(X) has: Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

8 Basic Biostatistics - Day 2
Erik Parner Logarithm and the normal distribution 24 April 2017 If X has a normal distribution with mean=median=m , and standard deviation=s ,then a valid 95% CI for m will transform into a valid 95% CI for the median of Y = exp(X) a valid 95% PI for X will transform into a valid 95% PI for Y = exp(X) Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

9 Body temperature versus gender
Erik Parner Body temperature versus gender 24 April 2017 Scientific question: Do the two gender have different normal body temperature? Design: 130 participants were randomly sampled, 65 males and 65 females Data: Measured temperature, gender Summary of the data (the units are degrees Celsius): Gender | N(tempC) mean(tempC) sd(tempC) med(tempC) Male | Female | Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

10 Body temperature: Plotting the data
Erik Parner Body temperature: Plotting the data 24 April 2017 Figure 2.1 The data looks “fine” - a few outliers among females? Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

11 Body temperature: Checking the normality in each group
Erik Parner Body temperature: Checking the normality in each group 24 April 2017 Figure 2.2 Normality looks ok! Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

12 Body temperature: The model
Erik Parner Body temperature: The model 24 April 2017 A statistical model: Two independent samples from normal distributions, i.e. the two samples are independent and each are assumed to be a random sample from a normal distribution: The observations are independent (knowing one observation will not alter the distribution of the others) The observations come from the same distribution, e.g. they all have the same mean and variance. This distribution is a normal distribution with unknown mean, mi, and standard deviation, si. N(mi, si2) Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

13 Body temperature: Checking the assumptions
Erik Parner Body temperature: Checking the assumptions 24 April 2017 The first two – think about how data was collected! Independence between groups –information on different individuals Independence within groups: Data are from different individuals, so the assumption is probably ok. In each group: The observations come from the same distribution. Here we can only speculate. Does the body temperature depend on known factors of interest, for example heart rate, time of day, etc.? Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

14 Body temperature: The estimates
Erik Parner Body temperature: The estimates 24 April 2017 The estimates are found like we did day 1: Observe that the width of the prediction interval is approximately * 1.96 * 0.4 C = 1.6 C, so there is a large variation in body temperature between individuals within each of the two groups We see that the average body temperature is higher among women Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

15 Body temperature: Estimating the difference
Erik Parner Body temperature: Estimating the difference 24 April 2017 Remember focus is on the difference between the two groups, meaning, we are interested in : The unknown difference in mean body temperature. This is of course estimated by: What about the precision of this estimate? What is the standard error of a difference? Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

16 The standard error of a difference
Erik Parner The standard error of a difference 24 April 2017 If we have two independent estimates and, like here, calculate the differences, then the standard error of the difference is given as We note that standard error of a difference between two independent estimates is larger than both of the two standard errors. In the body temperature data we get: and an approx. 95% CI Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

17 Testing no difference in means
Erik Parner Testing no difference in means 24 April 2017 Here we are especially interested in the hypothesis that body temperature is the same for the two gender: Hypothesis: d = d0 = 0 We can make an approx. test similar to day 1 and find the p-value as We get p=2.03% Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

18 Exact inference for two independent normal samples
Erik Parner Exact inference for two independent normal samples 24 April 2017 Just like in the one sample setting, it is possible to make exact inference – based on the t-distribution. And again these are easily made by a computer. Remember the model: Two independent samples from normal distributions with means and standard deviations, Note, both the means and the standard deviations might be different in the two populations. If one wants to make exact inference, then one has to make the additional assumption: 4. The standard deviations are the same: sM = sF Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

19 Exact inference for two independent normal samples
Erik Parner Exact inference for two independent normal samples 24 April 2017 Testing the hypothesis : sM = sF This is done by considering the ratio between the two estimated standard deviations: A large value of this F-ratio is critical for the hypothesis The p-value = the probability of observing a F-ratio at least as large as we have observed - given the hypothesis is true! The p-value is here found by using an F-distribution with (nlargest-1) and (nsmallest-1) degrees of freedom: Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

20 Exact inference for two independent normal samples
Erik Parner Exact inference for two independent normal samples 24 April 2017 Testing the hypothesis : sM = sF Here we have: so The observed variance (sd2) is 13% higher among women. But could this be explained by sampling variation – what is the p-value? To find the p-value we consult an F-distribution with 64=(65-1) and 64=(65-1) degrees of freedom. We get p-value = 63% The difference in the observed standard deviation can be explained by sampling variation. We accept that sM = sF ! The fourth assumption is ok! Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

21 Exact inference for two independent normal samples
Erik Parner Exact inference for two independent normal samples 24 April 2017 We now have a common standard deviation : s = sF = sM This is estimated as a “weighted” average This is not found in the Stata output Based on this we can calculate a revised/updated standard error of the difference: Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

22 Exact inference for two independent normal samples
Erik Parner Exact inference for two independent normal samples 24 April 2017 Exact confidence intervals and p-values are found by using a t-distribution with nM + nF - 2 = = 128 d.f. And the exact test: and find the p-value as We get p=2.2% (either from table of standard normal distribution, or from Stata) Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

23 Stata: two-sample normal analysis
Erik Parner Stata: two-sample normal analysis 24 April 2017 The F-test and t-test are easily done in Stata (more details can be found in the file day2.do). . cd "D:\Teaching\BasalBiostat\Lectures\Day2" D:\Teaching\BasalBiostat\Lectures\Day2 . use normtemp.dta, clear . * Checking the normality. . qnorm tempC if sex==1, title("Male") name(plot2, replace) . qnorm tempC if sex==2, title("Female") name(plot3, replace) . graph combine plot2 plot3, name(plotright, replace) col(1) Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

24 Basic Biostatistics - Day 2
Erik Parner 24 April 2017 . sdtest tempC, by(sex) Variance ratio test Group | Obs Mean Std.Err. Std.Dev. [95% Conf.Interval] Male | Female | combined ratio = sd(Male) / sd(Female) f = Ho: ratio = degrees of freedom = 64, 64 Ha: ratio < Ha: ratio != Ha: ratio > 1 Pr(F < f) = *Pr(F < f)= Pr(F > f)= Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

25 Basic Biostatistics - Day 2
Erik Parner 24 April 2017 . ttest tempC, by(sex) Two-sample t test with equal variances Group | Obs Mean Std.Err. Std.Dev. [95%Conf.Interval] Male | Female | combined diff | diff = mean(Male) - mean(Female) t = Ho: diff = degrees of freedom = 128 Ha: diff < Ha: diff != Ha: diff > 0 Pr(T < t) = Pr(|T| > |t|)= Pr(T > t)= Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

26 Exact inference for two independent normal samples
Erik Parner Exact inference for two independent normal samples 24 April 2017 What if you reject the hypothesis of the same sd in the two groups? This indicates that the variation in the two groups differ! Think about why!!! Often it is due to the fact that the assumption of normality is not satisfied. Maybe you would do better by making the statistical analysis on another scale, e.g. log. If you still want to compare the means on the original scale you can make approximate inference based on the t-distribution (e.g. ttest tempC, by(sex) unequal ) If you only want to test the hypothesis that the two distributions are located the same place, then can you use the non-parametric Wilcoxon-Mann-Whitney test – see later. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

27 Body temperature example - formulations
Erik Parner Body temperature example - formulations 24 April 2017 Methods: Data was analyzed as two independent samples from normal distributions based on the Students t. The assumption of normality was checked by a Q-Q plot. Estimates are given with 95% confidence intervals. Results: The mean body temperature was 36.9(36.8;37.0)C among women compared to 36.7(36.6;36.8)C among men. The mean was 0.16(0.02;0.30)C, higher for females and this was statistically significant (p=2.3%). Conclusion: Based on this study we conclude that women have a small, but statistically significantly higher mean body temperature than men. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

28 Example 7.2 Birth weight and heavy smoking
Erik Parner Example 7.2 Birth weight and heavy smoking 24 April 2017 Scientific question: Does the smoking habits of the mother influence the birth weight of the child? Design and data: (observational) The birth weight (kg) of children born by 14 heavy smokers and 15 non-smokers were recorded. Summary of the data (the units is kg): Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] Non-smok | Heavy sm | Already here we observe, that the average birth weight is smallest among heavy-smokers: difference=452 g Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

29 Example 7.2 Birth weight and heavy smoking
Erik Parner Example 7.2 Birth weight and heavy smoking 24 April 2017 Plot the data !!!!!! Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

30 Example 7.2 Birth weight and heavy smoking
Erik Parner Example 7.2 Birth weight and heavy smoking 24 April 2017 Independence, same distribution and normality seems ok. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

31 Example 7.2 Birth weight and heavy smoking exact inference
Erik Parner Example 7.2 Birth weight and heavy smoking exact inference 24 April 2017 Compare the standard deviations (using the computer): We accept that the two standard deviations are identical. and again by computer we get: Difference in mean birth weight: (0.138;0.767) kg Hypothesis: no difference in mean birth weight. p=0.06% Conclusion of the test: If there was no difference between the two groups, then it would be almost impossible to observe such a large difference as we have seen – hence the hypothesis cannot be true! Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

32 The birth weight example - formulations
Erik Parner The birth weight example - formulations 24 April 2017 Methods - like the body temperature example: Data ……intervals. Results: The mean birth weight was 3.627(3.428;3.825) kg among non-smokers compared to 3.174(2.907;3.442) kg among heavy smokers. The difference 452(138;767)g was statistically significant (p=0.06%). Conclusion: Children born by heavy-smokers have a birth weight, that is statistically significantly smaller, than that of children born by non-smokers. The study has only limited information on the precise size of the association. Furthermore we have not studied the implications of the difference in birth weight or whether the difference could be explained by other factors, like eating habits…… Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

33 Non-Parametric test: Wilcoxon-Mann-Whitney test
Erik Parner Non-Parametric test: Wilcoxon-Mann-Whitney test 24 April 2017 Until now we have only made statistical inference based on a parametric model. E.g. we have focused on estimating the difference between two groups and supplying the estimate with a confidence interval. We have also performed a statistical test of no difference based on the estimate and the standard error – a parametric test. There are other types of tests – non-parametric tests – that are not based on a parametric model. These test are also based on models, but they are not parametric models. We will here look at the Wilcoxon-Mann-Whitney test, which is the non-parametric analogy to the two sample t-test. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

34 Non-Parametric test: Wilcoxon-Mann-Whitney test
Erik Parner Non-Parametric test: Wilcoxon-Mann-Whitney test 24 April 2017 The key feature of all non-parametric tests is, that they are based on the ranks of the data and not the actual values. Smallest Number 17 and 18 Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

35 Non-Parametric test: Wilcoxon-Mann-Whitney test
Erik Parner Non-Parametric test: Wilcoxon-Mann-Whitney test 24 April 2017 We can now add the rank in one of the groups, here the heavy smokers: Heavy-smokers observed rank sum=150.5 Hypothesis: The birth weights among heavy-smokers and non-smokers is the same. Assuming the hypothesis is true one can calculate the expected rank sum among the heavy-smokers and standard error of the observed rank sum and calculate a test statistics: P-value = 0.9% The p-value is found as Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

36 Non-Parametric test: Wilcoxon-Mann-Whitney test
Erik Parner Non-Parametric test: Wilcoxon-Mann-Whitney test 24 April 2017 We saw that the ranksum among heavy smokers was smaller than expected if there was no true difference between the two groups. So small that we only observe such a discrepancy in one out of 100 (p-val=0.9%) studies like this. We reject the hypothesis! Conclusion Children born by heavy-smokers have a statistically significant lower birth weight than children born by non-smokers. Remember this depends on, the sample size, the design, the statistical analysis... Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

37 Non-Parametric test: Wilcoxon-Mann-Whitney test
Erik Parner Non-Parametric test: Wilcoxon-Mann-Whitney test 24 April 2017 Some comments: There are two assumptions behind the test: Independence between and within the groups. Within each group: The observations come from the same distribution, e.g. they all have the same mean and variance. The test is designed to detect a shift in location in the two populations and not, for example, a difference in the variation in the two populations. You will only get a p-value – the possible difference in location will is not quantified by an estimate with a confidence interval. As a test it is just as valid as the t-test! Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

38 Stata: Wilcoxon-Mann-Whitney test
Erik Parner Stata: Wilcoxon-Mann-Whitney test 24 April 2017 . use bwsmoking.dta,clear (Birth weight (kg) of 29 babies born to 14 heavy smokers and 15 non-smokers) . ranksum bw, by(group) Two-sample Wilcoxon rank-sum (Mann-Whitney) test group | obs rank sum expected Non-smoker | Heavy smoker | combined | unadjusted variance adjustment for ties adjusted variance Ho: bw(group==Non-smoker) = bw(group==Heavy smoker) z = Prob > |z| = Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

39 Basic Biostatistics - Day 2
Erik Parner Type 1 and type 2 errors 24 April 2017 We will here return to the simple interpretation of a statistical test: We test a hypothesis: d = d0 We will make a Type 1 error if we reject the hypothesis, if it is true. Type 2 error if we accept the hypothesis, if it is false. If we use a specific significance level, a, (typically 5%) then we know: The risk of a Type 1 error = a Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

40 Basic Biostatistics - Day 2
Erik Parner Type 1 and type 2 errors 24 April 2017 What about the risk of Type 2 error: This will depend on several things: The statistical model and test we will be using What is the true value of d ? The precision of the estimate. What is the sample size and standard deviation? That is, the risk of Type 2 error, b, is not constant. Often we consider the statistical power: Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

41 Statistical power – planning a study - testing for no difference
Erik Parner Statistical power – planning a study - testing for no difference 24 April 2017 Suppose we are planning a new study of fish oil and its possible effect on diastolic blood pressure (DBP). Assume we want to make a randomized trial with two groups of equal size and we will test the hypothesis of no difference. We believe that the true difference between groups in DBP is 5mmHg. Furthermore we believe that the standard deviation in the increase in DBP is 9mmHg. We plan to include 40 women in each group and analyze using a t-test. What is the chance, that this study will lead to a statistically significant difference between the two groups, given the true difference is 5mmHg? Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

42 Basic Biostatistics - Day 2
Erik Parner Statistical power, when the true difference is 5 and sd= 7,8,9 or 10 and we test the hypothesis of no difference. 24 April 2017 n=40 power=69% Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

43 Statistical power – planning a study
Erik Parner Statistical power – planning a study 24 April 2017 We plan to include 40 women in each group and analyze using a t-test and the true difference is 5mmHg and sd=9mmHg Power = 69% That is, there is only 69% chance, that such a study will lead to a statistical significant result - given the assumptions are true. How may women should we include in each group if we want to have a power of 90%? Based on the plot we see that more than aprox. 69 women in each group will lead to a power of 90%. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

44 Basic Biostatistics - Day 2
Erik Parner Statistical power, when the true difference is 5 and sd= 7,8,9 or 10 and we test the hypothesis of no difference. 24 April 2017 power=90% n=69 Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

45 Basic Biostatistics - Day 2
The power increases as a function of the expected difference between the groups and decreases as a function of the variation, standard deviation, within the groups Erik Parner 24 April 2017 Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

46 Power two unpaired normal samples
Erik Parner Power two unpaired normal samples 24 April 2017 In general we have the five quantities in play: If we know four of these, then we can determine the last. Typically, we know the first four and want to know the sample size. or we know d, s, a and n and then we want to know the power. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

47 Stata: power for two unpaired normal samples
Erik Parner Stata: power for two unpaired normal samples 24 April 2017 Power calculations are done using the sampsi command: . sampsi 0 5, sd1(9) sd2(9) alpha(0.05) power(0.90) Estimated sample size for two-sample comparison of means Test Ho: m1 = m2, where m1 is the mean in population 1 and m2 is the mean in population 2 Assumptions: alpha = (two-sided) power = m1 = m2 = sd1 = sd2 = n2/n1 = Estimated required sample sizes: n1 = n2 = * In Stata 13 * power twomeans 0 5 , sd(9) alpha(0.05) power(0.90) Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

48 By hand: power for two unpaired normal samples
Erik Parner By hand: power for two unpaired normal samples 24 April 2017 If the sample size is not too small then it can be found by hand by using the formula : Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014

49 Comments on sample size calculations
Erik Parner Comments on sample size calculations 24 April 2017 Most often done by computer (in Stata sampsi) There are many different formulas see Kirkwood & Stern Table We will only look at a few in this course. It is in general more relevant to test that the difference is larger than a specified value. A so-called Superiority or Non-inferiority study. Or to plan the study so that your study is expected to yield a confidence interval with a certain width. You need to know the true difference and you must have an idea of the variation within the groups. The latter you might find based on hospital records or in the literature. Sample size calculations after the study has been carried out (post –hoc) is nonsense!! The confidence interval will show how much information you have in the study. Basic Biostatistics - Day 2 Basic Biostatistics - Day September, 2014


Download ppt "Basic Biostatistics - Day 2"

Similar presentations


Ads by Google