[R] break

(Ted Harding) ted.harding at wlandres.net
Sat Dec 11 22:45:38 CET 2010


And not only that! According to the code, the only place that i is
set is in the loop for(i in 1:n){...}, and the test for 'break' is
  if (i <  0.1) {break(i)}
Therefore the condition will never be satisfied.

Possibly Serdar meant

  if(matris[i] < 0.1) {break}

or something similar.
Ted.

On 11-Dec-10 21:24:47, Jim Holtman wrote:
> It is 'break', not 'break(I)'
> 
> Sent from my iPhone
> 
> What is the problem you are trying to solve?
> 
> On Dec 11, 2010, at 12:17, Serdar Akin <akin1876 at gmail.com> wrote:
> 
>> Hi
>>
>> I'm trying to utilize the break command for breaking the loop when the
>> p-value is less than 10 per cent using the urca package. But it does  
>> not
>> break the loop, anyone that can help me?
>>
>> library(urca)
>> set.seed(1)
>> a1 <- runif(100)
>> lag.max <- function(object, n = 12){
>>    matris <- matrix(NA, nrow = n)
>>    for(i in 1:n) {
>>       matris[i] <- ur.df(object, lags = i,
>>                          type = "trend")@testreg$coefficients[i+3,4]
>>       if (i <  0.1) {break(i)}
>>   }
>>       list(matris = round(matris, 3))
>>   }
>> a2 <- lag.max(a1)
>>
>> /With regards
>> Serdar
>>
>>    [[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.
> 
> ______________________________________________
> 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.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 11-Dec-10                                       Time: 21:45:35
------------------------------ XFMail ------------------------------



More information about the R-help mailing list