# NOT RUN {
# Generate a data set consisting of 2000 rows (variables) and 50 columns.
# Assume that the first 25 observations belong to class 1, and the other
# 50 observations to class 2.
mat <- matrix(sample(3, 100000, TRUE), 2000)
rownames(mat) <- paste("SNP", 1:2000, sep = "")
cl <- rep(1:2, e = 25)
# Apply PAM for categorical data to this matrix, and compute the
# misclassification rate on the training set, i.e. on mat.
pam.out <- pamCat(mat, cl)
pam.out
# Now generate a new data set consisting of 20 observations,
# and predict the classes of these observations using the
# value of theta that has led to the smallest misclassification
# rate in pam.out.
mat2 <- matrix(sample(3, 40000, TRUE), 2000)
rownames(mat2) <- paste("SNP", 1:2000, sep = "")
predict(pam.out, mat2)
# Let's assume that the predicted classes are the real classes
# of the observations. Then, mat2 can also be used in pamCat
# to compute the misclassification rate.
cl2 <- predict(pam.out, mat2)
pamCat(mat, cl, newdata = mat2, newcl = cl2)
# }
Run the code above in your browser using DataLab