[R] error in "ca.jo"

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Dec 24 18:23:51 CET 2013


Once you start describing your code in language that indicates you have read some of the recommended materials, we can make some progress. For example, you are still posting in HTML format so your code is getting mangled (see Posting Guide). You don't seem to understand what tryCatch does (see ?tryCatch; hint... it does not alter the result returned by ca.jo, nor does it guarantee that any result will be returned). For that matter, you don't seem to understand how to give valid inputs to ca.jo, but then you don't seem to understand how to provide a reproducible example either (see for example http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example).

In short, if you ask us why one divided by zero doesn't give 3, we have to wonder if you don't belong in some other educational forum, because this is not a mathematics theory support group... it is about R. Please read or otherwise absorb the recommended background materials mentioned here and then ask clear questions here about R, or find some one-on-one help offline.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

mamush bukana <mamushbukana at gmail.com> wrote:
>Dear Pat,
>I tried your suggestion:
>for(i in 1:N1){
>for(j in 1:N2){
>co<-tryCatch(ca.jo <http://ca.jo>(data.frame(cbind(y2[
>i,j,],y1[i,j,])),type="trace", K=2,
>spec="transitory",ecdet="const",season=NULL,dumvar=NULL),error=function(e)
>NaN)
>}}
>
>and the earlier error does not show up. However, when I try to extract
>some
>results from the "co.jo" function, it does not work the way it does
>without
>the "tryCatch" thing and there appears another error. For example:
>
>for(i in 1:N1){
>for(j in 1:N2){
>co<-tryCatch(ca.jo <http://ca.jo>(data.frame(cbind(y2[
>i,j,],y1[i,j,])),type="trace", K=2,
>spec="transitory",ecdet="const",season=NULL,dumvar=NULL),error=function(e)
>NaN)
>
>cor1<-cajorls(co,r=1)
>}}
>
>Error in cajorls(vecm, r = 1) :
>Please, provide object of class 'ca.jo' or 'cajo.test' as 'z'.
>
>So it seems "tryCatch" is disabling "ca.jo" from running properly. My
>intention is to run this function ("ca.jo") and extract some estimates
>for
>further computation.
>
>regards
>
>Bukana
>
>
>
>
>
>
>
>On Mon, Dec 23, 2013 at 5:09 PM, Patrick Burns
><pburns at pburns.seanet.com>wrote:
>
>> There is a fundamental problem with your
>> code, and there is the problem that you
>> have (sort of) identified.
>>
>> The fundamental problem is that you are
>> only going to get the results of the last
>> call to 'ca.jo' that is done -- assuming
>> it were to run.  You presumably want to
>> save some information from each of the
>> computations.
>>
>> You can get the loops to run even when you
>> run into an error with some combinations
>> by using 'try' or 'tryCatch'.  There is an
>> example in Circle 8.3.13 of 'The R Inferno'.
>>
>> http://www.burns-stat.com/documents/books/the-r-inferno/
>>
>> If you have a question related to the actual
>> function as opposed to general problems with
>> R, then the r-sig-finance mailing list would
>> be appropriate (you need to subscribe before
>> posting).
>>
>> I'm not sure if this is enough of a hint for
>> you or not.  If not, then trying to formulate
>> a more explicit question might help.  (There
>> are some suggestions in Circle 9 of 'The R
>> Inferno'.)
>>
>> Pat
>>
>>
>>
>> On 23/12/2013 17:07, mamush bukana wrote:
>>
>>> Dear all,
>>> I fit co-integration function between two integrated variables(y1
>and y2)
>>> over different grid points:
>>>
>>> for(i in 1:N1){
>>> for(j in 1:N2){
>>> co<-ca.jo(data.frame(cbind(y2[i,j,],y1[i,j,])),type="trace", K=2,
>>> spec="transitory",ecdet="const",season=NULL,dumvar=NULL)
>>> }}
>>>
>>> I have already extracted grid points with integrated time series.
>However,
>>> when I run the above function, there happens an error
>>>
>>> Error in solve.default(t(V) %*% SKK %*% V) :
>>>    system is computationally singular: reciprocal condition number =
>>> 1.10221e-35
>>>
>>> May you suggest me how to fix this problem please?
>>>
>>> Thanks in advance
>>>
>>>         [[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.
>>>
>>>
>> --
>> Patrick Burns
>> pburns at pburns.seanet.com
>> twitter: @burnsstat @portfolioprobe
>> http://www.portfolioprobe.com/blog
>> http://www.burns-stat.com
>> (home of:
>>  'Impatient R'
>>  'The R Inferno'
>>  'Tao Te Programming')
>>
>
>	[[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