#create Morse-Smale complex regression of fourpeaks2d data set
data(fourpeaks)
d <- fourpeaks()
#build Morse-Smale complex
ms <- msc.nn.svm(y=d[,1], x=d[, 2:3], pLevel=0.1, knn = 10)
#build model using Morse-Smale decomposition ms
msr <- msc.slm(ms)
#print simultaneous linear model cv error
msr$slm[[msr$ms$predictLevel]]$cv
#predict for all data points
fp <- predict(msr, d[, 2:3])
#use elastic net for fitting instead
msr <- msc.slm.elnet(ms)
fp <- predict(msr, d[, 2:3])
Run the code above in your browser using DataLab