IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

Add comprehensive MV methods using Factoshiny? #8514

Open rdstern opened 1 year ago

rdstern commented 1 year ago

@lilyclements We currently have a Describe > Multivariate menu, which has only a limited number of methods within it.

One of them is PCA and this uses the FactoMineR package. We were asked about Multiple Correspondence Analysis (MCA) recently. And there are others. They run easily from the script window.

There is also a partner package, called FactoShiny. This can be used for particular methods or to give a menu, for all the methods. The example shows code that runs from the script window, and then the last lines call the shiny app.

## Tea example
data(tea)
res.mca <- MCA(tea,quanti.sup=19,quali.sup=20:36)
summary(res.mca)
plot(res.mca,invisible=c("var","quali.sup","quanti.sup"),cex=0.7)
plot(res.mca,invisible=c("ind","quali.sup","quanti.sup"),cex=0.8)
plot(res.mca,invisible=c("quali.sup","quanti.sup"),cex=0.8)
dimdesc(res.mca)
plotellipses(res.mca,keepvar=1:4)
plotellipses(res.mca,keepvar="Tea")

## Graphical interface
require(Factoshiny)
res <- Factoshiny(tea)

This is what you get:

image

Alternatively you can run the app for a particular method:. So for MDS:

require(FactoMineR)
data(poison)
# Multiple Correspondance Analysis with Factoshiny:
res.shiny=MCAshiny(poison)

Then you get the MCA function only as follows:

image

I suggest we could easily have a single dialog that permits the main menu, or the specific menus.

The third possibility is to do the analyses ourselves - just for PCA currently as that's the only one we have so far. Then call the app to modify the analysis.

Here is an example for PCA. Note the annoyance (for us) in the commands, which uses the variable numbers in the data frame, rather than the names.

require(FactoMineR)
data(decathlon)
# Principal Component Analysis with Factoshiny:
res.shiny=PCAshiny(decathlon)
# Find your app the way you left it (by clicking on the "Quit the app" button)
res.shiny2=PCAshiny(res.shiny)
#PCAshiny on a result of a PCA
res.pca <- PCA(decathlon, quanti.sup = 11:12, quali.sup=13)
res.shiny=PCAshiny(res.pca)
image

That would get close to having access to comprehensive MV methods!

lilyclements commented 1 year ago

@rdstern just putting our in-person discussion here to keep a record of it! This sounds good to me. Shiny uses the internet so would only work if there is internet access, but, I assume we aren't "replacing" anything we currently have - just adding quick and easy bonus material for those who can access it.

I tried to have a look into it, and seem to be getting a lot of errors. This could be a good thing - by offering it in R-Instat we can make it easy for the user. (But may be a bad thing - how do we get the code to work! Unless it's just a problem my end?)

Vitalis95 commented 10 months ago

@lilyclements We currently have a Describe > Multivariate menu, which has only a limited number of methods within it.

One of them is PCA and this uses the FactoMineR package. We were asked about Multiple Correspondence Analysis (MCA) recently. And there are others. They run easily from the script window.

There is also a partner package, called FactoShiny. This can be used for particular methods or to give a menu, for all the methods. The example shows code that runs from the script window, and then the last lines call the shiny app.

## Tea example
data(tea)
res.mca <- MCA(tea,quanti.sup=19,quali.sup=20:36)
summary(res.mca)
plot(res.mca,invisible=c("var","quali.sup","quanti.sup"),cex=0.7)
plot(res.mca,invisible=c("ind","quali.sup","quanti.sup"),cex=0.8)
plot(res.mca,invisible=c("quali.sup","quanti.sup"),cex=0.8)
dimdesc(res.mca)
plotellipses(res.mca,keepvar=1:4)
plotellipses(res.mca,keepvar="Tea")

## Graphical interface
require(Factoshiny)
res <- Factoshiny(tea)

This is what you get: image

Alternatively you can run the app for a particular method:. So for MDS:

require(FactoMineR)
data(poison)
# Multiple Correspondance Analysis with Factoshiny:
res.shiny=MCAshiny(poison)

Then you get the MCA function only as follows:

image

I suggest we could easily have a single dialog that permits the main menu, or the specific menus.

The third possibility is to do the analyses ourselves - just for PCA currently as that's the only one we have so far. Then call the app to modify the analysis.

Here is an example for PCA. Note the annoyance (for us) in the commands, which uses the variable numbers in the data frame, rather than the names.

require(FactoMineR)
data(decathlon)
# Principal Component Analysis with Factoshiny:
res.shiny=PCAshiny(decathlon)
# Find your app the way you left it (by clicking on the "Quit the app" button)
res.shiny2=PCAshiny(res.shiny)
#PCAshiny on a result of a PCA
res.pca <- PCA(decathlon, quanti.sup = 11:12, quali.sup=13)
res.shiny=PCAshiny(res.pca)
image

That would get close to having access to comprehensive MV methods!

@lilyclements , What do you think about this?

lilyclements commented 10 months ago

@Vitalis95 I previously commented the following about this. Is there anything in particular you’d like me to add or comment on? Thanks.

@rdstern just putting our in-person discussion here to keep a record of it! This sounds good to me. Shiny uses the internet so would only work if there is internet access, but, I assume we aren't "replacing" anything we currently have - just adding quick and easy bonus material for those who can access it.

I tried to have a look into it, and seem to be getting a lot of errors. This could be a good thing - by offering it in R-Instat we can make it easy for the user. (But may be a bad thing - how do we get the code to work! Unless it's just a problem my end?)