Мои проблемы можно легко описать на этих двух рисунках:
Последовательность участков:
Частота последовательности:
Превышена ось х, хотя набор данных заканчивается в 2018. Я действительно надеюсь выяснить, почему это так.
Я пытался ограничить период времени годом до конца 2017 года. Без изменений. Я немного новичок, хотя мои идеи были ограничены. Я могу предположить, что это путается с категорией «NA». Но общий сюжет выглядит нормально. Это только участки кластера и график частоты последовательности, который выходит за пределы оси x.
MyData <- read.csv2(file="e:/Dokumente (-videoedluxe)/IBP dokumente/Msc/seq/mappe1.csv", sep=";", skipNul=TRUE, stringsAsFactors=FALSE, na = "empty")
str(MyData, sep=",")
install.packages("TraMineR")
Yes
library("TraMineR")
table(data$x1989)
data.seq <-seqdef(MyData, var = 2:31, ext = TRUE, gaps="NA"
alphabet=c("GOVspec","GOVinv","GOVno","IOspec","IOinv","IOno","ICspec","ICinv","ICno","MNCspec","MNCinv","MNCno","NGOspec","NGOspec","NGOinv","NGOno","NPOspec","NPOinv","NPOno","UNIspec","UNIinv","UNIno","EDUspec","EDUinv","EDUno", NA),
states = c("GOVspec","GOVinv","GOVno","IOspec","IOinv","IOno","ICspec","ICinv","ICno","MNCspec","MNCinv","MNCno","NGOspec","NGOspec","NGOinv","NGOno","NPOspec","NPOinv","NPOno","UNIspec","UNIinv","UNIno","EDUspec","EDUinv","EDUno", NA)
cpal(data.seq) <-c("aquamarine2","aquamarine3","aquamarine4","chocolate2","chocolate3","chocolate4","cadetblue2","cadetblue3","cadetblue4","gold1","gold3","gold4","green2","green3","green4","hotpink2","hotpink3","hotpink4","orange2","orange3","orange4","purple2","purple4","rosybrown","orchid2", "white")
seqstatl(MyData)
summary(data.seq)
years = c(1989:2018)
par(mfrow = c(1, 2))
seqdplot(data.seq, with.legend = FALSE, border = NA, x = years)
seqlegend(data.seq)
cost.constant <- seqsubm(data.seq, method="CONSTANT", time.varying= T, with.miss = FALSE)
cost.trate <- seqsubm(data.seq, method="TRATE", time.varying= T, with.miss = FALSE)
seqfplot(data.seq, withlegend="FALSE")
seqmtplot(data.seq, withlegend="RIGHT", title="Mean Time",
analysis.manual <- seqdist(data.seq, method="OM", sm="TRATE", indel=1.5)
library(cluster)
analysis.manual = agnes(analysis.manual)
clusterward <- agnes(data.seq, method="ward")
plot(clusterward, which.plots = 2)
plot(analysis.trate, which.plots = 8)
## CLUSTER ANALYSIS
cluster1 = cutree(analysis.trate, 1)
cluster2 = cutree(analysis.trate, 2)
cluster3 = cutree(analysis.trate, 3)
cluster3 = cutree(analysis.trate, 4)
# Distribution plot
seqdplot(data.seq, group= cluster1, withlegend = F, border = NA, x = years)
# Index plots
seqIplot(data.seq, group= cluster1, withlegend = F, border = NA, x = years)
seqIplot(data.seq, group= cluster2, withlegend = F, border = NA, x = years)
seqIplot(data.seq, group= cluster3, withlegend = F, border = NA, x = years)
seqIplot(data.seq, group= cluster4, withlegend = F, border = NA, x = years)
Я ожидаю, что сюжеты закончатся, когда они должны.