[R] [R-SIG-Finance] error in "ca.jo"

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Dec 24 23:49:00 CET 2013


On Tue, Dec 24, 2013 at 3:36 PM, mamush bukana <mamushbukana at gmail.com> wrote:
> Hi Jeff,
> >From your words (if our words really describe us), I hope you don't expect
> me to teach you that this is "r-help" room. I don't expect you to tell me
> that I am a layman. I already know it and that is why I am here seeking a
> help. If I am an expert of things I asked here, there is no need for me to
> come here with such "stupid (in your understanding)" question. I know there
> are people on this planet who consider themselves advanced only when they
> meet stupid people like me - you may be one of them. It is always helpful
> for others if you could write a single line with a helping mind than
> writing tones of useless junk words. R is applied statistical language, to
> be used in different professions. So, don't expect all R users to be
> "experts" like you are. If you can't help people, at least keep yourself
> away from helping environment.
>
This isn't just R-help.  You've also cross-posted (which many feel is
rude) to R-SIG-Finance, even though this is off-topic for
R-SIG-Finance.  Your problem is with R's control-flow and
error-handling, not anything finance-related.  Also, these being
"help" forums and you being a laymen does not mean you can ignore the
guidelines.

Rather than (again) not following the suggestions in the posting guide
("If you feel insulted by some response to a post of yours, don't make
any hasty response in return - you're more likely than not to regret
it."), you would be wise to follow Jeff's advice:
1) Stop posting in HTML, so people can copy/paste your code.
2) Provide a small, self-contained reproducible example.
3) Carefully read ?try and ?tryCatch; use rseek.org to search for examples.
4) Skip 1-3 and find some one-on-one help in person.

It would also be wise to follow *both* of Pat's recommendations (you
ignored his suggestion to save some information from the ca.jo
calculations).

In short, please follow the posing guide, rather than expect people to
voluntarily help you on your terms.

> Cheers
>
> Bukana
>
>
> On Tue, Dec 24, 2013 at 5:23 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>wrote:
>
>> 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.
>>
>>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-help mailing list