Re: [Rd] anova and intercept

2022-12-28 Thread peter dalgaard
Yes, that works fine too. It likely depends on what you want to show and to 
whom. The audience might be ready to see the equivalence between t-tests and 
anova(lm(...)) but not yet prepared for variance components.

- Peter

> On 27 Dec 2022, at 18:55 , Greg Snow <538...@gmail.com> wrote:
> 
> Why compute the  differences manually when `aov` can do paired
> comparisons on this data as is:
> 
> summary(aov(extra ~ factor(group) + Error(ID), data=sleep ))
> 
> gives the same F and P values
> 
> On Tue, Dec 27, 2022 at 3:32 AM Gabor Grothendieck
>  wrote:
>> 
>> Good idea.
>> 
>> On Mon, Dec 26, 2022 at 12:59 PM peter dalgaard  wrote:
>>> 
>>> My usual advice on getting nonstandard F tests out of anova() is to fit the 
>>> models explicitly and compare.
>>> 
>>> So how about this?
>>> 
>>> fit1 <- lm(diff(extra,10) ~ 1, sleep)
>>> fit0 <- update(fit1, ~ -1)
>>> anova(fit0, fit1)
>>> 
>>> -pd
>>> 
 On 26 Dec 2022, at 13:49 , Gabor Grothendieck  
 wrote:
 
 Suppose we want to perform a paired test using the sleep data frame
 with anova in R.  Then this works and gives the same p value as
 t.test(extra ~ group, sleep, paired = TRUE, var.equal = TRUE)
 
  ones <- rep(1, 10)
  anova(lm(diff(extra, 10) ~ ones + 0, sleep)
 
 This gives output but does not give an F test at all.
 
  ones <- rep(1, 10)
  anova(lm(diff(extra, 10) ~ 1, sleep)
 
 Maybe there should be some way to force an F test to be produced for
 the intercept in anova for consistency with t.test so that the second
 code can be used.
 
 
 --
 Statistics & Software Consulting
 GKX Group, GKX Associates Inc.
 tel: 1-877-GKX-GROUP
 email: ggrothendieck at gmail.com
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel
>>> 
>>> --
>>> Peter Dalgaard, Professor,
>>> Center for Statistics, Copenhagen Business School
>>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>>> Phone: (+45)38153501
>>> Office: A 4.23
>>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>> 
>> 
>> 
>> --
>> Statistics & Software Consulting
>> GKX Group, GKX Associates Inc.
>> tel: 1-877-GKX-GROUP
>> email: ggrothendieck at gmail.com
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.com

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] anova and intercept

2022-12-27 Thread Greg Snow
Why compute the  differences manually when `aov` can do paired
comparisons on this data as is:

summary(aov(extra ~ factor(group) + Error(ID), data=sleep ))

gives the same F and P values

On Tue, Dec 27, 2022 at 3:32 AM Gabor Grothendieck
 wrote:
>
> Good idea.
>
> On Mon, Dec 26, 2022 at 12:59 PM peter dalgaard  wrote:
> >
> > My usual advice on getting nonstandard F tests out of anova() is to fit the 
> > models explicitly and compare.
> >
> > So how about this?
> >
> > fit1 <- lm(diff(extra,10) ~ 1, sleep)
> > fit0 <- update(fit1, ~ -1)
> > anova(fit0, fit1)
> >
> > -pd
> >
> > > On 26 Dec 2022, at 13:49 , Gabor Grothendieck  
> > > wrote:
> > >
> > > Suppose we want to perform a paired test using the sleep data frame
> > > with anova in R.  Then this works and gives the same p value as
> > > t.test(extra ~ group, sleep, paired = TRUE, var.equal = TRUE)
> > >
> > >   ones <- rep(1, 10)
> > >   anova(lm(diff(extra, 10) ~ ones + 0, sleep)
> > >
> > > This gives output but does not give an F test at all.
> > >
> > >   ones <- rep(1, 10)
> > >   anova(lm(diff(extra, 10) ~ 1, sleep)
> > >
> > > Maybe there should be some way to force an F test to be produced for
> > > the intercept in anova for consistency with t.test so that the second
> > > code can be used.
> > >
> > >
> > > --
> > > Statistics & Software Consulting
> > > GKX Group, GKX Associates Inc.
> > > tel: 1-877-GKX-GROUP
> > > email: ggrothendieck at gmail.com
> > >
> > > __
> > > R-devel@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > --
> > Peter Dalgaard, Professor,
> > Center for Statistics, Copenhagen Business School
> > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> > Phone: (+45)38153501
> > Office: A 4.23
> > Email: pd@cbs.dk  Priv: pda...@gmail.com
> >
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] anova and intercept

2022-12-27 Thread Gabor Grothendieck
Good idea.

On Mon, Dec 26, 2022 at 12:59 PM peter dalgaard  wrote:
>
> My usual advice on getting nonstandard F tests out of anova() is to fit the 
> models explicitly and compare.
>
> So how about this?
>
> fit1 <- lm(diff(extra,10) ~ 1, sleep)
> fit0 <- update(fit1, ~ -1)
> anova(fit0, fit1)
>
> -pd
>
> > On 26 Dec 2022, at 13:49 , Gabor Grothendieck  
> > wrote:
> >
> > Suppose we want to perform a paired test using the sleep data frame
> > with anova in R.  Then this works and gives the same p value as
> > t.test(extra ~ group, sleep, paired = TRUE, var.equal = TRUE)
> >
> >   ones <- rep(1, 10)
> >   anova(lm(diff(extra, 10) ~ ones + 0, sleep)
> >
> > This gives output but does not give an F test at all.
> >
> >   ones <- rep(1, 10)
> >   anova(lm(diff(extra, 10) ~ 1, sleep)
> >
> > Maybe there should be some way to force an F test to be produced for
> > the intercept in anova for consistency with t.test so that the second
> > code can be used.
> >
> >
> > --
> > Statistics & Software Consulting
> > GKX Group, GKX Associates Inc.
> > tel: 1-877-GKX-GROUP
> > email: ggrothendieck at gmail.com
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] anova and intercept

2022-12-26 Thread peter dalgaard
My usual advice on getting nonstandard F tests out of anova() is to fit the 
models explicitly and compare. 

So how about this?

fit1 <- lm(diff(extra,10) ~ 1, sleep)
fit0 <- update(fit1, ~ -1)
anova(fit0, fit1)

-pd

> On 26 Dec 2022, at 13:49 , Gabor Grothendieck  wrote:
> 
> Suppose we want to perform a paired test using the sleep data frame
> with anova in R.  Then this works and gives the same p value as
> t.test(extra ~ group, sleep, paired = TRUE, var.equal = TRUE)
> 
>   ones <- rep(1, 10)
>   anova(lm(diff(extra, 10) ~ ones + 0, sleep)
> 
> This gives output but does not give an F test at all.
> 
>   ones <- rep(1, 10)
>   anova(lm(diff(extra, 10) ~ 1, sleep)
> 
> Maybe there should be some way to force an F test to be produced for
> the intercept in anova for consistency with t.test so that the second
> code can be used.
> 
> 
> -- 
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] anova and intercept

2022-12-26 Thread Gabor Grothendieck
Suppose we want to perform a paired test using the sleep data frame
with anova in R.  Then this works and gives the same p value as
t.test(extra ~ group, sleep, paired = TRUE, var.equal = TRUE)

   ones <- rep(1, 10)
   anova(lm(diff(extra, 10) ~ ones + 0, sleep)

This gives output but does not give an F test at all.

   ones <- rep(1, 10)
   anova(lm(diff(extra, 10) ~ 1, sleep)

Maybe there should be some way to force an F test to be produced for
the intercept in anova for consistency with t.test so that the second
code can be used.


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel