Re: [R] Maximum likelihood estimation in R
Hello, Excellent, also the book: Pawitan, Yudi (2001). In all Likelihood: Statistical Modelling and Inference using Likelihood, Clarendon Press, Oxford. Is very good and the associated Web Site is full of MLE using R. Hope this also helps. /oal __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Maximum likelihood estimation in R
Hello, Use x=rnorm(100, mean=3, sd=1) library(MASS) fitdistr(x, normal) mean sd 2.9331 0.99673982 (0.09967398) (0.07048015) Hope this helps, Shrieb __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problems when compiling C code
Hello, Do you have S Programming by Venables and Ripley, Springer, 2000? There is an excellent discussion and examples there on compiling multifile codes. I think your problem is in the order of the compilation of the multiple files. Best, /oal __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Fortran source code
Dear All, After spending 3 long days attempting to interface Fortran with R--having spent 1 week sifting through R-help and the horrific official documentation--I cannot emphasize in words the importance of consulting 1 and-only 1 reference: Venables, W.N., B.D. Ripley, S Programming. Springer, New York, 2000. My goodness gracious, I should have started with that book first, I would have saved an incredible amount of time. My interface to a rather long library subroutine was done and tested in less than 30 minutes! My experience is posted in the hope that it will save someone TIME (the most precious of anything in the universe) I hope an up-to-date and expanded version of that fabulous book is also in the works. /Livin La Vida Loca __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Fitting compartmental model with nls and lsoda?
Dear Jesus, Yes there is a way and it is via Christoffer Torn\{o}e's package nlmeODE. I checked Chapter 4 of Bates and Watts. As usual, a little work involved, but doable and quite powerful. Thanks, olinares __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Fitting compartmental model with nls and lsoda?
Dear Colleagues, Our group is also working on implementing the use of R for pharmacokinetic compartmental analysis. Perhaps I have missed something, but fit - nls(noisy ~ lsoda(xstart, time, one.compartment.model, c(K1=0.5, k2=0.5)), +data=C1.lsoda, +start=list(K1=0.3, k2=0.7), +trace=T +) Error in eval(as.name(varName), data) : Object C1.lsoda not found What part of the e-mail did I miss? I would like to get this problem up an running. Now, I am including Richar Upton's 2 cm model implementation and Christoffer Tornoe's nls solution (I recommend Christoffer's nlmeODE package for these problems also if multi-response data is available) The code follows: -- # Simulation of a 2 compartment pharmacokinetic model using R # Richard N. Upton, 11/3/02, [EMAIL PROTECTED] # The R home page is at http://www.R-project.org/ # I make no representations about being an R guru. My contribution here # is hopefully to provide a starting point in R for people who # have a pharmacokinetic modelling background. # This text can be cut and pasted into R, or read in as a source file # There are two differential equations in the system: # V*dC/dt = Doserate - C*Cl + k21*A2 - k12*V*C # dA2/dt = k12*V*C - k21*A2 # C is a dependent variable (Concentration in the central compartment) # A is a dependent variable (Amount in the second compartment) # t is the independent variable (time) # V is the volume of the central compartment # Cl is the clearance from the central compartment # k12 is the rate constant between the central and second compartment # k21 is the rate constant between the second and central compartment # Dose is the total amount of drug given # tau is the time over which this amount is given # The doserate (amount/time) is therefore Dose/tau # A bolus dose should be thought of as a short infusion # The lsoda function is very fussy about names for variables # C[1] = C, meaning the first dependent variable ; Cd1 is its derivative wrt time # C[2] = A2, meaning the second dependent variable ; Cd2 is its derivative wrt time # You can change C to another name, but must keep these conventions # The output from Cprime (its last line) must be a list of the derivative of C wrt time # You must install the odesolve package in R. See the website for details. # This example gave results similar (within 6 sig. fig.) to the same problem # solved in an independent differential equation solving package. #Load the odesolve package require(odesolve) #Specify parameters times - c(0:180) tau - 4 Dose - 30 V- 23.1 Cl - 1 k12 - 0.197118 k21 - 0.022665 #A quick check - compare these steady-state values with values after a long infusion Css - (Dose/tau)/Cl A2ss - V*Css*(k12/k21) #lsoda requires the parameters as an object (p) with names p - c(V=V, Cl=Cl, k12=k12, k21=k21) #Differential equations are declared in a function Cprime - function(t, C, p) { if (t tau) Doserate - (Dose/tau) else Doserate - 0 Cd1 - (Doserate - C[1]*p[Cl] + p[k21]*C[2] - p[V]*p[k12]*C[1])/p[V] Cd2 - (p[V]*p[k12]*C[1] - p[k21]*C[2]) list(c(Cd1, Cd2)) } #Solve the system of differential equations, including initial values result - lsoda( c(0,0), times, Cprime, p) #Reformat the result result - data.frame(result) names(result) - c(time,Conc, Amount2) #Have a look at the result print(result) plot(result$Conc ~ result$time, type=b, main=Central compartment, xlab=time, ylab=Conc) plot(result$Amount2 ~ result$time, type=b, main=Second compartment, xlab = time, ylab = Amount) -- Our group is also working on implementing a ODE solvers suite for R for small to medium size problems. Thanks! for bringing this type of discussion to the R-news. [EMAIL PROTECTED] Oscar A. Linares, MD, PhD /// Michigan Diabetes Institute S c I S O F T ///=20=03 Molecular Medicine Unit __=20=04 SciSoft Group \_\_\_\/ Ann Arbor, MI \_\_\_\/// Tel. (734) 637-7997 \_\_\_\/ Fax. (734) 453-7019 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ODE solvers in R (was:The Wrong Choice: Locked in by licenserestrict...
Dear Colleague: I am glad to hear from you. I was going to contact you and ask if you have notes on the steps involved on how you implemented LSODA. I will gladly take the project on. In addition to dassl, I want to implement ODESSA also. In other words, my project is a suite of ode solvers for R. The application of these solvers will be to the study of the distribution of radioisotopes in living systems in diseases such as heart failure, diabetes, aging and high blood pressure. I have been toying with the latest g77. I find that it does not compile out of the box fortran IVP solver codes (ACM transactions ode solver codes). However, the COMPAQ Visual Fortran (cvf) 6.6B compiles the object code without any errors. I plan to work with Windows XP and 2000, cvf, and the latest R. I found that Prof. Ripley's S programming book and the BLUE book are very helpful. I have alreadychecked the r-archives and it has not been helpful. So, any notes on the procedure will be much appreciated. Kind Regards, Oscar A. Linares, MD, PhD Molecular Medicine Unit The University of Michigan Geriatrics Center [[alternate HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] The Wrong Choice: Locked in by license restrictions
In a message dated 5/27/2003 11:18:33 PM Eastern Standard Time, [EMAIL PROTECTED] writes: Can you comment on the benefits of odepack versus lsoda? The benefit of ODEPACK vs. LSODA is mainly that ODEPACK is a collection of solvers (A. C. Hindmarsh (1983) ODEPACK: a systematized collection of ODE solvers; in Scientific Computing, ed. R. S. Stepleman et al., North Holland, Amsterdam, pp. 55--64.) whereas LSODA is a solver. Some problems demand alternate approaches. ODEPACK sports the Petzold DASSL solver which is of proven utility for large chemical systems. LSODA however is excellent and quite useful. /oal __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] The Wrong Choice: Locked in by license restrictions
In a message dated 5/27/2003 7:11:00 PM Eastern Standard Time, [EMAIL PROTECTED] writes: originalContent/0,289142,sid39_gci902076,00.html I run MATLAB v6.5 Release 13. In my view, the benefit of Matlab over R depends on your objectives. I am now using R exclusively, except for solving differential and partial differential equations which R is weak in. If a comparable suite of DEQ solvers were available for R, then, in my opinion, R would be superior to MATLAB for many reasons (too numerous to list). Both use LAPACK. Prof. Bates Matrix package is a useful complement based on LAPACK. From a computational statistics point of view, MATLAB cannot compare to R, R is much much better anf the support on r-news, well, there is nothing like it for MATLAB. So, unless you need to solve DEQs (IVPs and BVPs), PDEs, and now delay DEQs, use R. I have tried to find the fortran versions of the MATLAB ODE suite but have not been successful. Also, looking at the MATLAB code has not been helpful because the solvers make extensive use of MATLAB built-ins. Don't get me wrong, MATLAB is an outstanding product...R is simply the best (Tina Turner) The Serial Fortran Solvers for ODE Initial Value Problems by Alan C. Hindmarsh in Fortran (http://www.llnl.gov/CASC/odepack/) would be very nice to have in R for scientific computing. There are benchmark comparisions of MATLAB vs. S-PLUS in the s-news archives. Livin La Vida [R]oca (tranlation [R]ockin and [R]ollin) oscar __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help