nls and maximum likelihood

1.Purpose:

1. based on the does-respond formulation and the experiment data to get an estimation of parameters in the formulation


2. Problems:

1. there are two ways to fit the model, one is the sum least-square, which can be achieved by “nls”, the other way is a maximum likelihood, which can be achieved by mlme

2. don’t know how to do the “nls” and the “maximum likelihood”


3. Results:

3.1. use “nls” get the result

library(readxl)

IMI_20190713 <-read_excel("D:/huang084/1_Experiments/7_toxicity_Grammer/forR/IMI_20190713.xlsx")

# y = (1-c)/(1 +exp(-(b)*(log(x)-a)))

x <-  IMI_20190713$conc

y <-(IMI_20190713$effected)/(IMI_20190713$total)

data_IMI <-data.frame(x,y)

 

m <- nls(y ~(1-c)/(1 + exp(-b*(log(x)-a))),

         data = data_IMI,

        start = list(a = 5, b =5, c =0.000001),

        trace = T)

# the important thing is to

choose the suitable parameters

summary(m)


3.2. the maximum likehood

3.3. lmom



4. Discussion:

4.1. the nls

1.1 singular gradient problem

As  I already the estimation of my three parameters, so I use them as the guess, then there is nosingular gradient error again


1.2 The parameters are slightly different from the results gotfrom the Genestat software


4.2. maximum likelihood

Thefitdistr need the data between (0,1), the data cannot be 0 or 1


4.3. lmom

Some people suggest using the “lmom”, as it is norequirement for the data between (0,1)


4.4. change the source code

as there is a quite similar formulation in the “drc”packages, which is LL2.3u, so  I wonder maybe I can change the source code

library(drc)

trace("LL2.3u",edit= TRUE)

But the code is too complex and it seemed that I should change the code in llogistic2, which I really don’t know how to that.


5. next step

1. figure out the distribution of my data and try reference 7

Reference:

1. the example of nlshttps://www.cnblogs.com/fuxueming/p/6854512.html

2. Maximum Likelihood Estimation https://stat.ethz.ch/R-manual/R-devel/library/stats4/html/mle.html

3.how to solve the singular gradient https://stackoverflow.com/questions/18364402/r-nls-singular-gradient

4. how to fit the data to the modelhttps://www.zoology.ubc.ca/~schluter/R/fit-model/

5. the source of “drc”https://cran.r-project.org/web/packages/drc/index.html

6. how to change the package in Rhttps://stackoverflow.com/questions/49276439/how-to-modify-a-function-in-local-r-package

7. Fitting a Model by Maximum Likelihood https://www.r-bloggers.com/

8.https://cran.r-project.org/web/packages/fitdistrplus/fitdistrplus.pdf

9. elnorm3: Estimate Parameters of a Three-ParameterLognormal...https://rdrr.io/cran/EnvStats/man/elnorm3.html

10 important! The common distribution http://rstudio-pubs-static.s3.amazonaws.com/153240_4d5376627f6740f8be7a4fa5271f4de8.html#f

11. 独家|一文读懂最大似然估计(附R代码) https://zhuanlan.zhihu.com/p/45421484

12. Choose best model between logit, probit and nlshttps://stats.stackexchange.com/questions/33562/choose-best-model-between-logit-probit-and-nls

你可能感兴趣的:(nls and maximum likelihood)