Reputation: 1
What I entered in the console (alp, DF1, DF2 are defined):
LT <- left.tail=FALSE
q <- qf(alp, DF1, DF2, LT)
q
What I got:
LT <- left.tail=FALSE
Error in LT <- left.tail = FALSE : could not find function "<-<-"
> q <- qf(alp, DF1, DF2, LT)
> q
[1] 0.4490486
The answer I am looking for is 2.22, which I get when the Lower Tail is defined as false.
Why is it telling me that "<-<-" is not avaible, I did not write this function? And is there a way to store a TRUE/ FALSE value for lower.tail?
For further explanation, I am trying to write a code where I simply have to enter the values on the top and get the answer out of it:
data.entry(1)
a1 <- mean(var2)
v1 <- var(var2)
SD1 <- sd(var2)
n1 <- max(n)
a2 <- mean(var3)
v2 <- var(var3)
SD2 <- sd(var3)
n2 <- max(n)
int <- 1-0.9 #given interval
LT <- FALSE #Right Tailed- H1: >/ =/=
TT <- 0 #Two Tailes- H1: = / =/=
alp.O <- 0.1 #Given Alpha
alp <- alp.O/(1+TT)
DF1 <- n1 - 1
DF2 <- n2 -1
q <- qf(alp, DF1, DF2, left.tail=LT) #ALP, DF1, DF2
f <- q-2*q*RT #t-Critical Value - Rejection Level
F <- v1/v2 #Parameter of Interest1 / Parameter of Interest2
print(F==f)
print(F>f)
print(F<f)
It's not done yet and there are some residuals from older code, please ignore them.
Upvotes: 0
Views: 1229
Reputation: 12155
In R, you can assign using 2 different operators: <-
and =
.
That is, if you want to assign the value of 3 to the variable x
, you can write either x<-3
or x=3
.
When you write: LT <- left.tail=FALSE
, instead of testing whether left.tail
is FALSE (which you'd do with the comparison operator ==
) you're setting up a double assignment – that is, assigning the value FALSE
to left.tail
and LT
. You can actually do that if you use the same operator: x=y=4
or k<-d<-5
both work as expected. If you mix these operators, though, you get an error.
I'm not exactly sure what is going on behind the scenes to generate the function <-<-
, but I do know it's a result of R trying to deal with combining the 2 different assignment operators in a single expression. If you do want to do the double assignment, just use the same operator:
LT <- left.tail <- FALSE
In your case, I don't think you want to do a double assignment. Likely, you want to test if left.tail
is FALSE, and store that result in LT
. You can do that in a few ways:
# Tests for only FALSE values
LT <- left.tail==FALSE
LT <- isFALSE(left.tail)
# Tests for "falsy" values like 0
LT <- !left.tail
Upvotes: 0
Reputation: 18487
The correct way to do this is
qf(p = alp, df1 = DF1, df2 = DF2, lower.tail = FALSE)
Note that qf(alp, DF1, DF2, FALSE)
passes FALSE
to the fourth argument of qf()
, which is ncp
and not lower.tail
.
Upvotes: 0
Reputation: 44788
This looks to me like a parser oddity in R. The expression
LT <- left.tail=FALSE
is parsed as
(LT <- left.tail) = FALSE
which is the same as
`<-`(LT, left.tail) = FALSE
which is the same as
`<-<-`(LT, left.tail, FALSE)
which is where your error message came from.
I call this an oddity, because I would have expected it to be parsed the same as
LT <- left.tail <- FALSE
which assigns FALSE
to left.tail
and then to LT
.
Upvotes: 3