STA 291-013 Spring 2000 Computer assignment 6 Due April 18 ================================================================= Hand written your name and student id on the first page. Also type your name once you are inside R, #Name.......ID...... Problem 1: Page 466. Application Notice the sample size here is 35 and that's marginally a large enough sample to use Z table (instead of a t table). So please still use the t-table and the t.test function in R. (Since in most cases, we do not know sigma and will be using s to replace sigma, there is no harm to use t.test even when sample size is large) (a) and (b) Problem 2: Suppose in 1200 randomly selected households, 589 have Kenmore appliances. The hypothesis to be tested are Ho: p=0.5 Ha: p < 0.5 (a) Compute the P-value. (b) If we use a significance level of 0.03 (alpha), what is your conclusion? [end of assignment] ============================================================================ One sample t-test: First put your data in a vector called data6 (a possible example: > data6<-c(33.9, 52.4,48.6, 53.5, 43.8) remember quiz?) To test (actually just to get p-value) Ho: mu=46.5 Ha: mu<46.5 (less than) based on the data in data6, you do > t.test(data6, alternative="less", mu=46.5) The other possible alternatives are: "greater" and "two.sided" In addition to the P-value this also computes a 95% t-confidence interval ============================================================================ The function t.test can also do two-sample t-tests. Suppose you have two (not paired) samples stored in vectors called xbefore and xafter then do > t.test(x=xbefore, y=xafter, alternative="less", mu=0, paired=F) If the data are actually paired, then change paired=F to paired=T. Therefore, t.test() can be used in 3 different cases: 1). one sample t-test 2). 2 sample paired t-test 3). 2 sample not paired t-test case. ============================================================================ One sample proportion test: Suppose your sample has 600 success in 1000 trials. To test if the success propability is equal to 0.5 (actually just to get P-value) Ho: p=0.5 Ha: p not= 0.5 (not equal) you do > prop.test(600, n=1000, p=0.5, alternative="two.sided") The other possible alternatives are: "less" and "greater" In addition to p-value this also computes a 95% confidence interval =========================================================================== For further info on the use of t.etst( ) and prop.test( ) please see the online help page that comes with R: ?t.test ?prop.test =========================================================================== If you are using a newer verson of R, then do > library(ctest) # load the library ctest > binom.test(600, n=1000, p=0.5, alternative="two.sided") Binom.test is similar to prop.test. The difference is that prop.test uses approximate computation, while binom.test uses exact computation [but prop.test can be used to test several samples].