Stat3022 hw4

# Stat3022 hw4 - Stats3022 HW4 Yutong Gao 4.20 >dat <-

This preview shows pages 1–3. Sign up to view the full content.

Stats3022 Yutong Gao HW4 4.20 >dat <- read.table("http://www.stat.umn.edu/~yixxx064/hw/ex0318.txt", header=T) >attach(dat) > nTrial=1000 > a=dat[,1] > leng=length(a) > rd=NULL > for (i in 1:nTrial) { + T=sample(leng,7) + N=setdiff(1:leng,T) + y1=a[T] + y2=a[N] + rd[i]=mean(y1)-mean(y2) + } > hist(rd) > names(dat) [1] "expenditure" "trauma" > nt<-expenditure[trauma=="no"] > yt<-expenditure[trauma=="yes"] > t.test(nt,yt,varequal=F) Welch Two Sample t-test Histogram of rd rd Frequency -5 0 5 0 60 140

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
data: nt and yt t = -2.9701, df = 6.428, p-value = 0.02299 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -14.139773 -1.478084 sample estimates: mean of x mean of y 20.96250 28.77143 > sum(rd>=-2.9701)/nTrial [1] 0.808 Based on the graph, we can see that the difference between averages of two groups are approximately normality, even almost symmetric. We got the observed t-test value from R, and compared it to the regrouping groups. The p-value we've got is 0.808.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/28/2012 for the course ECON 111 taught by Professor Aaa during the Summer '11 term at UIBE.

### Page1 / 3

Stat3022 hw4 - Stats3022 HW4 Yutong Gao 4.20 >dat <-

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online