I am wanting to find the correlation between two variables: a categorical vegetation variable (with categories 1-4) and a continuous variable of erosion (with values anywhere between 0.2 and 9). I think I would be required to use a non parametric test to find the correlation, but bit of a newby to stats so could anyone suggest the best test to use? I also wanted to know how sample size can affect these tests, ie with a sample size of 100 or 1000?
I agree with @John's answer but would also suggest simply plotting boxplots of erosion for each vegetation category. If the vegetation variable actually has a ordinal interpretation then we could draw some exploratory conclusions about correlations between vegetation and erosion. For example, consider the following fictional data and corresponding box plot.
So as you can see from the box plots, there would appear to be a positive correlation (or association if you prefer that jargon) between erosion and vegetation level. (Of course this argument requires vegetation categories have an ordinal meaning)
Here is the code to generate this in
R although I know you didn't ask for it and clearly one of your tags is for
#Pseudo Data N = 10000 erosion = runif(N,0,10) vegetation = rep(1,N) vegetation[erosion > 2.5 & erosion <= 5] = 2 vegetation[erosion > 5 & erosion <= 7.5] = 3 vegetation[erosion > 7.5 & erosion <= 10] = 4 boxplot(erosion~vegetation,col=c("blue","red","green","orange"), xlab="Vegetation",ylab="Erosion")
You could calculate a $\chi^2$ and the $\Phi$ coefficient measure as a substitute for correlation. $\Phi$ would have a similar interpretation to a Pearson correlation coefficient but should really only be used in 2x2 designs. In your case you should probably go with a Cramer's V which is standardized but doesn't quite have the correlation style interpretation. There is no nonparametric comparable linear correlation because one of your variables is purely categorical. Those numbers 1-4 labelling your categories could be arbitrarily reassigned to different categories and it wouldn't affect the true relationship but it would affect something like a Spearman correlation coefficient.
Unfortunately, the above tactic wouldn't really treat your continuous variable fairly. Another way to get a correlation(ish) value is to perform an ANOVA with your continuous variable as response and categorical as predictor and then calculate $\eta^2$ (eta-squared) effect size measure. That effect size has an interpretation that's similar to $R^2$.
Your second query about sample size has a fixed answer for all tests and estimates. The larger the sample, the more likely the test is to be significant. Increasing sample size increases the accuracy of your effect estimates ($\Phi$ or $\eta^2$, or any parameter estimates you're making).