...

/

Solution: Conduct a Series of One-way ANOVAs

Solution: Conduct a Series of One-way ANOVAs

Let's look at the solution to the previous exercise.

Solution

As always, let’s look at the structure to make sure everything looks good.

R
str(RxP.byTank)

Check the distribution

Let’s check the best distribution to use for the final Mass data. We’ll first examine the raw and log-transformed histograms. Then, we’ll test the distributions using the fitdistr() function from the MASS package.

R
plot1<-qplot(data=RxP.byTank, x=Mass.final, ylab="occurrences", geom="histogram")
plot2<-qplot(data=RxP.byTank, x=log(Mass.final), ylab="occurrences", geom="histogram")
plot_grid(plot1,plot2)

The log transformation appears to help a bit, at least graphically. Let’s see the use of the fitdistr() function:

R
fit1<-fitdistr(RxP.byTank$Mass.final, "normal")
fit2<-fitdistr(RxP.byTank$Mass.final, "lognormal")
AIC(fit1,fit2)

Indeed, log transformation helps improve the normality of the data. Now, let’s hard code a log-transformed version of the data.

RxP.byTank$log.Mass.final<-log(RxP.byTank$Mass.final)

Now, we’re ready to do some analyses! ...