{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# SolHW1 - ﬁndings Assuming normalityy of the measurements...

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

Page 1 STAT 406: HW1 1. The iris data set is a well known data set available within R. It gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 ﬂowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. a. Load the data set in a variable. How many records (rows) in the data set has a missing data? A simple visual count will give you no credit. dt=iris nRows=sum(!complete.cases(dt)) # complete.cases returns rows with #missing data and ’!’ is the negation operator b. Use a boxplot to compare the petal length of the three species of Iris. Present the three boxplots in a single ﬁgure. boxplot(dt,names=c(’setosa’, ’versicolor’, and ’virginica’)) c. Looking at the species two by two, perform a two-sample t -test to compare the mean petal lengths. State your assumptions and

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ﬁndings. Assuming normalityy of the measurements: test12=t.test(dt[,1],dt[,2]);test13=t.test(dt[,1],dt[,3]); test23=t.test(dt[,2],dt[,3]); In all three tests, we reject the hypothesis of equality of means. 2. Suppose U 1 and U 2 are uniformly generated. Someone claims that that the random value Z = p-2log( U 1 )cos (2 πU 2 ) , Page 2 has a standard normal distribution. Without using a ”for” loop, write an R code to generate 10 , 000 such values Z . Use these values to ﬁll up the following table and assess whether it appears to behave like a normally distributed value. Use a normal qqplot as an alternative approach to validate that claim. n=10000 U1=runif(n);U2=runif(n) Z=sqrt(-2*log(U1))*cos(2*pi*U2) p1=sum(Z>=0)/n; p2=sum((0<Z)&(Z<=1))/n p3=sum((1<Z)&(Z<=2))/n; p4=sum(Z>2)/n...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

SolHW1 - ﬁndings Assuming normalityy of the measurements...

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

View Full Document
Ask a homework question - tutors are online