R-lab 2 -Dorji Pelzom
Basic Statistical Functions THE MUST KNOW’s Total sum: sum() Mean: mean() Column means: colMeans() Median: median() Variance: var() Covariance matrix: cov() Correlation between two variables: cor() Standard deviation: sd() Maximum: max() Minimum: min() Range: range() Quantile: quantile() Summary: summary() Always refer to the help files if you are not sure about the function by typing ?function name! For example > ?summary
To plot OC curve p<-c(0,..............................,0.3) OC<-phyper(c(...),m=floor(....*p),n=.....-floor(.....*p), k=....,lower.tail=TRUE) plot(p,OC)
Lab 3
Q1B P<-c(0,. ,0. 4) OC<-phyper(c(. ),m=floor(. p),n=. -floor( Q1B P<-c(0,..............................,0.4) OC<-phyper(c(...),m=floor(....*p),n=.....-floor(.....*p), k=....,lower.tail=TRUE) Plot(P,OC) Q 2 A P<-c(0,………………………………,0.4) Pi<-phyper(c(...),m=floor(....*p),n=.....-floor(.....*p), k=....,lower.tail=TRUE) + 1 -phyper(c(...), m=floor(....*p), n=.....-floor(.....*p), k=....,lower.tail=TRUE) Plot(P, Pi) Q2B ASN <- 20*Pi + 40*(1-Pi) Plot(P, ASN)
Lab 4
For entering data directly Dataset <- edit(as.data.frame(NULL)) for mac For windows choose Data -> New data set
1 (B) For z-values type qnorm()
Q 1© P <- c(0.001, 0.005, 0.007, 0.01, 0.02, 0.03, 0.06, 0.09, 0.12, 0.15, 0.18) Z <- qnorm(p, mean = 0, sd = 1, lower.tail = TRUE) OC <- 1 - pnorm(4.472*(Z+2.93), mean = 0, sd = 1, lower.tail = TRUE) plot(p, OC)
Good luck with the lab