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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,448评论 0 10
  • Lua 5.1 参考手册 by Roberto Ierusalimschy, Luiz Henrique de F...
    苏黎九歌阅读 13,905评论 0 38
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,504评论 0 13
  • Introduction What is Bowtie 2? Bowtie 2 is an ultrafast a...
    wzz阅读 5,816评论 0 5
  • 第十章 第一次考不及格 第九章 那天晚上在校门口见了面,贝贝一言不发,只鼓鼓地撅起了嘴,晨新和方宇互相看了一眼...
    清晨起阅读 443评论 15 17