setwd("C:/Courses/STA4502/2009-Fall/R/") data(swiss); swiss x <- swiss$Infant.Mortality # ============================= # Binomial Test for Quantiles # ============================= ## Conover (1971), p. 97f. ## Under (the assumption of) simple Mendelian inheritance, a cross ## between plants of two particular genotypes produces progeny 1/4 of ## which are "dwarf" and 3/4 of which are "giant", respectively. ## In an experiment to determine if this assumption is reasonable, a ## cross results in progeny having 243 dwarf and 682 giant plants. ## If "giant" is taken as success, the null hypothesis is that p = ## 3/4 and the alternative that p != 3/4. binom.test(c(682, 243), p = 3/4) binom.test(682, 682 + 243, p = 3/4) # ======================== # RUNS TEST FOR RANDOMNESS # ======================== # YOU NEED INSTALL THE lawstat PACKAGE FIRST. library(lawstat) runs.test(x, plot.it=T, alternative="two.sided") y = arima.sim(n = 20, list(ar = c(0.5))); y; median(y) cbind(y=round(y,2), g.l=sign(y