Wednesday, 5 December 2018

ANOVA 101

G'day, it's been a while.

This one will not be like my usual logs, but I do hope it is useful.

One of the thing men of science need to do is research, but quite often people obtain a lot of data from multiple samples and multiple treatments. I thought of it and commonly they wanted to know if different treatments are the same or different from one another. This can be done with an analysis of variance, which is tedious if you have to do it with a pen and a sheet of paper, so I thought of seeking a more "updated" method to clear this up.


Be aware that this program requires a lot of coding for the script input.

Getting started,
define the random variable and hypotheses of the analysis of variance, let's say
X would be the j-th data observed from the i-th treatment.

The hypotheses, the nil hypothesis basically is when there are no differences between the treatments based on the variance of each, and for the counterpart hypothesis, there would be at least one average of a treatment that is significantly different.

You don't need to "link" a separate data sheet, you can also put them manually should it be not that many.

In this case, let's say I have k treatments and n observations for each, create a matrix for them. Name the table with anything define the matrix as the Predictor. Insert the values as if it is a table, but sideways on the script. Define the number of rows (downwards), and columns (sideways). Pay attention to those commas.

Name the transformed data with anything you like. Input the Compiled Table and transform it as a matrix. Remember to input the name of the table the last. Do not forget the compilation and table notation.

Define new variables for the treatments and the amount of observations/samples. The variable factors for each treatment you can name them with anything, and compile them. Determine how many treatments, observations per treatment, and all observations there are. You can use any letters to code it. Do not forget the compilation notation. Determine the 1st and 2nd degrees of freedom. The first is the number of treatments subtracted with one, and the second is the amount of all observations subtracted with the amount of treatments. Make the treatment factors is compatible with the data vector. You will need the number of treatments, 1 to signify difference, the whole number observations and the factors you have listed on the first step. get lit.
Create the Analysis of Variance summary table. Determine the variable for the analysis of variance you're getting. Input the code and connect the data vector and the factor vector with a tilde and summarise it. Compare the obtained F value from prior step with a critical F. For the latter, you'll need the alpha, degree of freedom 1, and degree of freedom 2 for the inputs. Do not forget the compilation notation. Compare the F value and critical F. Note that if F value > critical F and P-value < alpha, H0 is not supported, thus showing difference between treatments. The vice versa works as well if treatments results showed no differences.

Quite often, linear regression is also often used. I'll cover that on the next post.

No comments:

Post a Comment