F test error with command

After writing the command

var.test(vari1, vari2)

comparing my variances I obtained the error :


I am unable to find out how to fix this.

this stack question wasn't the solution

What is the result of running


Please post the output of that command.

@FJCC My results are:


It appears my object is 'not found'

What code assigns a value to vari1? Can you show a complete example of making vari1 and vari2 and then running var.test()?

@FJCC Yes, my code is the following:

vari1 <- var(med_vect)
vari2 <- var(placebo_vect)
vari3 <- var(recup_vect)
# Comparaison
var.test(vari1, vari2)

I initialized my vectors with vect <- c(...).

You cannot use the calculated variances in var.test(). You should give var.test() the data vectors. Here is an example that reproduces your error and also successfully does the calculation.

 #Invent some data
med_vec <- rnorm(30)
placebo_vec <- rnorm(30)

#Calculate the variance
vari1 <- var(med_vec)
vari2 <- var(placebo_vec)

#Cannot test just the variance values
var.test(vari1, vari2)
Error in var.test.default(vari1, vari2) : not enough 'x' observations

#It works to test the data vectors
var.test(med_vec, placebo_vec)

	F test to compare two variances

data:  med_vec and placebo_vec
F = 1.4777, num df = 29, denom df = 29, p-value = 0.2987
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
 0.7033488 3.1047106
sample estimates:
ratio of variances 

Also, you do not need to initiate vectors with c(). A simple assignment of a value is enough.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.