<br><div class="gmail_quote"><font size="2">Hey everyone,<br><br>I use R and the package TraMineR to analyse payment data in 151 cases.</font> As you might expect, I have some trouble...<br><br>Question 1: I successfully calculated an optimal matching analysis and a
cluster analysis. I also generated the necessary graphs.<b> How to I get the IDs into the graphs</b> OR <b>How can I get a table of every cluster and the relevant sequences?</b> <br>
<br>
Question 2: E.g., when plotting the mean times spent in each state per
cluster (seqmtplot) oder other graphs, <b>how can I get a table with the corresponding values </b>(since I can only guess the values in the graphs)<b>?</b>
<br><br>Thanks a lot in advance and good luck with all your projects!<br>
<br>
Greetz<br>
Judie<br><br><font size="1"><span style="color:rgb(204, 0, 0)">> library(TraMineR)<br>> library(foreign)<br>> library(cluster)<br>> library(RColorBrewer)<br>> datenR <- read.spss("Y:\\DOKTORARBEIT\\1_Dissertation\\3_Methode\\2_Erwerbsverläufe\\5_R\\datenR.sav", to.data.frame=TRUE, use.value.labels=FALSE)<br>
> datenR.labels <- c("ES6", "ES7", "ES8", "ES9", "ES10", "ES11",
"ES12", "ES13", "ES14", "Ruhendes Arb.verh.", "Austritt", "Muttersch.,
Erz.-Elt.zeit", "Wehrdienst", "Weiterbildung")</span><br style="color:rgb(204, 0, 0)">
<span style="color:rgb(204, 0, 0)">> datenR.seq <- seqdef(datenR, var=20:103, labels=datenR.labels, id="auto")</span><br> [>] found missing values ('NA') in sequence data<br> [>] preparing 151 sequences<br>
[>] coding void elements with '%' and missing values with '*'<br> [>] 14 distinct states appear in the data: <br> 1 = 6<br> 2 = 7<br> 3 = 8<br> 4 = 9<br> 5 = 10<br> 6 = 11<br>
7 = 12<br> 8 = 13<br> 9 = 14<br> 10 = 44<br> 11 = 55<br> 12 = 66<br> ...<br> [>] alphabet (state labels): <br> 1 = 6 (ES6)<br> 2 = 7 (ES7)<br> 3 = 8 (ES8)<br> 4 = 9 (ES9)<br>
5 = 10 (ES10)<br> 6 = 11 (ES11)<br> 7 = 12 (ES12)<br> 8 = 13 (ES13)<br> 9 = 14 (ES14)<br> 10 = 44 (Ruhendes Arb.verh.)<br> 11 = 55 (Austritt)<br> 12 = 66 (Muttersch., Erz.-Elt.zeit)<br> ... (14 states)<br>
[>] no color palette attributed, provide one to use graphical functions<br> [>] 151 sequences in the data set<br> [>] min/max sequence length: 2/84<br>Warnmeldung:<br> [!] no automatic color palete attributed, number of states>12. <br>
Use 'cpal' argument to define one. <br><span style="color:rgb(204, 0, 0)">>
cpal(datenR.seq) <- c("white", "yellow", "orange", "hotpink",
"red1", "red3", "darkred", "skyblue", "blue", "grey80", "grey60",
"springgreen", "grey20", "purple")</span><br style="color:rgb(204, 0, 0)">
<span style="color:rgb(204, 0, 0)">> subcostmatrix <- seqsubm(datenR.seq, method="TRATE")</span><br> [>] creating substitution-cost matrix using transition rates ...<br> [>] computing transition rates for states 6/7/8/9/10/11/12/13/14/44/55/66/77/88 ...<br>
<span style="color:rgb(204, 0, 0)">> round(subcostmatrix, 2)</span><br> 6-> 7-> 8-> 9-> 10-> 11-> 12-> 13-> 14-> 44-> 55-> 66-> 77-> 88-><br>6-> 0.00 1.75 2.00 1.75 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.0<br>
7-> 1.75 0.00 1.89 1.98 1.99 2.00 2.00 2.00 2.00 2.00 <a style="color:rgb(0, 0, 0)" href="tel:1.93%201.92%201.72%C2%A0%202.0" value="+19319217220" target="_blank">1.93 1.92 1.72 2.0</a><br style="color:rgb(0, 0, 0)">
<span style="color:rgb(0, 0, 0)">8-> 2.00 1.89 0.00 1.89 1.99 2.00 2.00 2.00 2.00 2.00 1.86 1.88 1.90 1.4</span><br style="color:rgb(0, 0, 0)"><span style="color:rgb(0, 0, 0)">9-> 1.75 1.98 1.89 0.00 1.82 2.00 2.00 2.00 2.00 1.75 2.00 1.98 1.95 2.0</span><br style="color:rgb(0, 0, 0)">
<span style="color:rgb(0, 0, 0)">
10-> 2.00 1.99 1.99 1.82 0.00 1.85 2.00 2.00 2.00 2.00 2.00 1.99 1.98 2.0</span><br style="color:rgb(0, 0, 0)"><span style="color:rgb(0, 0, 0)">11-> 2.00 2.00 2.00 2.00 1.85 0.00 1.91 2.00 2.00 2.00 2.00 1.90 2.00 2.0</span><br style="color:rgb(0, 0, 0)">
<span style="color:rgb(0, 0, 0)">12-> 2.00 2.00 2.00 2.00 2.00 1.91 0.00 1.99 2.00 2.00 2.00 1.92 2.00 2.0</span><br style="color:rgb(0, 0, 0)"><span style="color:rgb(0, 0, 0)">
13-> 2.00 2.00 2.00 2.00 2.00 2.00 1.99 0.00 1.99 2.00 2.00 1.97 2.00 2.0</span><br>14-> 2.00 2.00 2.00 2.00 2.00 2.00 2.00 1.99 0.00 2.00 2.00 2.00 2.00 2.0<br>44-> 2.00 2.00 2.00 1.75 2.00 2.00 2.00 2.00 2.00 0.00 2.00 1.75 2.00 2.0<br>
55-> 2.00 1.93 1.86 2.00 2.00 2.00 2.00 2.00 2.00 2.00 0.00 1.98 2.00 2.0<br>66-> 2.00 1.92 1.88 1.98 1.99 1.90 1.92 1.97 2.00 1.75 1.98 0.00 2.00 2.0<br>77-> 2.00 1.72 1.90 1.95 1.98 2.00 2.00 2.00 2.00 2.00 2.00 2.00 0.00 2.0<br>
88-> 2.00 2.00 1.40 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00 0.0<br><span style="color:rgb(204, 0, 0)">> datenR.om <- seqdist(datenR.seq, method="OM", indel=2, sm=subcostmatrix)</span><br> [>] 151 sequences with 14 distinct events/states<br>
[>] 147 distinct sequences<br> [>] min/max sequence length: 2/84<br> [>] computing distances using OM metric<br> [>] total time: 0.33 secs<br>Warnmeldung:<br>The substitution cost matrix is not symmetric. <br>
<span style="color:rgb(204, 0, 0)">> clusterward <- agnes(datenR.om, diss=TRUE, method="ward")<br>> plot(clusterward, which.plots=2)<br>> cluster4 <- cutree(clusterward, k=4)<br>> cluster4 <- factor(cluster4, labels=c("Cluster 1", "Cluster 2", "Cluster 3", "Cluster 4"))<br>
> table(cluster4)</span><br>cluster4<br>Cluster 1 Cluster 2 Cluster 3 Cluster 4 <br> 32 17 35 67 <br><span style="color:rgb(204, 0, 0)">> seqfplot(datenR.seq, group=cluster4, pbarw=T, tlim=0, border=NA)</span><br>
<span style="color:rgb(204, 0, 0)">> seqmtplot(datenR.seq, group=cluster4)</span></font><br><font color="#888888"><br>Judith Krüger<br>Ph.D. Student<br>Germany<br>
</font></div><br>