TAMS38 Computer exercises 4 Preparation: Read about different models and analysis, especially about the choice of the sample size, regression, response surface and logistic regression. Do assignments 5b), 6a,f) before the computer exercise class. Bring collection of formulas and tables, and calculators to the computer exercise class. 1 Analysis using response surface The following data set provides data for the final attempt in a experiment via the steepest ascentmethod to find the optimal values of ph and temperature for a chemical reaction. Purity data from uniform-precision rotable Central Composite Design x 1 x 2 Temp. ph Purity Y Factorial -1-1 53 5.0 90.1 portion +1-1 55 5.0 91.8-1 +1 53 5.8 90.7 +1 +1 55 5.8 93.6 Centre 0 0 54 5.4 94.1 portion 0 0 54 5.4 94.6 0 0 54 5.4 94.2 0 0 54 5.4 93.9 0 0 54 5.4 94.0 Axial -1.414 0 52.59 5.4 89.0 portion +1.414 0 55.41 5.4 92.3 0-1.414 54 4.83 90.7 0 +1.414 54 5.96 92.5 Do we have curvature using analysis according to 2 2 -design with five observations in the central point? 1
Go to STAT/DOE/Factorial/Create Factorial Design... Choose amount of factors as 2. Click on Designs and choose Number of Center Points: 5. Put in the nine y-values in c7 in the correct order by looking on the levels of factors A and B. Name column c7 as Y. Wait with the four extra points. Go to STAT/DOE/Factorial/Analyze Factorial Design... In Response set c7. a) Perform tests of curvature at the level 0.01. Conclusion? Rename c5 and c6 as x1 and x2. Fill with extra points in the c5-c7. Then, create new columns by typing in the session window let c8=c5*c6 let c9=c5**2 let c10=c6**2 b) Rename new column as x1*x2, x1**2 and x2**2. You can now fit a quadric surface to your data. Go to Stat/Regression/Regression and fill Response: c7, Predictors: c5 c6 c8-c10. c) Is it possible, using this quadric surface, to find an optimum point? Calculate the values of x1 and x2 for the optimum point and recalculate them to the actual temperature and the actual ph. d) It might be nice to watch how the fitted quadratic surface looks. Go to Calc/Make Mesh Data... Put x1-values in c11 from -1.5 to 1.5 with 21 points and x2-values similarly in c12 (not for Z). As Z-function you should put the estimated regression expression. Write in the session window let c13=...+...*c11+...*c12+...*c11*c12... Fill in the correct coefficients from the regression analysis and remember to put all the terms. Go to Graph/3D Surface Plots/Wireframe plot and fill in Z: c13 Y: c12 X: c11. What you have obtained? 2
2 Determination of sample size under normal distribution A team of researchers want to study whether regular exercise can increase in bone mineral content in young women. One thinks to select n young women, measure their bone mineral content, allowing them to practice according to a certain program for six months and then re-measuring the mineral content in the bones. Let x i and y i stands for their mineral content (unit:%) before and after the training. Then z i = y i x i stands for the change. Previous measurements have shown that it is reasonable to assume that Z i N(µ, 4). We want to test H 0 : µ = 0 against H 1 : µ 0 on level 0.05, such that the power of the test is at least 0.90 if µ = 2. How should we choose n? a) Go to Stat/Power and Sample Size/1-sample Z. Fill in Differences: 2 Power values: 0.90 Standard deviation: 4.0 Click on Options and choose Alternative Hypothesis: Not equal samt Significance level: 0.05. Click on Graphs: and choose Display Power Curve. Then OK. Give n 1 =....... b) Repeat procedure as for the one sided test. Give n 2 =....... c) Determine power of the two-sided test on n = 25 using the same Minitab procedure. Power:....... d) Redo part a) using 1-sample t. Give n 3 =....... 3 Sample size under binomial distribution a) In the treatment of a chronic disease with an old proven drug 20% of patients experience a clear relief. One has developed a new drug and it is hoped that along with the traditional treatment will help more patients. 3
By allowing n patients to try the new combination therapy and find out how many people feel an improvement we would test the following hypothesis H 0 : p = 0.2 against H 1 : p > 0.2 on level 0.01. Moreover we want to have power of the test 0.99 if p = 0.4. Determine n using Stat/Power and Sample Size/One proportion with right H 1. Give n a =....... Look at the power function. b) Solve exercise 60 from Problem book, using Stat/Power and Sample Size/Two proportions. Give n b =....... 4 Sample size under one factor analysis Solve exercise 3-44 in Design and Analysis of Experiments Montgomery, using Stat/Power and Sample Size/ Oneway ANOVA. Give n =....... This is inconsistent with our old earnings, which is due to Minitab works with pairwise comparisons between µ i and µ j, while we have discussed F-test for H 0 : µ 1 =... = µ 4 on level 0.05. 5 Logistic regression, mixed model In 1974 and 1975 two studies have been done National Opinion Research Center, University of Chicago, Illinios where people s attitude towards women is considered. Each would be asked to consider the following statement: Women should take care of running their homes and leave running the country up to men. Observations from 1305 men and 1566 women are summarized in the table below. 4
Amount Men, j = 1 Women, j = 2 year of education, k positive negative positive negative 0 4 2 4 2 1 2 0 1 0 2 4 0 0 0 3 6 3 6 1 4 5 5 10 0 5 13 7 14 7 6 25 9 17 5 7 27 15 26 16 8 75 49 91 36 9 29 29 30 35 10 32 45 55 67 11 36 59 50 62 12 115 245 190 403 13 31 70 17 92 14 28 79 18 81 15 9 23 7 34 16 15 110 13 115 17 3 29 3 28 18 1 28 0 21 19 3 13 1 2 20 3 20 2 4 The above data are available to download on the course website. After a quick look at the data, it seems that the longer the education, the lower proportion of positive to the statement. We will now analyze the data using logistic regression and answer some questions about the length of training and gender are important. We choose the dummy variable { 0 om j = 1 (men) z j = 1 om j = 2 (women) to separate two groups men and women. Put columns y jk for the positive, x jk for the negative, dummy variable z j and amount of the education years k. There is also a column for the total number n jk = y jk + x jk respondents for each sex j and years of education k. Create a column with the percentage of positive answers ˆp jk = y jk /n jk. a) Plot the proportion of the positive answers ˆp jk against the years of education k. Choose Graph/Scatterplot/With Gropus so that we can see the difference between men and women. b) Write down model where the constant term and slope can be different for those two groups (logit p jk =...). Use the dummy variables to separate groups. (Hemuppgift) 5
Do the logit-analysis for the given model with dummy variables. Go to Stat/Regression/Binary Log... c) What are the parameters of your model that are significant? Are you satisfied with deviance? D =......... P =......... Conclusions? Non-mandatory exercise En anledning till att modellen inte är så bra kan vara att vissa celler har färre än tio observationer och påverkar resultatet mer än vad som är önskvärt. Ett sätt att hantera denna problematik skulle kunna vara att helt enkelt ta bort dessa observationer. Gör om analysen för samma modell men där alla observationer som är tio eller färre per cell är bortagna. Kopiara all data i datafönstret till nya kolumner och ta bort de som ej ska ingå (alla där n 10). Gå in under Stat/Regression/Binary Log... och gör en ny analys med de nya kolumnerna. d) Vilka parametrar i din modell är signifikanta? Är du nöjd med deviansen? D =......... P =......... Slutsats? 6 Use of dymmy variables in the additive model (non-mandatory exercise) Vid tillverkning av tvål görs en kvalitetsklassning av tvålens utseende enligt en skala från 1 till 10, ju högre värde desto bättre. Man tror att skillnader mellan operatörer samt hastigheten på produktionslinjen har betydelse. Resultat: 6
Appearance Operator Line Speed (Sum for 30 Bars) 1 150 255 1 175 246 1 200 249 2 150 260 2 175 223 2 200 231 3 150 265 3 175 247 3 200 256 Genomför en regressionsanalys svarande mot en additiv tvåfaktormodell genom att utnyttja förklaringsvariablerna { { 1 för operatör 1 1 för operatör 2 x 1 =, x 0 annars 2 =, 0 annars { { 1 för hastighet 1 1 för hastighet 2 z 1 =, z 0 annars 2 =. 0 annars Lägg in data i datafönstret och skriv in variabelnamnen i namnraden. Kalla den aktuella responsvariabeln för Y. Gå in under Stat/Regression/Regression och beställ en regressionsanalys med Y som responsvariabel och x 1, x 2, z 1, z 2 som prediktorer. Under Graphs beställer du plott av residualerna mot de skattade väntevärdena (fits) samt normalfördelningsplott av residualerna. Under Storage beställer du lagring av (X X) 1. Ta sedan OK. Titta överst i analysen var (X X) 1 har hamnat och skriv i sessionsfönstret print m1 om den finns i m1. a) Ställ upp den aktuella modellen. (Hemuppgift) b) Gör konfidensintervall för samtliga β-koefficienter vart och ett med konfidensgrad 95%. Finns det påvisbara skillnader mellan operatörer? c) Vilka parametrar beskriver skillnaden mellan hastighet 1 och 2? Punktskatta den? d) Titta på residualplottarna. e) Skapa två kolumner med nivåer för operatör respektive hastighet. 7
Gå in under Stat/ANOVA/Balanced ANOVA och genomför en analys enligt en additiv tvåfaktormodell med lagring av medelvärden för de olika faktorerna (beställs under Results). f) Ställ upp modellen. (Hemuppgift) g) Skatta skillnaderna i kvalitetsbedömningen mellan hastigheterna och jämför med motsvarande parameterskattningar i c). h) Kan vi rekommendera någon hastighet? Konstruera lämpliga konfidensintervall med simultan konfidensgrad exakt 90%. 7 Power for t-test (non-mandatory exercise) Låt x 1,..., x n vara observationer från N(µ, σ). Vi kan då pröva hypotesen H 0 ; µ = 5 mot H 1 : µ 5 med teststorheten w = x 5 s/ n. H 0 förkastas om w > t, där t ges i t(n 1)-tabell av villkoret F (t) = 0.975, då testet har nivån 0.05. Vi ska dels studera signifikansnivån, d v s P ( W > t om µ = 5), dels testets styrka då µ = 6, dvs. P ( W > t om µ = 6). Styrkan beror inte bara på det alternativa µ-värdet utan även på standardavvikelsen σ. Styrkeberäkningar är bl a intressanta då man planerar en undersökning och vill kunna bedöma hur många mätningar som behövs. För t-testet är det besvärligt att räkan på styrkan för hand och då har man nytta av simuleringar. a) Rensa fönsterna. Gå in under Calc-Random data-normal distribution och generera 1000 rader i c1-c16 med väntevärde 5 och standardavvikelse 1.2. I varje rad har man sedan 16 observationer från N(5, 1.2). Ta sedan Calc-Row Statistics, välj alternativet mean med Input Variables c1-c16 och lagra i c17. Ta sedan Calc-Row Statistics, välj alternativet stdev med Input Variables c1-c16 och lagra i c18. Beräkna teststorhetens värde för varje rad genom att skriva i sessionsfönstret let c19 = (c17-5)/(c18/4) För att få fram t-värdet kan man gå in under Calc-Probability Distribution-t; välj Inverse cumulative probability. Fyll också i Noncentrality parameter: 0.0, frihetsgrad och Input constant: 0.975. Skriv i sessions-fönstret let k1 =... let c20 = c19 < -k1 8
let c21 = c19 > k1 sum c20 sum c21 Då är sum c20 + sum c21 =......... antalet gånger nollhypotesen förkastats. Stämmer denna summa med vad ni väntade er med hänsyn till signifikansnivån? b) Rensa datafönstret, men inte sessionsfönstret. Gör om proceduren med data från N(6, 1.2). OBS! Ni ska fortfarande pröva H 0 : µ = 5. med samma teststorhet w. Med hjälp av y = sum c20 + sum c21 kan man beräkna ett approximativt värde y/1000 =......... på styrkan för µ = 6. Är ni nöjda med styrkan? c) Bestäm också styrkan genom att utnyttja lämplig rutin under Stat/Power and Sample Size. Styrkan blir......... 9