[R] Fitting Weibull Model with Levenberg-Marquardt regression method
Hi, I have a problem fitting the following Weibull Model to a set of data. The model is this one: a-b*exp(-c*x^d) If I fitted the model with CurveExpert I can find a very nice set of coefficients which create a curve very close to my data, but when I use the nls.lm function in R I can't obtain the same result. My data are these: X Y 1513 5013 759 904 With the commercial software I obtain the following coefficients: Weibull Model: y=a-b*exp(-c*x^d) Coefficient Data: a = 1.31636909714E+001 b = 7.61325570579E+002 c = 2.8215991E+002 d = -9.23838785044E-001 For fitting the Levenberg-Marquardt in R I'm using the following lines: pS<-list(a=1,b=1,c=1,d=1) model<-function(pS,xx){pS$a-pS$b*exp(-pS$c*xx^-pS$d)} resid<-function(observed,pS,xx){observed-model(pS,xx)} lin<-nls.lm(pS,resid,observed=Y,xx=X) Why I can't obtain the same results? Many thanks in advance, Fabio Mr. Fabio Veronesi Ph.D. student Cranfield University e-mail: f.veron...@cranfield.ac.uk [[alternative HTML version deleted]] __ 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 with arguments in .Script
Dear R users, my problem, at the moment, is the following: I need to apply a script to a very big dataset, so I need first to subdivide the dataset into samples and then apply the script to every single sample. Now I tried to solve the problem with these linest: S1<-data[data$sub==1,1:3] #which divide the dataset in samples based on the number on the column "sub" data<-S1 #because in the script the dataset is always called "data" .Script("R",script.R,args=data,write.csv(table,c:\table.csv) With the last line I basically want to run the script ("script.R), with the created dataset and, at the end of the script, I need to write the table, created inside the script, in a csv file. Obviously it does not work. Do you have some suggestion to solve a problem like this? Many thankls, Fabio __ 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] "R CMD BATCH" continue after an error in the script
Hi, I have a problem with R CMD BATCH, because I created a .bat file to run a script: C:\R\R-2.9.2\bin\R CMD BATCH C:\Scrip_test.R It work perfectly but after 3 lines of script there is a line with a nls() function that cannot be fitted and this end in an error message. I'm not bother by the error message, I just want that the script continue. If I use the R windows GUI the script show the error message but it continue till the very end. I want that the script continue to run also in BATCH mode, How can I do that? Many thanks in advance, Fabio Fabio Veronesi Ph.D Student Cranfield University School of Applied Sciences Building 37 Cranfield, Bedforshire MK43 0AL tel. +4407984049316 __ 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] Substitute "Object not found" with NA
Hi everybody, I'm trying to create a script that picks a txt file with 2 columns of coordinates (depth and variable1) and automatically tries to fit several polynomial with the function nls(). After that, it creates a list of observed, predict, residuals and other, and then it calculates AIC, RMSD, MAD and R^2. At the end of the script I create a series of vectors with MAD for all polynomials, RMSD for all polynomial and so on, and from a matrix a .csv file. This script is completely automatic, but there is a problem if one or more models don't fit, because if one or more data is missing I cannot create the vectors and the matrix, as well. So, my question is: is it possible to create a vector with a missing object, substituting that object with NA in the vector? For example: I want to create this vector Vec1<-c(MAD1,MAD2,MAD3,MAD4) but MAD4 is missing and as a consequence R return an error like this: "object 'MAD4' not found" Is it possible to say to R that if it does not find an object it must substitute that object with NA in the vector? Many Thanks, Fabio Mr. Fabio Veronesi Ph.D. student Cranfield University, Bld.37 School of Applied Sciences MK43 0AL Cranfield, Bedfordshire Tel. +44 (0)7984049316 e-mail: f.veron...@cranfield.ac.uk [[alternative HTML version deleted]] __ 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.