2

I'm trying to use the package fifer with command install.packages("fifer") with R 3.5.0. However, R tells me that it is not available. This webpage tells me that it has been removed from CRAN. Alternatively is there another function / package in R that allows to do a post hoc chi squared?

DTYK
  • 1,098
  • 1
  • 8
  • 33
ecjb
  • 5,169
  • 12
  • 43
  • 79
  • Is there any reason why you can't download and install the archived version? – Rui Barradas Sep 23 '18 at 09:42
  • Thank you. @RuiBarradas. I successfully downloaded the archived version! However why has it been remove from CRAN? – ecjb Sep 23 '18 at 10:49
  • I don't know. Usually this means that the maintainer no longer wants or can support it. Contributed packages are the developers' and maintainer's responsability, not CRAN's. – Rui Barradas Sep 23 '18 at 10:51
  • Ok @RuiBarradas thank you for the comments – ecjb Sep 23 '18 at 10:59

5 Answers5

3

Alternatively, you can install the package using devtools

install.packages("devtools")
library(devtools)
install_github("dustinfife/fifer")

Based on the activity on Github, it looks like it's still being maintained/developed.

However, I don't manage to install it this way or using the archive in R 3.5.1 (but it seems to work for R 3.5.0 and older). Good luck.

David
  • 71
  • 2
2

Additionally, there is the chisq.posthoc.test package. https://www.rdocumentation.org/packages/chisq.posthoc.test/versions/0.1.2/topics/chisq.posthoc.test

test.df <- as.table(cbind(c(30,40,60,120), c(50,70,60,80)))

library(chisq.posthoc.test)

chisq.posthoc.test(test.df)

#  Dimension     Value          A          B
#1         A Residuals -2.2446418  2.2446418
#2         A  p values  0.1983290  0.1983290
#3         B Residuals -2.9981988  2.9981988
#4         B  p values  0.0217260  0.0217260
#5         C Residuals  0.2456726 -0.2456726
#6         C  p values  1.0000000  1.0000000
#7         D Residuals  3.9842868 -3.9842868
#8         D  p values  0.0005410  0.0005410
Evelyn Mac
  • 23
  • 5
0

The package fifer is no longer maintained, here is a solution with RVAideMemoire (described in more detail here https://rdrr.io/cran/RVAideMemoire/src/R/chisq.multcomp.R), using an example from Post-Hoc tests for chi-sq in R:

install.packages("RVAideMemoire")
library(RVAideMemoire)
theft_loc<-as.table(c(13704L, 14059L, 14263L, 14450L, 14057L, 15503L, 14230L, 
           16758L, 15289L, 15499L, 16066L, 15905L, 18531L, 19217L, 12410L, 
           13398L, 13308L, 13455L, 13083L, 14111L, 13068L, 19569L, 18771L, 
           19626L, 20290L, 19816L, 20923L, 20466L, 20517L, 19377L, 20035L, 
           20504L, 20393L, 22409L, 22289L, 7997L, 8106L, 7971L, 8437L, 8246L, 
           9090L, 8363L, 7934L, 7874L, 7909L, 8150L, 8191L, 8746L, 8277L, 
           27194L, 25220L, 26034L, 27080L, 27334L, 30819L, 30633L, 10452L, 
           10848L, 11301L, 11494L, 11265L, 11985L, 11038L, 12104L, 13368L, 
           14594L, 14702L, 13891L, 12891L, 12939L), .Dim = c(7L, 10L), .Dimnames = structure(list(
             c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", 
               "Friday", "Saturday"), c("BAYVIEW", "CENTRAL", "INGLESIDE", 
                                        "MISSION", "NORTHERN", "PARK", "RICHMOND", "SOUTHERN", "TARAVAL", 
                                        "TENDERLOIN")), .Names = c("", "")), class = "table")
chisq.multcomp(theft_loc, p.method = "none")
>      7874    7909    7934    7971    7997    8106    8150    8191    8246    8277    8363    8437    8746    9090    10452   10848   11038   11265   11301  
7909  0.78056 -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -      
7934  0.63321 0.84256 -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -      
7971  0.44095 0.62272 0.76923 -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -      
7997  0.32889 0.48533 0.61768 0.83698 -       -       -       -       -       -       -       -       -       -       -       -       -       -       -      
8106  0.06647 0.11954 0.17444 0.28701 0.39036 -       -       -       -       -       -       -       -       -       -       -       -       -       -      
8150  0.02923 0.05720 0.08854 0.15860 0.22857 0.73002 -       -       -       -       -       -       -       -       -       -       -       -       -      
8191  0.01238 0.02625 0.04298 0.08354 0.12732 0.50552 0.74841 -       -       -       -       -       -       -       -       -       -       -       -      
8246  0.00339 0.00802 0.01417 0.03081 0.05073 0.27360 0.45342 0.66793 -       -       -       -       -       -       -       -       -       -       -      
8277  0.00152 0.00382 0.00706 0.01637 0.02817 0.18156 0.32174 0.50276 0.80943 -       -       -       -       -       -       -       -       -       -      
8363  0.00012 0.00037 0.00078 0.00216 0.00422 0.04522 0.09741 0.18128 0.36396 0.50497 -       -       -       -       -       -       -       -       -      
8437  1.0e-05 3.6e-05 8.5e-05 0.00027 0.00060 0.01007 0.02585 0.05643 0.13921 0.21586 0.56805 -       -       -       -       -       -       -       -      
8746  1.3e-11 8.8e-11 3.2e-10 2.0e-09 7.1e-09 8.2e-07 4.5e-06 2.0e-05 0.00013 0.00032 0.00341 0.01841 -       -       -       -       -       -       -      
9090  < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 6.2e-14 8.1e-13 8.0e-12 1.5e-10 6.9e-10 3.7e-08 8.1e-07 0.01000 -       -       -       -       -       -      
10452 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 < 2e-16 -       -       -       -       - 

Unfortunately the category names are lost and replaced by the counts of each category. I don't like corrections for multiple comparisons (see [Moran 2003][1] for a discussion), but fdr is available.

> install.packages("fifer")
Installing package into ‘C:/Users/admin/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘fifer’ is not available (for R version 3.5.0)

[1]: Moran, M. D. (2003). Arguments for rejecting the sequential Bonferroni in ecological studies. Oikos, 100(2), 403-405.

Nakx
  • 1,460
  • 1
  • 23
  • 32
0

Having use the 'fifer' package in the past, I also saw this:

chisq.test(Matriz)

X-squared = 7.7832, df = 3, p-value = 0.05071

FUN = function(i,j){     
      chisq.test(matrix(c(Matriz[i,1], Matriz[i,2],
                          Matriz[j,1], Matriz[j,2]),
                 nrow=2,
                 byrow=TRUE))$ p.value
                }

pairwise.table(FUN,
               rownames(Matriz),
               p.adjust.method="fdr")

Found at https://rcompanion.org/rcompanion/b_05.html -- this gives answers similar to fifer. The p.adjust.method can be changed.

tripleee
  • 175,061
  • 34
  • 275
  • 318
0

Alternatively, you can downloads source bundle and install using remote packages.

library(remotes)
install_version("fifer", "1.0")
# Import
library(fifer)
# Run Post Hoc Test of Proportion
chisq.post.hoc(table(data))

Works on R version 4.1.2