[R] nnet: cannot coerce class c("terms", "formula") into a data.frame
Dearest all, Objective: I am now learning neural networks. I want to see how well can train an artificial neural network model to discriminate between the two files I am attaching with this message. http://r.789695.n4.nabble.com/file/n2240582/3dMaskDump.txt 3dMaskDump.txt http://r.789695.n4.nabble.com/file/n2240582/test_vowels.txt test_vowels.txt Question: when I am attempting to run >cvc_nnet <- nnet(G ~ ., data=cvc_lda, size=1,iter=10,MaxNWts=100) I get an error saying: Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class c("terms", "formula") into a data.frame I have not encountered this error when I was running this script with previous lda results, and, I am not quite sure what the error means. Below is short (and, I hope, reproducible) code. library(nnet) cvc_nnet <- nnet(G ~ ., data=cvc_lda, size=1,iter=10,MaxNWts=100) predict(cvc_nnet,cvc_lda,type = "class") table(predict(cvc_nnet,cvc_lda,type = "class"),cvc_lda$G) cvc_nnet.out<-NULL all = c(1:52) for(n in all){ cvc_nnet <- nnet(G ~ ., data=cvc_lda[all != n,], CV =TRUE,size=1,iter=10,MaxNWts=100) cvc_nnet.out <- c(cvc_nnet.out,predict(cvc_nnet,cvc_lda[all == n,],type = "class")) } table(cvc_nnet.out,cvc_lda$G) === to get cvc_lda: library(MASS) vowel_features <- data.frame(as.matrix(read.table(file = "test_vowels.txt"))) mask_features <- data.frame(as.matrix(read.table(file = "3dmaskdump.txt"))) G <-vowel_features[,41] cvc_lda <- lda(G ~ ., data=mask_features, na.action="na.omit", CV=TRUE) Your insight is very much appreciated it! -- View this message in context: http://r.789695.n4.nabble.com/nnet-cannot-coerce-class-c-terms-formula-into-a-data-frame-tp2240582p2240582.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Linear Discriminant Analysis in R
Joris, Thank you, I have corrected my mistakes. I very much appreciate your time and patience. All my best, Cobbler. -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2240547.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Linear Discriminant Analysis in R
Hi Janis, As you have suggested below is the output for the following: test.vowel <- vowel_features[,1:10] test.mask <- mask_features[,1:10] dput(test.vowel) dput(test.mask) --- NOTE: outputs are limited >>test_vowel first 12 columns are all zero (total of 26 columns) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 10 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 0 30 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 60 0 0 0 0 0 0 0 0 0 70 0 0 0 0 0 0 0 0 0 80 0 0 0 0 0 0 0 0 0 90 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 >>test_mask (sample output for first 6 columns and 5 rows) V1 V2V3 V4 V5 V6 1 0.034495155 0.990218632 0.601464511 0.014837676 0.058299799 0.818202398 2 0.683688879 0.541566798 0.898061753 0.008456439 0.800863858 0.381366477 3 0.464978895 0.844494807 0.281241401 0.290183593 0.552412608 0.158107894 4 0.200058599 0.270115497 0.179173377 0.341301213 0.672338934 0.322934948 5 0.595020534 0.633111358 0.861024861 0.811241462 0.326562913 0.363330793 >>dput(test.vowel) structure(list(V1 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V2 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V3 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V4 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V5 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V6 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V7 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V8 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V9 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), V10 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10"), class = "data.frame", row.names = c(NA, -254L)) >>dput(test.mask) structure(list(V1 = c(0.034495155, 0.683688879, 0.464978895, 0.877838275, 0.943014871, 0.163438168), V2 = c(0.990218632, 0.541566798, 0.025567579, 0.159811845, 0.13874224, 0.752357297, 0.669662897, 0.854803677, 0.28129096, 0.858919573, 0.98992922, 0.980733255, 0.452405459, 0.376828532, 0.901208552), V3 = c(0.601464511, 0.898061753, 0.38395498, 0.923324665, 0.529832526, 0.182135661), V4 = c(0.014837676, 0.166132726, 0.893089168, 0.45962114, 0.018438501, 0.667720635 ), V5 = c(0.058299799, 0.800863858, 0.552412608, 0.672338934, 0.185407787, 0.691367432), V6 = c(0.818202398, 0.381366477, 0.158107894, 0.322934948, 0.363330793, 0.161321704, 0.052999774, 0.513440813, 0.402895033, 0.201576687, 0.076826481), V7 = c(0.642136394, 0.099776129, 0.148801865, 0.603051825, 0.440594157, 0.215038249, 0.531623479, 0.534920743, 0.45784502, 0.080887221), V8 = c(0.016004048, 0.519115043, 0.149317949, 0.088362708, 0.705002368, 0.185590863, 0.434963787, 0.847410734, 0.78777694, 0.443995646, 0.53903599), V9 = c(0.400620271, 0.918472003, 0.446820588, 0.310981412, 0.734013866, 0.172112916 ), V10 = c(0.532136091, 0.350028839, 0.40424688, 0.607395545, 0.392450857, 0.306530929, 0.756277707, 0.63606622, 0.718866192, 0.258778101)), .Names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10"), class = "data.frame", row.names = c(NA, -671L)) Thank you once more for your help. I really can not say it enough. ps. original files i work with are attached. Cobbler. http://r.789695.n4.nabble.com/file/n2236083/3dMaskDump.txt 3dMaskDump.txt http://r.789695.n4.nabble.com/file/n2236083/vowel_features.txt vowel_features.txt -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2236083.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Linear Discriminant Analysis in R
Thanks for being patient with me. I guess my problem is with understand how grouping in this particular case is used: one of the sample codes I found online (http://www.statmethods.net/advstats/discriminant.html) library(MASS) fit <- lda(G ~ x1 + x2 + x3, data=mydata, na.action="na.omit", CV=TRUE) the "mydata" file in my case is the 3dmaskdump file with 52 columns and 671 rows (all values range between 0 and 1 after they're scaled) the other file, what I assumed was the "grouping file" (or the "vowel_feature") is the file that defines features for the vowels (i.e. column 1 of the file is vowel name (a, i, u) and every other column in a distinct combination of 0's and 1's defining the vowel (so this file has 26 columns and 254 rows). Therefore, every column that follows represents a particular "feature" of that vowel.. (hope this makes sense!!) So, the reason I wanted to return G <- vowel_feature[15] in my previous post is because I need to extract a column that represents "backness" of the vowel (while other columns represent "roundedness", "nasalization" features, etc). So what (in my mind) G <- vowel_feature[15] would return is 1 column which is 254 rows long with 0's and 1's in it. i.e. 1 0 2 1 3 1 4 0 ... .. . 2541 I am a novice with R (so I know my questions are pretty dumb!), but I really hope I clarified my confusion a bit better. I very much appreciate your help. Looking forward to your replies. Thank you again, Cobbler -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2235777.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Linear Discriminant Analysis in R
Joris, You are a life saver. Based on two sample files above, I think lda should go something like this: vowel_features <- read.table(file = "mappings_for_vowels.txt") mask_features <- data.frame(as.matrix(read.table(file = "3dmaskdump_ICA_37_Combined.txt"))) G <- vowel_features[15] cvc_lda <- lda(G~ vowel_features[15], data=mask_features, na.action="na.omit", CV=TRUE) ERROR: Error in model.frame.default(formula = G ~ vowel_features[15], data = mask_features, : invalid type (list) for variable 'G' I am clearly doing something wrong declaring G (how should I declare grouping in R when I need to use one column from vowel_feature file)? Sorry for stupid questions and thank you for being so helpful! - again, sample files that I am working with: mappings_for_vowels.txt: V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23 V24 V25 V26 1E 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 2o 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 3I 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 4^ 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 5@ 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 and the mask_features file is: V42 V43 V44 V45 V46 V47 V48 V49 [1,] 2.890891625 2.881188521 2.88778 -2.882606612 -2.77341 2.879834384 2.886483229 2.883815864 [2,] 2.763404707 2.756198683 2.761863881 -2.756827983 -2.762268531 2.754305072 2.760017050 2.758399799 [3,] 0.556614506 0.556377530 0.556247414 -0.556300910 -0.556098321 0.557495060 0.557383073 0.556867424 [4,] 0.367065248 0.366962036 0.366870087 -0.366794442 -0.366644148 0.366613343 0.366537320 0.366953464 [5,] 0.423692393 0.421835623 0.421741829 -0.421897460 -0.421659824 0.421567705 0.421465738 0.422407838 -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p223.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Linear Discriminant Analysis in R
Dear R gurus, Thank you all for continuous support and guidance -- learning without you would not be efficient. I have a question regarding LD analysis and how to best code it up in R. I have a file of (V52 and 671 time points across all columns) and another file of phonetic features (each vowel is aligned with a distinct binary sequence, i.e. E 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 and so on). I need to run lda (at first for one of the features, meaning one column only extracted from the "binary" file mentioned above). In code so far I have very little, but here the short examples of both files: V57 file: V27 V28 V29 V30 V31 V32 V33 V34 1 -2.515000e-03 -0.203858 6.531000e-03 0.248686 6.76e-04 0.084677 -1.262000e-03 2 -2.406000e-03 -0.194943 6.248000e-03 0.237851 6.47e-04 0.081001 -1.207000e-03 3 -4.86e-04 -0.039288 1.263000e-03 0.047980 1.30e-04 0.016292 -2.43e-04 and "binary" file V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23 V24 V25 V26 1E 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 2o 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 3I 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 thus in code I have the following: library(MASS) vowel_features <- read.table(file = "mappings_for_vowels.txt") mask_features <- read.table(file = "3dmaskdump_ICA_37_Combined.txt") #scale the mask_features file scaled_features <- scale(mask_features, center = FALSE, scale = apply(abs(mask_features, 2, median))) #input vowel feature, lda lda(ROI_values ~ mappings_for_vowels[15]...) not sure what is the correct approach to use for lda any pointers would be greatly appreciated thanks again all! Cobbler -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2231922.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] File normalization
Dear all, I have a file with 57 columns (671 time points in each column) File looks like this: 10.279191 -1.203200e-02 -0.166772 6.12080e-02 0.196379 4.591900e-02 0.293689 20.267017 -1.150700e-02 -0.159463 5.85400e-02 0.187775 4.392200e-02 0.280854 30.053778 -2.322000e-03 -0.032103 1.18490e-02 0.037921 8.867000e-03 0.056571 40.035469 -1.531000e-03 -0.021166 7.79200e-03 0.024937 5.843000e-03 0.037273 50.040774 -1.761000e-03 -0.024342 8.96000e-03 0.028674 6.726000e-03 0.042910 6 -0.3597091.547400e-020.214844 -7.87320e-02 -0.253034 -5.905100e-02 -0.378322 I need to normalize it -- is it possible? I looked into normalize columns of a matrix to have the median absolute value in R, but I am not sure how to apply it in this case. Would very much appreciate any input you could give me.. Thank you all in advance, Cobbler -- View this message in context: http://r.789695.n4.nabble.com/File-normalization-tp2230251p2230251.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] argument is of length zero
Dear R gurus, We are working on a problem in R - the following script is getting a subset of values from a table that is read in and calculating the average of these values in the subset defined. the table looks like this: subject stim trial xmax ymax xmin ymin flag 1 4 dur1 1 -13 133 -403 547 true 2 4 dur1 2 15 450 -466 631 true 3 4 dur1 3 -8 179 -543 687true 4 4 dur1 4 -6 129 -427 603false .. the script is: traj_lengths <- NULL # flag files dur_flags = data.frame(read.table("flagfile_dur")) spec_flags = data.frame(read.table("flagfile_spec")) for ( sub in c(4, 5, 7, 8, 9, 11, 12, 13, 14, 15 ,16 ,17, 19, 20, 81) ) { for ( stimnum in c(1, 2, 3, 4, 5, 6, 7) ) { for ( continuum in c("_dur","_spec")) { foo = data.frame(read.table(paste("MT_sub",as.character(sub),"_dur",as.character(stimnum),"_time",sep=""))) names(foo) = c("trialnum","stim","RT","y","x") foo_trialnums = data.frame(read.table(paste("MT_sub",as.character(sub),"_dur",as.character(stimnum),"_trialnums",sep=""))) # CHECK THAT SUB/STIM COMBINATION IS LEGIT -- at least 90% categorical if ( as.character(as.vector(subset(data.frame(read.table(paste("flagfile_",substr(continuum,2,nchar(continuum)),sep=""))), V1==sub & V2==stimnum)$V3)[1] == "true") ) { normalized_traj_y <- NULL normalized_traj_x <- NULL for ( copynum in c(1,2,3,4,5,6,7,8,9,10) ) { if ( as.vector(subset(bigframe, subject==sub & stim==paste(substr(continuum,2,nchar(continuum)),as.character(stimnum),sep="") & trial==copynum)$flag) == "true") { # INTERPOLATE TO MEAN LENGTH = 67 new_y <- as.integer( spline(subset(foo, trialnum == foo_trialnums[copynum,1])$y, n=67)$y ) new_x <- as.integer( spline(subset(foo, trialnum == foo_trialnums[copynum,1])$x, n=67)$y ) normalized_traj_y <- cbind(normalized_traj_y, new_y) normalized_traj_x <- cbind(normalized_traj_x, new_x) } } } It finds an error in: Error in if (as.vector(subset(bigframe, subject == sub & stim == paste(substr(continuum, : argument is of length zero -- We were wondering what is the reason for the error above.. Thank you in advance for any pointers! cobbler squad -- View this message in context: http://r.789695.n4.nabble.com/argument-is-of-length-zero-tp2193605p2193605.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in from:to : NA/NaN argument
Hello R gurus, I am having difficulties running a chunk of code that I otherwise thought was correct.. > if (lower < max(length(IC_peaks),length(IC_valleys))) { + valley_index <- IC_valleys[lower+1] + for (i in seq(peak_index,valley_index-1)) { + IC_peaks_and_valleys <- c(IC_peaks_and_valleys, "v") + } + } Error in from:to : NA/NaN argument I can not pin point the issue and if you have any suggestions I would greatly appreciate them. If more code is needed to figure out the problem, I will post it right away. Thank you all. -- View this message in context: http://n4.nabble.com/Error-in-from-to-NA-NaN-argument-tp2017930p2017930.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Converting a .txt file into a matrix
I need to convert foo.txt file into as.matrix .txt file is a single column of numbers (i.e. -0.303904 -0.889965 -0.0270313 -0.387125 0.189837 -0.14858 -0.651178 -0.162632 0.449309 ) and I need to find out the correct syntax to read in this table as.matrix I tried as.matrix(read.table(foo.txt)), but unfortunately this just spits the table back out.. Any of your pointers would be welcome.. -- View this message in context: http://n4.nabble.com/Converting-a-txt-file-into-a-matrix-tp1838718p1838718.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help interpreting libarary(nnet) script output..URGENT
Hello, I am pretty new to R. I am working on neural network classifiers and I am feeding the nnet input from different regions of interest (fMRI data). The script that I am using is this: library (MASS) heap_lda <- data.frame(as.matrix(t(read.table(file="R_10_5runs_matrix9.txt")))*10,syll = c(rep("heap",3),rep("hoop",3),rep("hop",3))) library(nnet) heap_nnet <- nnet(syll ~ ., data=heap_lda, size=12,iter=100,MaxNWts=1) predict(heap_nnet,heap_lda,type = "class") table(predict(heap_nnet,heap_lda,type = "class"),heap_lda$syll) # do leave-one-out crossvalidation... heap_nnet.out<-NULL all = c(1:9) for(n in all){ heap_nnet <- nnet(syll ~ ., data=heap_lda[all != n,], CV =TRUE,size=12,iter=100,MaxNWts=1) heap_nnet.out <- c(heap_nnet.out,predict(heap_nnet,heap_lda[all == n,],type = "class")) } table(heap_nnet.out,heap_lda$syll) ..the output I am receiving so far is fits in this structure..(this input is from 1 Region of interest file) > library(MASS) > heap_lda <- > data.frame(as.matrix(t(read.table(file="R_10_5runs_matrix9.txt")))*10,syll > = c(rep("heap",3),rep("hoop",3),rep("hop",3))) > library(nnet) > heap_nnet <- nnet(syll ~ ., data=heap_lda, size=12,iter=100,MaxNWts=1) # weights: 1719 initial value 10.469219 iter 10 value 0.057269 iter 20 value 0.000276 final value 0.69 converged > > predict(heap_nnet,heap_lda,type = "class") [1] "heap" "heap" "heap" "hoop" "hoop" "hoop" "hop" "hop" "hop" > table(predict(heap_nnet,heap_lda,type = "class"),heap_lda$syll) heap hoop hop heap30 0 hoop03 0 hop 00 3 > heap_nnet.out<-NULL > all = c(1:9) > > for(n in all){ + heap_nnet <- nnet(syll ~ ., data=heap_lda[all != n,], CV =TRUE,size=12,iter=100,MaxNWts=1) +heap_nnet.out <- c(heap_nnet.out,predict(heap_nnet,heap_lda[all == n,],type = "class")) + } # weights: 1719 initial value 10.602879 iter 10 value 1.417881 iter 20 value 1.387453 iter 30 value 1.386296 final value 1.386294 converged # weights: 1719 initial value 11.055741 iter 10 value 0.096622 iter 20 value 0.000189 final value 0.60 converged # weights: 1719 initial value 10.029384 iter 10 value 0.046705 final value 0.63 converged # weights: 1719 initial value 10.997292 iter 10 value 0.011758 final value 0.86 converged # weights: 1719 initial value 8.527452 iter 10 value 0.019332 final value 0.60 converged # weights: 1719 initial value 7.470868 iter 10 value 0.016888 final value 0.85 converged # weights: 1719 initial value 10.694363 iter 10 value 0.000740 iter 20 value 0.000310 final value 0.57 converged # weights: 1719 initial value 13.334826 iter 10 value 0.032689 final value 0.91 converged # weights: 1719 initial value 6.861594 iter 10 value 0.008161 final value 0.81 converged > > table(heap_nnet.out,heap_lda$syll) heap_nnet.out heap hoop hop heap21 1 hoop01 0 hop 11 2 I am having trouble understanding how to interpret the output. is my intuition correct and we are comparing the heap_nnet <- nnet(syll ~ ., data=heap_lda, size=12,iter=100,MaxNWts=1) [# weights: 1719 initial value 10.469219 iter 10 value 0.057269 iter 20 value 0.000276 final value 0.69 converged] to the output of leave one out cross-validation? Is the better match the one that goes through least iterations and arrives at the closest approximation of the neural network classifier? General ideas/notes regarding this would be greatly appreciated. Also, which number of weights is best, the one with larger or the smaller number (given that our max_weights limit is set at 1). I apologize for my lack of familiarity with this and the resulting stupid questions. Thanks. -- View this message in context: http://n4.nabble.com/Help-interpreting-libarary-nnet-script-output-URGENT-tp1431725p1431725.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plotting in R
Hello, As a result of running linear discriminant analysis, I need to be able to plot the resulting file. I am not sure what the best way to do this is. So far I have tried regular plot("insert_file_name_here") command but the error it gives me is Error in plot.new() : figure margins too large here is sample LDA code I am working with library(MASS) example <- data.frame(as.matrix(t(read.table(file="trial.txt"))),syll = c(rep("one",3),rep("two",3),rep("three",3))) table(lda(syll ~ ., example, CV =TRUE)$class,example$syll) what is the best way to plot the example file? sample "trial.txt" contents... 0.004764-0.008445 0.0150450.0146580.004095 -0.001678 0.011231-0.003612 0.011409 0.010761-0.009416 0.0060080.001603-0.004214 -0.015367 0.014689-0.003415 -0.001983 0.004339-0.018069 -0.001695 0.0026320.011438 -0.013996 0.012927-0.002597 -0.005044 thank you for your help. -- View this message in context: http://n4.nabble.com/plotting-in-R-tp1015355p1015355.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Linear Discriminant Analysis in R
Dear R-gurus, Here is what I need to do.. I have two .txt files that are in a matrix form (each looks something like this: 0.0334820.02238 0.026677 0.0345530.0232260.028855 0.0350170.0232620.02941 0.0362620.0233060.029706 0.0372520.0246440.032053 ) I need to write a code such that it pulls these two matrices into a data frame and then runs the LDA and compares the classification results of the two stimuli against one another. I am not sure how to do that at all, but here is what I have thus far (not sure about the syntax 100%) # lda, nnet, prcomp, etc are in the MASS library library(MASS) # pull matrices (made by 3dmaskdump) into a data frame #first file L_heap_hoop_4 <- data.frame(as.matrix(t(read.table(file="L_Heap_4_top_ten.txt")))*10,syll = c(rep("heap")) <~~~ NEED specification here #second file L_heap_hoop_4 <- data.frame(as.matrix(t(read.table(file="L_Hoop_4_top_ten.txt")))*10,syll = c(rep("hoop")) <~~~ NEED specification here # run the LDA and compare the clasification results of the two stimuli against one another table(lda(syll ~ ., L_heap_hoop_4, CV =TRUE)$class,$syll) any input would be highly appreciated. -- View this message in context: http://n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp998567p998567.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.