I’ve tried to change rdabbler code and run it. Unfortunately example runs with no problems, but after adjusting equations to my problem, I get a warning messages:

50: In r[2] = (1/k1) * 2.42 * ((1 + 0.26 * cP)/(1 + 0.004 * … :

number of items to replace is not a multiple of replacement length (cP is the variable from the data.frame) and an error message:

Error in chol.default(object$hessian) :

the leading minor of order 1 is not positive definite and further:

Error in solve.default(object$hessian) :

Lapack routine dgesv: system is exactly singular: U[1,1] = 0

My equations are of the form:

r=rep(0,length(c))

r[1]=(500+(4500*cE^8)/(200^8+cE^8))/(1+cP/12.2)-2.42*((1+0.26*cP)/(1+0.004*cE))*c[“pLH”]; #dRP_LH/dt

r[2]=(1/k1)*2.42*((1+0.26*cP)/(1+0.004*cE))*c[“pLH”]-k2*c[“L”] #dL/dt

return(list(r))

I’ve embedded values of some parameters, as the code didn’t like bigger number of parameters to be found that the number of equations.

Did you solve this problem. Can you advice me on that,please?

]]>Thank you for your code. Should be very useful for me, I’m new to R. I have problems with running the code (the problem is with the version of R). What version did u use? I have 3.3.2.

Also, I have a problem with plotting. I get an error message:

expdf=melt(df,id.var=”time”,variable.name=”species”,value.name=”conc”)

Error in match.names(clabs, names(xi)) :

names do not match previous names

> ssqres=preddf$conc-expdf$conc

Error: object ‘expdf’ not found

and much more (I couldn’t install minpack on my version of R)

Thanks in advance for any suggestions,

Malgosia

A wonderful example for parameter estimation for model using R. This is my first time to use R, but this tutorial is easy to follow and understand.

I have one more question to ask: if the model initial conditions (cinit) are also considered as the unknow parameters (like k1,k2 and k3). How should I change the above code to achieve this purpose? Would I change the code in ssq=function(parms) as well as its corresponding positions, or do some change in rxnrate function (in fact, it is not necessary to change rxnrate function because cinit is not required in this function. Cinit is only required to get a solution for desolve).

I already tried many changes according to my understanding. However, I did not get the correct solutions at the moment. Hoperfully, I can get your response as soon as possible.

Thanks

Hong

One question:

When dealing with data from multiple subjects there’s two types of uncertainties: the inter-individual uncertainty and residual error. When we solve a differential equation, is there any good way to add uncertainty to a specific parameter, and add residual error also?

For example: we assume drug concentration dy/dt = -k*y + ε. When we simulate for y changes over time for several subjects, how shall we let k change randomly? Is it also possible to generate a random number (ε) for each observation (this would be each time t).

Thank you.

]]>