Consistent Error with t tests

1,743 views
Skip to first unread message

Ben

unread,
Jan 25, 2011, 10:16:56 PM1/25/11
to Deducer
Hi Ian

First of all i *love* your program. Honestly prefer it to SPSS and
also much nicer than Rcmdr. Well done.

Using Analysis>Two Sample Test for a data set I am unable to get a
t.test or wilcox.test. Here's some example output (R version 2.11.1);

> print(two.sample.test(formula=d(bDWG) ~ bConcord,
+ data=d.sub,
+ test=t.test,
+ alternative="two.sided")
+ )
Error in tests[[2]] : subscript out of bounds
In addition: Warning message:
In two.sample.test(formula = d(bDWG) ~ bConcord, data = d.sub, test =
t.test, :
bDWG must have at least 3 observations per group. Dropping...

I promise that there are *way* more than 3 observations per group ;-)

If i just work 'old skool' and type at the terminal:

> t.test(bDWG ~ bConcord, data=d)

Welch Two Sample t-test

data: bDWG by bConcord
t = 6.185, df = 15.798, p-value = 1.385e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
7.87152 16.09429
sample estimates:
mean in group 0 mean in group 2
20.538462 8.555556

This is an error that i get consistently. I saw that two.sample.test
is a function in the Deducer library so I hope you'll be able to help
me get out of this problem.

Many thanks
Dr Ben Fox

Ian Fellows

unread,
Jan 26, 2011, 12:34:52 AM1/26/11
to ded...@googlegroups.com
Ben,

There have been no changes to the two.sample.test function for quite
some time, so I doubt that the upgrade is what solved the problem.
Just looking at the generated code, the first case (that gives you an
error) uses the d.sub dataset, whereas the second (that works) uses
the d dataset.

Ian

Ben

unread,
Feb 7, 2011, 11:23:25 PM2/7/11
to Deducer
grr i am not managing with a simple ANOVA either
there are over 100 data points in this data set and no NA at all
so why 'not enough observations?'

help!


> k.sample.test(formula=d(ClimbIndex) ~ nyha,data=all,test=oneway.test,var.equal=TRUE)
Error in test(y ~ x, tmp, ...) : not enough observations

> summary(all$nyha)
0 1 2 3 4
18 6 52 33 1
> summary(all$ClimbIndex)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.883 3.368 3.874 3.937 4.812 5.435



On Jan 26, 12:34 am, Ian Fellows <ifell...@gmail.com> wrote:
> Ben,
>
> There have been no changes to the two.sample.test function for quite
> some time, so I doubt that the upgrade is what solved the problem.
> Just looking at the generated code, the first case (that gives you an
> error) uses the d.sub dataset, whereas the second (that works) uses
> the d dataset.
>
> Ian
>

Ian Fellows

unread,
Feb 7, 2011, 11:40:52 PM2/7/11
to ded...@googlegroups.com
Ben,

If you are having data related problems it is best to post the data
with it to get a reproducible error. It is much easier to see what is
going on in that case and to communicate back to you the issue. The
easiest way to do this is paste the result of dput(all)

The problem is that you have one cell of your anova with only one
observation. I can't remember what the official "rule of thumb" is
regarding cell sizes, but you should definitely have more than 5.
Consider pooling some of your groups or if nyha is ordered treating it
as continuous and using simple linear regression.

#all only has one observation with nyha==4 so the following will fail
all <- data.frame(ClimbIndex=rnorm(110),nyha=c(rep(0,18),rep(1,6),rep(2,52),rep(3,33),rep(4,1)))
k.sample.test(formula=d(ClimbIndex) ~
nyha,data=all,test=oneway.test,var.equal=TRUE)
oneway.test(ClimbIndex~factor(nyha),data=all,var.equal=TRUE)

#all2 has two observations in 4, so it will work
all2 <- data.frame(ClimbIndex=rnorm(110),nyha=c(rep(0,18),rep(1,6),rep(2,52),rep(3,32),rep(4,2)))
k.sample.test(formula=d(ClimbIndex) ~
nyha,data=all2,test=oneway.test,var.equal=TRUE)
oneway.test(ClimbIndex~factor(nyha),data=all2,var.equal=TRUE)

Best,
Ian

Ben

unread,
Feb 7, 2011, 11:52:31 PM2/7/11
to Deducer
aha
yep that solved the problem. i was thinking about recoding that 4 as a
3 and that solved the problem.
thanks very much
ben

On Feb 7, 11:40 pm, Ian Fellows <ifell...@gmail.com> wrote:
> Ben,
>
> If you are having data related problems it is best to post the data
> with it to get a reproducible error. It is much easier to see what is
> going on in that case and to communicate back to you the issue. The
> easiest way to do this is paste the result of dput(all)
>
> The problem is that you have one cell of your anova with only one
> observation. I can't remember what the official "rule of thumb" is
> regarding cell sizes, but you should definitely have more than 5.
> Consider pooling some of your groups or if nyha is ordered treating it
> as continuous and using simple linear regression.
>
> #all only has one observation with nyha==4 so the following will fail
> all <- data.frame(ClimbIndex=rnorm(110),nyha=c(rep(0,18),rep(1,6),rep(2,52),rep(3,33),rep(4,1)))
> k.sample.test(formula=d(ClimbIndex) ~
> nyha,data=all,test=oneway.test,var.equal=TRUE)
> oneway.test(ClimbIndex~factor(nyha),data=all,var.equal=TRUE)
>
> #all2 has two observations in 4, so it will work
> all2 <- data.frame(ClimbIndex=rnorm(110),nyha=c(rep(0,18),rep(1,6),rep(2,52),rep(3,32),rep(4,2)))
> k.sample.test(formula=d(ClimbIndex) ~
> nyha,data=all2,test=oneway.test,var.equal=TRUE)
> oneway.test(ClimbIndex~factor(nyha),data=all2,var.equal=TRUE)
>
> Best,
> Ian
>

sgl3...@gmail.com

unread,
Sep 26, 2016, 10:44:58 AM9/26/16
to Deducer



Hi, lan
I got same error which is 'object not found'. Could you help me to take look at my attached code and my results? Please! I am looking forward your reply. Thank you so much. 

Ellie


Ian Fellows

unread,
Sep 26, 2016, 11:51:11 AM9/26/16
to ded...@googlegroups.com
Hi Ellie,

oneway.test is an R function, not fundamentally related to Deducer. That said, I think the syntax you are looking for is

oneway.test(conc ~ Type, data=CO2, var.equal=TRUE)

best,
Ian



-- 

--- 
You received this message because you are subscribed to the Google Groups "Deducer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deducer+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages