mountain_sn
mountain_sn

Reputation: 53

how to calculate variance between means in r

I think this is not a difficult question, but I just got stuck. For two independent datasets (vectors), original values x and predicted values y, I use t-test(x,y,var.equal) to calculate the mean values of these two datasets. How to calculate the difference between the means? |mean of x - mean of y|/|mean of x| or |mean of x - mean of y|/|mean of y|? Thanks for your help.

Upvotes: 0

Views: 105

Answers (1)

IF.Francisco.ME
IF.Francisco.ME

Reputation: 146

So first asuming this as your data:

x: original values x1,x2,x3...xn

y: predicted values y1,y2,y3...yn

then simply:

VarmeansX <- var(x)
VarmeansY <- var(y)

so you have in VarmeansX and VarmeansY the variance of each data samples, so in order to know what is the difference just do

VarBetween <- VarmeansX - VarmeansY

so you will have a positive or negative number, if the case is the first then the variance in your original values is greater than the predicted values,etc.

Upvotes: 1

Related Questions