[R] Equivalence test and factors

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Mon Apr 17 23:15:44 CEST 2006

On Mon, Apr 17, 2006 at 02:29:16PM -0600, Tobah Gass wrote:
> Hello, helpeRs,
> I recently used a linear mixed effects model followed by ANOVA to 
> assess the relationship between a categorical predictor variable with 2 
> levels (and random effects) and a numeric response variable.  As I was 
> concerned about the lack of a power analysis prior to data collection, 
> it was suggested that I use an equivalence test to complement the 
> conventional hypothesis test.  Using "equiv.boot" in 
> package "equivalence", I get an "NA" response for the test of the 
> intercept ($rs.b0 and $Test.b0) and the following warnings after the 
> last line of output:
> Warning messages: 
> 1: argument is not numeric or logical: returning NA in: mean.default(x, 
> na.rm = TRUE) 
> 2: argument is not numeric or logical: returning NA in: mean.default(x, 
> na.rm = TRUE)
> "equiv.p" produced the following:
> Error in lm.fit(x, y, offset = offset, singular.ok = 
> singular.ok, ...) : 
>         0 (non-NA) cases
> In addition: Warning messages: 
> 1: argument is not numeric or logical: returning NA in: mean.default(x, 
> na.rm = TRUE) 
> 2: "-" not meaningful for factors in: Ops.factor(x, mean(x, na.rm = 
> TRUE)) 
> I received the same warnings and errors using the simple simulation:
> low <- rnorm(50, 100, 25)
> high <- rnorm(50, 300, 75)
> ages = c(low,high)
> levels = 1:100
> levels[1:50] = "L"
> levels[51:100] = "H"
> test = data.frame(ages, levels)
> class(test$levels)
> equiv.boot(test$levels, test$ages)
> equiv.p(test$levels, test$ages)

You are being caught out by infelicitious documentation.  To do an
equivalence test using the equiv.boot function as I intended it, you
need model predictions and independent observations (i.e. observations
that are not those with which the model was fit).  Report your model
predictions in the "x" argument, and the observations in the "y"

equiv.boot(x=predictions, y=observations)

The documentation is written from the point of view of the application
of a particular test, essentially trying to use predictions as an
explanatory variable for observations as a response variable. The
wording is unclear.  I will make fixing that a priority.

> Can the equivalence package, or parts thereof, handle categorical 
> predictor variables of 2 or more levels?  

Yes, used as above.

> Can the package, or the package plus another function, be used to
> test the similarity of the predictions produced by two or more
> factor levels from nested or otherwise correlated data?

Not as it stands, but it can probably be modified.  This is not a
high priority for me.

> Which of the equivalence functions accomodates unbalanced designs?
> Using functions such as tost.data to compare observations associated
> with the 2 predictors in my data is complicated both by the
> unbalanced design and the lack of accomodation of the nested design.

As far as I can tell, all of them accommodate unbalanced designs, but
not nested designs.  I don't see any reason that an unbalanced design
wouldn't work, but I haven't thought about it deeply.

> Note that I am running R 2.0.1 which predates the version in 
> which "equivalence" was developed.

You should make sure that you upgrade before posting questions to the
list, as it may well be that the problem exists only with early
versions.  It does not, in this case.

> Thank you in advance.
> Toby

Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
Email: a.robinson at ms.unimelb.edu.au         http://www.ms.unimelb.edu.au

More information about the R-help mailing list