################################################################# # # Examples # by Mu Zhu # Original version = Jan 2005 # This version = Jun 2007 # # The main function is called scree.thresh(), and the syntax is # scree.thresh(d) where d is a vector of ORDERED scores. # ################################################################# # clear everything rm(list=ls(all=TRUE)) # get functions; this is like calling library(proflik) if # such a library is packaged ... source("proflik.txt") ################################################################# # BEGIN EXAMPLE ################################################################# # read in some data; this is the data set used for # Comp Stat Data Anal 51(2), 918-930, Section 4.1 mydata <- as.matrix(read.table('eights.dat', sep=',')) # perform SVD first d=svd(scale(mydata, cen=T, sca=F))$d # call profile likelihood function to estimate dimension scree.thresh(d) # you can also change the legend's location and label ans=scree.thresh(d, trace=T) plot2(ans$lik, ans$top, legendx=150, legendy=-880, preface="dimension =") # or no such legend at all ... plot2(ans$lik, ans$top, preface="none") ################################################################# # END EXAMPLE #################################################################