[R] help with nls fitting
Dear all, I'm trying to fit the following function slope_pp3_mrna = ( (k3 * v3_K_d *p1^v3_h) / ( (v3_Kd^v3_h) + p2^v3_h ) ) * ( 1/(1 + (p2/v4_Kd)^v4_h) ) - pp3_mrna to this experimental data in the datafraeme Data_pp3_mrna (see it at the end of this e-mail) I'm using the nls function in the following code. IN the last step of the fit fm_pp3_mrna_4, when I add to the funziont the paramter v4_Kd something goes wrong, and I reeive this message Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model What could be the error? I tried with differnet intial values of v4_Kd, but I did not fix the problem. Here below the code. Thanks in advance, Paola. Data_pp3_mrna - data.frame( p1 = protein_1, p2 = protein_2, pp3_mrna = protein_3_mrna, slope_pp3_mrna = stinemanSlopes(times, protein_3_mrna) ) one_par - nls(slope_pp3_mrna ~ ( (k3 * p1) / ( (1) + p1 ) ) * ( 1/(1 + (p2)) ) - pp3_mrna, data=Data_pp3_mrna, start=list( k3=0.1 )) summary(one_par) fm_pp3_mrna_1 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1) / ( (v3_Kd) + p1 ) ) * ( 1/(1 + (p2)) ) - pp3_mrna, data=Data_pp3_mrna, start=list(k3=24, v3_Kd=1 )) summary(fm_pp3_mrna_1) fm_pp3_mrna_2 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1^v3_h) / ( (v3_Kd)^v3_h + p1^v3_h ) ) * ( 1/(1 + (p2)) ) - pp3_mrna, control = list(maxiter = 500), data=Data_pp3_mrna, start=list(k3=69, v3_Kd=0.3238, v3_h=1 )) summary(fm_pp3_mrna_2) fm_pp3_mrna_3 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1^v3_h) / ( (v3_Kd)^v3_h + p1^v3_h ) ) * ( 1/(1 + (p2)^v4_h) ) - pp3_mrna, control = list(maxiter = 500), data=Data_pp3_mrna, start=list(k3=37.451, v3_Kd=0.59, v3_h=2.013, v4_h=0.01 )) summary(fm_pp3_mrna_3) fm_pp3_mrna_4 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1^v3_h) / ( (v3_Kd)^v3_h + p1^v3_h ) ) * ( 1/(1 + (p2/v4_Kd)^v4_h) ) - pp3_mrna, control = list(maxiter = 500), data=Data_pp3_mrna, start=list(k3=56.2823, v3_Kd=0.3366, v3_h=1.8040, v4_Kd=0.03, v4_h=0.7693 )) Here the data. Data_pp3_mrna p1 p2 pp3_mrna slope_pp3_mrna 1 1.006 0.921 0.041 8.63741887 2 2.235 2.047 2.9069031 2.82619343 3 3.744 3.937 4.052 0.84354113 4 4.222 9.340 4.3237353 0.47577213 5 9.022 14.609 4.531-0.03940131 6 11.326 22.765 3.510-2.0420 7 6.899 17.852 2.489-1.86822481 8 10.709 27.777 1.6222048-1.55625973 9 14.084 27.785 0.911-0.48800514 10 14.922 23.613 0.826-0.1700 11 14.340 18.422 0.741-0.22560156 12 13.066 24.085 0.599-0.2840 13 17.553 18.594 0.457-0.13847372 14 14.803 16.831 0.4550965 0.03588624 15 11.945 14.495 0.493 0.09536674 16 11.427 12.458 0.5505361 0.15549062 17 11.556 9.082 0.649 0.49638596 18 20.107 9.987 1.2486525 1.36871828 19 15.999 10.305 2.059 1.87868197 20 16.094 5.793 3.2285000 2.3390 21 11.752 6.944 4.398 0.80395869 22 15.841 5.575 4.651 0.5060 23 12.601 5.221 4.904 0.80270128 24 13.598 2.872 5.819 1.8300 25 13.879 2.883 6.734-0.03571884 26 16.270 2.213 6.4135000-0.6410 27 17.176 3.381 6.093-0.33913760 28 12.332 2.781 6.032-0.1220 29 12.373 3.073 5.971-0.41224459 30 14.781 2.948 5.489-0.9640 31 17.578 3.953 5.007-0.68258311 32 18.865 2.279 4.7568901-0.39425557 33 14.735 2.806 4.606 0.13264481 34 16.160 1.676 4.987 0.7620 35 13.416 2.478 5.368 0.63914248 36 13.864 1.394 5.6374239 0.45419096 37 16.219 2.299 5.827-0.12540453 38 13.249 1.457 5.2505000-1.1530 39 14.445 2.325 4.674-0.09880849 40 13.210 2.230 5.5576966 2.17200142 41 12.358 2.116 8.94711.38521228 -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* [[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] fit a 2-variables function to data
Dearl all, I have to fit a function y = f(x1, x2) to data experiemntal data describing the measured behavior of y. x1 and x2 are the independent variables. Could you suggest me wich R package can I use for this purpose? Thanks, Paola. -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* [[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] problemsn in using nls
Dear all, I tried to use nls, but I got the following error Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model Any suggestion? Thanks, Paola. The code I wrote is Data_pp2_mrna - data.frame( p1 = protein_1, p6 = protein_6, pp2_mrna = protein_2_mrna, slope_pp2_mrna = stinemanSlopes(times, protein_2_mrna) ) fm_pp2_mrna - nls(slope_pp2_mrna ~ ( (k1 * v2_Kd *p1^v2_h) / ( (v2_Kd^v2_h) + p1^v2_h ) ) * ( 1/(1 + (p6/v5_Kd)^v5_h) ) - pp2_mrna, data = Data_pp2_mrna, start = list(k1 = 1, v2_Kd = 1, v2_h = 1, v5_Kd = 1, v5_h = 1 )) The data are as follows Data_pp2_mrna p1 p6 pp2_mrna slope_pp2_mrna 1 1.006 1.234 0.000 1.0183976996 2 2.235 0.693 0.5565718 1.2167043185 3 3.744 0.451 1.230 1.6962541888 4 4.222 0.441 2.620 2.78 5 9.022 0.523 4.010 0.1298238635 6 11.326 0.845 3.9179535 -0.2048280861 7 6.899 0.674 3.805 -0.4595669210 8 10.709 1.369 3.386 -0.838000 9 14.084 1.646 2.967 -0.5032137310 10 14.922 2.561 2.822 -0.29 11 14.340 2.265 2.677 -0.300152 12 13.066 4.832 2.4634792 -0.4859794757 13 17.553 5.651 2.188 -0.7700435122 14 14.803 6.418 1.6045000 -1.167000 15 11.945 10.343 1.021 -0.3160241819 16 11.427 9.415 1.0435000 0.045000 17 11.556 12.610 1.066 -0.1700195282 18 20.107 16.171 0.8545000 -0.423000 19 15.999 13.189 0.643 -0.1721421868 20 16.094 17.022 0.6635000 0.041000 21 11.752 14.723 0.684 -0.0911220974 22 15.841 15.887 0.569 -0.23 23 12.601 15.604 0.454 -0.0022539547 24 13.598 18.202 0.5665000 0.225000 25 13.879 20.821 0.679 -0.0155566571 26 16.270 18.040 0.549 -0.26 27 17.176 16.015 0.419 -0.1195632728 28 12.332 18.429 0.425 0.012000 29 12.373 17.723 0.431 -0.1118527520 30 14.781 23.100 0.3095000 -0.243000 31 17.578 15.396 0.188 0.0004440266 32 18.865 21.408 0.310 0.244000 33 14.735 14.518 0.432 0.0473462057 34 16.160 21.351 0.361 -0.142000 35 13.416 16.689 0.290 0.0424156026 36 13.864 17.015 0.4065000 0.233000 37 16.219 21.776 0.523 0.1567965535 38 13.249 17.371 0.5650035 0.0498847737 39 14.445 19.218 0.573 -0.0435396634 40 13.210 21.309 0.5211514 -0.1713939796 41 12.358 24.966 0.400 -0.3132118164 -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* [[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] use of modMCMC
Dear all, I used modFit of the package FME to fit a set of ODE to a ste of eperiemntal data. The summary of this fit give me the following error summary(Fit) Residual standard error: 984.1 on 452 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular This is due becasue the Hessian matrix has all the entries equal to 0. In these cases, on the help page of modFit, it is suggested to use modMCMC to generate new sets of parameters. modMCMC performs a Markov Chain Monte Carlo simulation. I do not understand very well how modMCMC can be used in a context of parameter estimation. Could someone help me in understanding the use of this function and its utility for parameter fiting? Thank you very much in advance, Paola. -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* [[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] use of modMCMC
Dear all, I used modFit of the package FME to fit a set of ODE to a ste of experimental data. The summary of this fit give me the following error summary(Fit) Residual standard error: 984.1 on 452 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular This is due becasue the Hessian matrix has all the entries equal to 0 in my system. In these cases, on the help page of modFit, it is suggested to use modMCMC to generate new sets of parameters. modMCMC performs a Markov Chain Monte Carlo simulation. I do not understand very well how modMCMC can be used in a context of parameter estimation. Could someone help me in understanding the use of this function and its utility for parameter fitting? Thank you very much in advance, Paola. -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* [[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 modFit of FME package
Dear R users, I'm trying to fit a set an ODE to an experimental time series. In the attachment you find the R code I wrote using modFit and modCost of FME package and the file of the time series. When I run summary(Fit) I obtain this error message, and the values of the parameters are equal to the initial guesses I gave to them. The problem is not due to the fact that I have only one equation (I tried also with more equations, but I still obtain this error). I would appreciate if someone could help me in understanding the reason of the error and in fixing it. Thanks for your attention, Paola Lecca. Here the error: summary(Fit) Parameters: Estimate Std. Error t value Pr(|t|) pro1_strength1 NA NA NA Residual standard error: 2.124 on 10 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular __ 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. -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* timepp1_mrna 0 0 2 2.754 4 2.958 6 4.058 8 3.41 10 3.459 12 2.453 14 1.234 16 2.385 18 3.691 20 3.252 __ 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 modFit of FME package 2
* Apologies for multiple posting * I attached to my previous e-mail a .r file, and it was not permitted by the rules of the mailing lis. Again, please receive my sincere apologies for this. I re-send again the e-mail with .txt attachemnt in the hope someone an help me to solve my problem. I'm trying to fit a set an ODE to an experimental time series. In the attachment you find the R code I wrote using modFit and modCost of FME package and the file of the time series. When I run summary(Fit) I obtain this error message, and the values of the parameters are equal to the initial guesses I gave to them. The problem is not due to the fact that I have only one equation (I tried also with more equations, but I still obtain this error). I would appreciate if someone could help me in understanding the reason of the error and in fixing it. Thanks for your attention, Paola Lecca. Here the error: summary(Fit) Parameters: Estimate Std. Error t value Pr(|t|) pro1_strength1 NA NA NA Residual standard error: 2.124 on 10 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular __ 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. -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* timepp1_mrna 0 0 2 2.754 4 2.958 6 4.058 8 3.41 10 3.459 12 2.453 14 1.234 16 2.385 18 3.691 20 3.252 require(deSolve) require(FME) ## # PART 1 # ## # Differential equations model_1_part_1 - function(t, S, parameters) { with(as.list(parameters), { # cod1 = pro1_strength # pp1_mrna_degradation_rate - 1 ### # v1 = cod1 v2 = pp1_mrna_degradation_rate * S[1] # # # dS1 = v1 - v2 # # list(c(dS1)) }) } # Parameters parms_part_1 - c(pro1_strength = 1.0) # Initial values of the species concentration S - c(pp1_mrna = 0) times - seq(0, 20, by = 2) # Solve the system ode_solutions_part_1 - ode(S, times, model_1_part_1, parms = parms_part_1) ode_solutions_part_1 summary(ode_solutions_part_1) ## Default plot method plot(ode_solutions_part_1) # Estimate of the parameters experiment - read.table(./wild_pp1_mrna.txt, header=TRUE) rw - dim(experiment)[1] names - array(, rw) for (i in 1:rw) { names[i] - pp1_mrna } names observed_data_part_1 - data.frame(name = names, time = experiment[,1], val = experiment[,2]) observed_data_part_1 ode_solutions_part_1 Cost_function - function (pars) { out - ode_solutions_part_1 cost - modCost(model = out, obs = observed_data_part_1, y = val) cost } Cost_function(parms) # Fit the model to the observed data Fit - modFit(f = Cost_function, p = parms_part_1) Fit # Summary of the fit summary(Fit) # Model coefficients coef(Fit) # Deviance of the fit deviance(Fit)__ 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 modFit of FME package
Dear R users, I’m trying to fit a set an ODE to an experimental time series. In the attachment you find the R code I wrote using modFit and modCost of FME package and the file of the time series. When I run summary(Fit) I obtain this error message, and the values of the parameters are equal to the initial guesses I gave to them. The problem is not due to the fact that I have only one equation (I tried also with more equations, but I still obtain this error). I would appreciate if someone could help me in understanding the reason of the error and in fixing it. Thanks for your attention, Paola. Here the error: summary(Fit) Parameters: Estimate Std. Error t value Pr(|t|) pro1_strength1 NA NA NA Residual standard error: 2.124 on 10 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular -- *Paola Lecca, PhD* *The Microsoft Research - University of Trento* *Centre for Computational and Systems Biology* *Piazza Manci 17 38123 Povo/Trento, Italy* *Phome: +39 0461282843* *Fax: +39 0461282814* timepp1_mrna 0 0 2 2.754 4 2.958 6 4.058 8 3.41 10 3.459 12 2.453 14 1.234 16 2.385 18 3.691 20 3.252 __ 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 modFit of FME package
Dear R users, I'm trying to fit a set an ODE to an experimental time series. In the attachment you find the R code I wrote using modFit and modCost of FME package and the file of the time series. When I run summary(Fit) I obtain this error message, and the values of the parameters are equal to the initial guesses I gave to them. The problem is not due to the fact that I have only one equation (I tried also with more equations, but I still obtain this error). I would appreciate if someone could help me in understanding the reason of the error and in fixing it. Thanks for your attention, Paola Lecca. Here the error: summary(Fit) Parameters: Estimate Std. Error t value Pr(|t|) pro1_strength1 NA NA NA Residual standard error: 2.124 on 10 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addition: Warning message: In summary.modFit(Fit) : Cannot estimate covariance; system is singular timepp1_mrna 0 0 2 2.754 4 2.958 6 4.058 8 3.41 10 3.459 12 2.453 14 1.234 16 2.385 18 3.691 20 3.252 __ 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.