[R] Likelihood ratio test

Achim Zeileis Achim.Zeileis at uibk.ac.at
Sun Jun 12 23:20:43 CEST 2011


On Sun, 12 Jun 2011, Jorge Ivan Velez wrote:

> Hi Diviya,
>
> Take a look at the lrtest function in the lmtest package:
>
> install.packages('lmtest)
> require(lmtest)
> ?lrtest

Yes, when you have to nls() fits, say m1 and m2, you can do

lrtest(m1, m2)

However, I don't think that both m1 and m2 can be identified in

   y = a * exp(-(m1+m2) * x) + c

Unless I'm missing something only the sum (m1+m2) is identified anyway.

Best,
Z

> HTH,
> Jorge
>
>
> On Sun, Jun 12, 2011 at 1:16 PM, Diviya Smith <> wrote:
>
>> Hello there,
>>
>> I want to perform a likelihood ratio test to check if a single exponential
>> or a sum of 2 exponentials provides the best fit to my data. I am new to R
>> programming and I am not sure if there is a direct function for doing this
>> and whats the best way to go about it?
>>
>> #data
>> x <- c(1 ,10,  20,  30,  40,  50,  60,  70,  80,  90, 100)
>> y <- c(0.033823,  0.014779,  0.004698,  0.001584, -0.002017, -0.003436,
>> -0.000006, -0.004626, -0.004626, -0.004626, -0.004626)
>>
>> data <- data.frame(x,y)
>>
>> Specifically, I would like to test if the model1 or model2 provides the
>> best
>> fit to the data-
>> model 1: y = a*exp(-m*x) + c
>> model 2: y = a*exp(-(m1+m2)*x) + c
>>
>> Likelihood ratio test = L(data| model1)/ L(data | model2)
>>
>> Any help would be most appreciated. Thanks in advance.
>>
>> Diviya
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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.
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list