Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Program2.Question2
#MATRIX TWO kicker<-matrix(c(22,4,10,6),ncol=2,byrow=T);kicker dimnames(kicker)<-list(Strategy=c("No Time-Out","Time-Out"),FielgGoal=c("Success","Failure")) kicker rtot<-apply(kicker,1,sum);rtot ctot<-apply(kicker,2,sum);ctot kicker.test<-prop.test(kicker) kicker.test$estimate p1<-kicker.test$estimate[1] p2<-kicker.test$estimate[2] alpha<-0.05 ##Wald Confidence Intervals se<-sqrt((p1*(1-p1)/rtot[1])+(p2*(1-p2)/rtot[2])) print("The Wald Confidence Interval:") exp((p1-p2)+c(-1,1)*1.96*se) var.wald<-p1*(1-p1)/rtot[1] + p2*(1-p2)/rtot[2] print("The Wald Confidence Interval 2 :") p1-p2+qnorm(p=c(alpha/2,1-alpha/2))*sqrt(var.wald) ##Agresti-Caffo Confidence Intervals print("SUM:") n<-sum(kicker);n pit1<-(kicker[1,1]+1)/(kicker[1,]+2) pit2<-(kicker[2,1]+1)/(kicker[2,]+2) var.AC<-pit1*(1-pit1)/(kicker[1,]+2) + pit2*(1-pit2)/(kicker[2,]+2) pit1-pit2+qnorm(p=c(alpha/2,1-alpha/2))*sqrt(var.AC) ##Score Test ##Pearson Chi-Sqaured Test #chisq.test(kicker) chisq.test(kicker,simulate.p.value=2,B=10000) ##Likelihood Ratio Test aka Gsqaure test #g.test(kicker) n<-sum(kicker);n mu<-rtot%*%t(ctot)/n;mu #matrix multiplication df<-(nrow(kicker)-1)*(ncol(kicker)-1);df print("The LRT test statistic:") g<-2*sum(kicker*log(kicker/mu));g print("The P-Value of the G^2:") pval<-1-pchisq(g,df);pval ##Relative Risk and RR Confidence Interval print("The Relative Risk:") rr<-kicker.test$estimate[1]/kicker.test$estimate[2];rr ##Relative Risk## se<-sqrt(((1-p1)/rtot[1]*p1)+((1-p2)/rtot[2]*p2)) logrr.ci<-log(rr)+c(-1,1)*1.96*se print("95% Relative Risk Confidence Interval:") exp(logrr.ci) ##Odds Ratio and OR Confidence Interval odds<-kicker.test$estimate/(1-kicker.test$estimate);odds odds[1]/odds[2] ##odds ratio (kicker[1,1]*kicker[2,2])/(kicker[2,1]*kicker[1,2]) kicker print("The Odds Ratio:") theta<-odds[1]/odds[2];theta ase<-sqrt(sum(1/kicker));ase logtheta.ci<-log(theta)+c(-1,1)*1.96*ase logtheta.ci print("The 95% Odds Ratio Confidence Interval:") exp(logtheta.ci)
run
|
edit
|
history
|
help
0
CDF- Gaussian (trapezoids method)
Double Pendulum with euler (copy and past on your computer)
Outlier
Football weights
,k
print name and age
Julia set
Ass2 q2
BasicPlot
MSS PS: Introduction to R