[R] incompatible dimensions error

2020-08-24 Thread Andrew Halford
Hi Listers

Using mvpart to run a MV regression tree with PCA= TRUE to get a PCA
plotted with sites coloured according to the tree output.

Unfortunately it wont produce the PCA, instead giving the error message..

Error in cor(xall, xx[order(tree$where), ]) : incompatible dimensions.

However, when I run a PCA on the data using the rda command I have no
problems producing a PCA.

data is attached as a text file

my code is thus...
fish05.hel <- decostand(fish05,"hellinger")
fish05.mrt <-
mvpart(data.matrix(fish05.hel)~.,env,margin=0.08,cp=0,rsq=TRUE,xv="pick",xval=nrow(fish05),xvmult=100,which=4,pca=TRUE)

The tree is produced no problem but it wont produce a PCA.

I am just keen to understand what this error means as I dont see anything
unusual about the dataset used, notwithstanding the data is rather messy.

Andy





-- 
Andrew Halford Ph.D
Senior Coastal Fisheries Scientist
Pacific Community | Communauté du Pacifique CPS – B.P. D5 | 98848 Noumea,
New Caledonia | Nouméa, Nouvelle-Calédonie
CTE.STRICHL.SORDCHA.LTUSLAB.DIMI
ACA.NANSMON.GRANZAN.CORNGOM.VARIHAL.HORT
THA.LUTECHA.AURICEN.FLAVZEB.SCOPBAL.UNDU
CHA.RETINAS.LITUCHA.EPHICHE.FASCTHA.HARD
HEM.MELACEP.URODCHL.BLEESCA.SCHLMEL.VIDU
CHE.CHLOEPB.INSISCA.PSITZEB.VELICHA.TLIS
CHA.VAGALAB.BICOHIP.LONGEPI.MERRACA.NUDA
CHA.LUNUCHA.ULIETHA.QUINCEP.ARGUCHL.MICR
SCA.NIGEHAL.TRIMLUT.FULVLUT.GIBBSCA.DIMI
CHA.CITRMAC.MELEGND.AUREAPH.FURCLUT.MONO
PYG.DIACACA.TRIORHI.ACULCHE.TRILTHA.LUNA
ACA.NCUSHEM.FASCTHA.PURPSCA.GLOBSCA.SPP 
SIG.ARGEACA.NRISHEN.CHRYHAL.CHRYOXY.UNIF
SCA.FORSSCA.OVICACA.PYRONAS.UNICMON.HETE
CET.OCELSCA.FRENACA.THOMFOR.FLAVPSC.HEXA
STJ.BANDSCA.FLAVPSE.PASCSIG.VULPACA.LINE
ACA.OLIVMEL.NIGESUF.BURSCHA.KLEICHE.UNDU
COR.GAIMHAL.RICHMCR.NIGESCA.GHOBCHA.MERT
FOR.LONGHAL.MELALUT.BOHACEN.LORICTE.CYAN
SUF.CHRYHTY.POLYLBY.UNILPSC.TETRTHA.AMBL
ACA.BLOCCHA.MELACHA.MEYECHE.SPP HAL.MTUS
NOV.TAENLET.HARALUT.SEMISCO.LINECEN.BICO
SCA.SPINACA.MACUACA.SPP CHA.LINECHA.PUNC
KYP.VAIGANA.MELECOR.BATULAB.PECTOXY.DIGR
STJ.STRIMCR.MACUSCA.ALTISCA.RIVUPMS.AREO
CTE.STRGNAS.BREVNAS.HEXACHA.SEMEHEN.MONO
ANA.MELAANA.TWISCOR.AYGUHAL.SPP SCO.BILI
CEN.VROLPCA.IMPESCA.FESTSIG.FUSCACA.MATA
NAS.CAESHAL.PROSHAL.SCAPLBS.MICRTHA.TRIL
SCA.RUBRPSE.BARTSIG.PUEL
DrenmeoMPA_Tr4_2011 75  41  5.5 38.50   3   0   
1   0   2   3.5 9.5 26  0   0.5 1   0.5 
2   7.5 1.5 1   0   0   0   0   0   0   
0.5 3.5 0   1   2.5 1.5 0   0.5 1.5 0   
0.5 0   0.5 3   0   0   0   0   0   0   
0   1.5 0.5 0   0   0   0   0   0   0   
21.32.5 0   0   1   0   0   0   0   0   
0   0   0   0   0   0   0   0   0   0   
1   0   0.5 0   0   0   0   0   0   0   
0.5 0   0   0   0   0   0   0   0   0   
0   0   0   0   0   3   0   0   0   0   
0   0   0   0   4.5 0   0   0   0   0   
0   0   0   0   0   0   0   0   0   0   
0   0   0   0   0   14  0   0   0   0   
0   0   0   0   0   0   0   0   0   0
DrenmeoMPA_Tr10_20114.5 9   2   12.50   0   0   
1   1   2.5 0   0.5 0   0   1   0   0   
0   0.5 0   0   0   0   0   1.5 0   0   
0   2   0   0   0   1   0   0   0   0   
0   0   0   28  0   0   0   0   0   0   
0   0   0   2.

Re: [R] Export R outputs to SAS dataset

2020-08-24 Thread Daniel Nordlund
It is still not clear to me (1) if you just want the printed output in 
your SAS list file, or (2) if you want the actual numerical results 
returned to SAS so that you can do more manipulation with the numbers.


If (1) you can precede your R code with sink() to output to your SAS 
list file


 #R libraries-
sink('path/to/your/listfile.lst', append=TRUE)
 library(tidyverse)
 library(MF)

MFSubj(lesion ~ group, calflung)
HLBoot(lesion ~ group,  calflung, compare = c("con", "vac"), b = 100,
          B = 100, alpha = 0.05, hpd = TRUE, bca = FALSE,
          return.boot = FALSE, trace.it  = FALSE, seed 
= NULL)


You will probably need to redirect your SAS list file to the same location
   PROC PRINTTO file='path/to/your/listfile.lst' new;


If (2), then you need to store the output from you function into 
variables that you can examine to see what you may want to import into 
SAS.  So, something like this in R


mfsubj <- MFSubj(lesion ~ group, calflung)
hlboot <- HLBoot(lesion ~ group,  calflung, compare = c("con", "vac"), b 
= 100,

  B = 100, alpha = 0.05, hpd = TRUE, bca = FALSE,
  return.boot = FALSE, trace.it = FALSE, seed = NULL)
str(mfsubj)
str(hlboot)

After examining the output, you will know what variables/dataframes you 
want to import and you can use the functions provided by PROC IML for 
that purpose.  You will need to read the SAS documentation to understand 
how to do that.


This is becoming off topic for R-Help, so let me end with suggesting you 
pursue this question either on SAScommunity or the SAS-L listserve.  You 
might also want to look into SAS Viya for running your R code. If you 
want to continue this off-list, I can try to help you more, but I will 
need to better understand what it is that you want to get back into SAS.


Dan


On 8/23/2020 6:46 AM, Jomy Jose wrote:

 Hi Daniel

Thanks,please find the code and output

 #R libraries-
      library(tidyverse)
      library(MF)


MFSubj(lesion ~ group, calflung)
HLBoot(lesion ~ group,  calflung, compare = c("con", "vac"), b = 100,
          B = 100, alpha = 0.05, hpd = TRUE, bca = FALSE,
          return.boot = FALSE, trace.it  = FALSE, 
seed = NULL)



1 bootstrap samples
95% confidence intervals
Comparing vac to con


Mitigated Fraction

                observed median  lower  upper
Equal Tailed        0.44 0.4464 0.1360 0.7024
Highest Density     0.44 0.4464 0.1456 0.7088


Hodges-Lehmann

                observed   median     lower    upper
Equal Tailed    -0.07335 -0.07125 -0.170425 -0.01480
Highest Density -0.07335 -0.07125 -0.156350 -0.00975


Quartile Differences (quartiles of vac - quartiles of con)

     observed    median    lower     upper
Q25 -0.041500 -0.041300 -0.10340 -0.000905
Q50 -0.112525 -0.75 -0.28115  0.019350
Q75 -0.168000 -0.170425 -0.38650  0.03


Quartiles of con
    observed   median   lower   upper
Q25 0.054000 0.054000 0.01525 0.11275
Q50 0.139275 0.139275 0.06140 0.31000
Q75 0.315000 0.315000 0.17300 0.45250


Quartiles of vac
    observed  median   lower    upper
Q25  0.01250 0.01250 0.00125 0.026000
Q50  0.02675 0.02675 0.01665 0.144575
Q75  0.14700 0.14700 0.02810 0.292000


Best
Jose

On Sun, Aug 23, 2020 at 2:44 AM Daniel Nordlund > wrote:


On 8/22/2020 9:05 AM, Rasmus Liland wrote:
> On 2020-08-22 08:17 +0530, Jomy Jose wrote:
> | Hi
> | I was able to run R code via PROC IML
> | in SAS,so is there any way to export
> | the generated outputs to SAS datasets
> | since the R outputs don't follow data
> | frame structure.
>
> Dear Jomy,
>
> But perhaps you can take the outputs in
> SAS and work on them inside from there?
>
> To export a data frame from R to SAS via
> a file[1], you can use
>
>       foreign::write.foreign(..., package="SAS")
>
> But I have not tried it.
>
> I have used foreign::read.spss before,
> hehe :-)
>
> I know R is also possible to call from
> Julia, and the df appearing in Julia,
> this sounds like it should be possible
> SAS too[2], yes?
>
> Best,
> Rasmus
>
> [1] https://www.statmethods.net/input/exportingdata.html

> [2]

https://documentation.sas.com/?docsetId=imlug&docsetTarget=imlug_r_sect012.htm&docsetVersion=15.1&locale=en


>
> __
> R-help@r-project.org  mailing list
-- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help

> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html

> and provide c

Re: [R] Classification Tree Prediction Error

2020-08-24 Thread Bert Gunter
Purely statistical questions -- as opposed to R programming queries -- are
generally off topic here.
Here is where they are on topic:  https://stats.stackexchange.com/

Suggestion: when you post, do include the package name where you get tree()
from, as there might be
more than one with this function.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, Aug 24, 2020 at 8:58 AM Xu Jun  wrote:

> Dear all R experts,
>
> I have a question about using cross-validation to assess results estimated
> from a classification tree model. I annotated what each line does in the R
> code chunk below. Basically, I split the data, named usedta, into 70% vs.
> 30%, with the training set having 70% and the test set 30% of the original
> cases. After splitting the data, I first run a classification tree off the
> training set, and then use the results for cross-validation using the test
> set. It turns out that if I don't have any predictors and make predictions
> by simply betting on the majority class of the zero-one coding of the
> binary response variable, I can do better than what the results from the
> classification tree would deliver in the test set. What would this imply
> and what would cause this problem? Does it mean that classification tree is
> not an appropriate method for my data; or, it's because I have too few
> variables? Thanks a lot!
>
> Jun Xu, PhD
> Professor
> Department of Sociology
> Ball State University
> Muncie, IN 47306
> USA
>
> Using the estimates, I get the following prediction rate (correct
> prediction) using the test set. Or we can say the misclassification error
> rate is 1-0.837 = 0.163
>
> > (tab[1,1] + tab[2,2]) / sum(tab)[1] 0.837
>
>
> Without any predictors, I can get the following rate by betting on the
> majority class every time, again using data from the test set. In this
> case, the misclassification error rate is 1-0.85 = 0.15
>
> > table(h2.test)h2.test
> 1poorHlth 0goodHlth
>   101   575 > 571/(571+101)[1] 0.85
>
>
>
> R Code Chunk
>
> # set the seed for random number generator for replication
> set.seed(47306)
> # have the 7/3 split with 70% of the cases allotted to the training set
> # AND create the training set identifier
> class.train = sample(1:nrow(usedta), nrow(usedta)*0.7)
> # create the test set indicator
> class.test = (-class.train)
> # create a vector for the binary response variable from the test set
> # for future cross-tabulation.
> h2.test <- usedta$h2[class.test]
> # count the train set cases
> Ntrain = length(usedta$h2[class.train])
> # run the classification tree model using the training set
> # h2 is the binary response and other variables are predictors
> tree.h2 <- tree(h2 ~ age + educ + female + white + married + happy,
> data = usedta, subset = class.train,
> control = tree.control(nobs=Ntrain, mindev=0.003))
> # summary results
> summary(tree.h2)
> # make predictions of h2 using the test set
> tree.h2.pred <- predict(tree.h2, usedta[class.test,], type="class")
> # cross tab the predictions using the test set
> table(tree.h2.pred, h2.test)
> tab = table(tree.h2.pred, h2.test)
> # calculate the ratio for the correctly predicted in the test set
> (tab[1,1] + tab[2,2]) / sum(tab)
> # calculate the ratio for the correctly predicted using the naive approach
> # by betting on the majority category.
> table(h2.test)[2]/sum(tab)
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Classification Tree Prediction Error

2020-08-24 Thread Xu Jun
Dear all R experts,

I have a question about using cross-validation to assess results estimated
from a classification tree model. I annotated what each line does in the R
code chunk below. Basically, I split the data, named usedta, into 70% vs.
30%, with the training set having 70% and the test set 30% of the original
cases. After splitting the data, I first run a classification tree off the
training set, and then use the results for cross-validation using the test
set. It turns out that if I don't have any predictors and make predictions
by simply betting on the majority class of the zero-one coding of the
binary response variable, I can do better than what the results from the
classification tree would deliver in the test set. What would this imply
and what would cause this problem? Does it mean that classification tree is
not an appropriate method for my data; or, it's because I have too few
variables? Thanks a lot!

Jun Xu, PhD
Professor
Department of Sociology
Ball State University
Muncie, IN 47306
USA

Using the estimates, I get the following prediction rate (correct
prediction) using the test set. Or we can say the misclassification error
rate is 1-0.837 = 0.163

> (tab[1,1] + tab[2,2]) / sum(tab)[1] 0.837


Without any predictors, I can get the following rate by betting on the
majority class every time, again using data from the test set. In this
case, the misclassification error rate is 1-0.85 = 0.15

> table(h2.test)h2.test
1poorHlth 0goodHlth
  101   575 > 571/(571+101)[1] 0.85



R Code Chunk

# set the seed for random number generator for replication
set.seed(47306)
# have the 7/3 split with 70% of the cases allotted to the training set
# AND create the training set identifier
class.train = sample(1:nrow(usedta), nrow(usedta)*0.7)
# create the test set indicator
class.test = (-class.train)
# create a vector for the binary response variable from the test set
# for future cross-tabulation.
h2.test <- usedta$h2[class.test]
# count the train set cases
Ntrain = length(usedta$h2[class.train])
# run the classification tree model using the training set
# h2 is the binary response and other variables are predictors
tree.h2 <- tree(h2 ~ age + educ + female + white + married + happy,
data = usedta, subset = class.train,
control = tree.control(nobs=Ntrain, mindev=0.003))
# summary results
summary(tree.h2)
# make predictions of h2 using the test set
tree.h2.pred <- predict(tree.h2, usedta[class.test,], type="class")
# cross tab the predictions using the test set
table(tree.h2.pred, h2.test)
tab = table(tree.h2.pred, h2.test)
# calculate the ratio for the correctly predicted in the test set
(tab[1,1] + tab[2,2]) / sum(tab)
# calculate the ratio for the correctly predicted using the naive approach
# by betting on the majority category.
table(h2.test)[2]/sum(tab)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [External] rNOMADS package

2020-08-24 Thread William Dunlap via R-help
Add the arguments type="source" and repos=NULL to your call to
install.packages().  repos=NULL means that this is a local file, not
something to download from a repository.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Aug 24, 2020 at 8:31 AM Richard M. Heiberger  wrote:
>
> incorrect double slash c://
> use single slash c:/
>
> On Mon, Aug 24, 2020 at 11:21 Philip  wrote:
>
> > I am struggling to install a fix for the rNOMADS package which reads
> > National Weather Service data.  I copied the fix (rNOMADS_2.5.0.tar.gz)
> > from an email to a local drive and then tried to install it with the
> > command below.  I also tried installing it without the .tar.gz extension
> > and without the _2.5.0 extension but I get the same error message.  The
> > author, Daniel Bowman, emailed me that the fix should work for R version
> > 4.0 or better.
> >
> >
> >
> > Do I need to untar it?
> >
> >
> >
> >
> > install.packages("C://Documents/Ballooning/WeatherBriefing/rNOMADS_2.5.0.tar.gz")
> >
> >
> >
> > Installing package into ‘C:/Users/Owner/Documents/R/win-library/4.0’
> >
> > (as ‘lib’ is unspecified)
> >
> > Warning in install.packages :
> >
> >   package ‘C://Documents/Ballooning/WeatherBriefing/rNOMADS_2.5.0.tar.gz’
> > is not available (for R version 4.0.2)
> >
> > [[alternative HTML version deleted]]
> >
> >
> >
> > __
> >
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >
> > https://stat.ethz.ch/mailman/listinfo/r-help
> >
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> >
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [External] rNOMADS package

2020-08-24 Thread Richard M. Heiberger
incorrect double slash c://
use single slash c:/

On Mon, Aug 24, 2020 at 11:21 Philip  wrote:

> I am struggling to install a fix for the rNOMADS package which reads
> National Weather Service data.  I copied the fix (rNOMADS_2.5.0.tar.gz)
> from an email to a local drive and then tried to install it with the
> command below.  I also tried installing it without the .tar.gz extension
> and without the _2.5.0 extension but I get the same error message.  The
> author, Daniel Bowman, emailed me that the fix should work for R version
> 4.0 or better.
>
>
>
> Do I need to untar it?
>
>
>
>
> install.packages("C://Documents/Ballooning/WeatherBriefing/rNOMADS_2.5.0.tar.gz")
>
>
>
> Installing package into ‘C:/Users/Owner/Documents/R/win-library/4.0’
>
> (as ‘lib’ is unspecified)
>
> Warning in install.packages :
>
>   package ‘C://Documents/Ballooning/WeatherBriefing/rNOMADS_2.5.0.tar.gz’
> is not available (for R version 4.0.2)
>
> [[alternative HTML version deleted]]
>
>
>
> __
>
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>
> https://stat.ethz.ch/mailman/listinfo/r-help
>
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] rNOMADS package

2020-08-24 Thread Philip
I am struggling to install a fix for the rNOMADS package which reads National 
Weather Service data.  I copied the fix (rNOMADS_2.5.0.tar.gz) from an email to 
a local drive and then tried to install it with the command below.  I also 
tried installing it without the .tar.gz extension and without the _2.5.0 
extension but I get the same error message.  The author, Daniel Bowman, emailed 
me that the fix should work for R version 4.0 or better.

Do I need to untar it?

install.packages("C://Documents/Ballooning/WeatherBriefing/rNOMADS_2.5.0.tar.gz")

Installing package into ‘C:/Users/Owner/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘C://Documents/Ballooning/WeatherBriefing/rNOMADS_2.5.0.tar.gz’ is 
not available (for R version 4.0.2)
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help on plot from transition matrix

2020-08-24 Thread Jim Lemon
Hi Luis,
As so often happens, the image didn't make it. Try PNG or PDF format.
Without seeing what you want, it's only guessing.

Jim

On Mon, Aug 24, 2020 at 6:34 PM Luis Fernando García
 wrote:
>
> I am wanting to make a flow diagram like the one attached as an example for
> the given dataset.
>
> The idea is to plot a flow diagramm using the probabilities given by a
> transition matrix like the displayed in the example below. I have found
> some tools like DiagrammeR which might work for this purpose, but it works
> by introducing values manually. I wanted to know if there exists any
> package able to plot automatically the flow diagram, given the transition
> probabilities.
>
> Thanks in advance.
>
> ###
>
> library(TraMineR)
>
> h2a=c("Q-X-Q-Y-W-Z-P")
>
> h3a=c("Q-X-Q-Y-W-Z-P-Q-M-P-Q-A")
>
> h4a=c("Q-X-Q-X-Q-X-Q-Y-W-Z-C-B-Q-M-B-Q-A")
>
> h6a=c("Q-X-Q-X-Q-Y-W-Z-P-Q-P-Q-M-Q-A")
>
> h7a=c("Q-Y-W-Z-P-Q-B-Q-M-A")
>
> h8a=c("Q-Y-W-Z-P-B-Q-M-Q-A")
>
> h9a=c("Q-X-Q-W-Z-B-Q-A")
>
> h10a=c("Q-Y-W-Z-Q-A")
>
> h11a=c("Q-Y-W-Z-B-Q-P-B-Q-M-A")
>
> h12a=c("Q-W-Z-B-P-Q-A")
>
> h13a=c("Q-X-Q-Y-W-Z-P-Q-A")
>
> h14a=c("Q-X-B-X-Q-X-B-Q-X-Q-X-Q-Y-W-Z-B-P-B-Q-A")
>
> h15a=c("Q-X-Y-W-Z-B-P-Q-B-Q-A")
>
> h16a=c("Q-X-Q-B-Q-X-B-X-Q-Y-W-Z-P-B-Q-A")
>
> h17a=c("Q-X-Q-X-B-X-Q-W-Z-P-B-P-Q-A")
>
> h18a=c("Q-Y-W-Z-B-P-Q-B-Q-P-Q-M-B-P-A")
>
> h19a=c("Q-W-Z-B-P-Q-P-Q-M-Q-A")
>
> a=c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a)
>
> a
>
> library(TraMineR)
>
> i1=seqdef(c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a))
>
> seqtrate(i1)
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help on plot from transition matrix

2020-08-24 Thread Luis Fernando García
I am wanting to make a flow diagram like the one attached as an example for
the given dataset.

The idea is to plot a flow diagramm using the probabilities given by a
transition matrix like the displayed in the example below. I have found
some tools like DiagrammeR which might work for this purpose, but it works
by introducing values manually. I wanted to know if there exists any
package able to plot automatically the flow diagram, given the transition
probabilities.

Thanks in advance.

###

library(TraMineR)

h2a=c("Q-X-Q-Y-W-Z-P")

h3a=c("Q-X-Q-Y-W-Z-P-Q-M-P-Q-A")

h4a=c("Q-X-Q-X-Q-X-Q-Y-W-Z-C-B-Q-M-B-Q-A")

h6a=c("Q-X-Q-X-Q-Y-W-Z-P-Q-P-Q-M-Q-A")

h7a=c("Q-Y-W-Z-P-Q-B-Q-M-A")

h8a=c("Q-Y-W-Z-P-B-Q-M-Q-A")

h9a=c("Q-X-Q-W-Z-B-Q-A")

h10a=c("Q-Y-W-Z-Q-A")

h11a=c("Q-Y-W-Z-B-Q-P-B-Q-M-A")

h12a=c("Q-W-Z-B-P-Q-A")

h13a=c("Q-X-Q-Y-W-Z-P-Q-A")

h14a=c("Q-X-B-X-Q-X-B-Q-X-Q-X-Q-Y-W-Z-B-P-B-Q-A")

h15a=c("Q-X-Y-W-Z-B-P-Q-B-Q-A")

h16a=c("Q-X-Q-B-Q-X-B-X-Q-Y-W-Z-P-B-Q-A")

h17a=c("Q-X-Q-X-B-X-Q-W-Z-P-B-P-Q-A")

h18a=c("Q-Y-W-Z-B-P-Q-B-Q-P-Q-M-B-P-A")

h19a=c("Q-W-Z-B-P-Q-P-Q-M-Q-A")

a=c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a)

a

library(TraMineR)

i1=seqdef(c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a))

seqtrate(i1)
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.