[R] Extracting results from the VAR output

Rui Barradas ruipbarradas at sapo.pt
Fri Jul 27 13:34:28 CEST 2012


I'm not familiar with package urca but your problem seems to be in the 
access of a list member.
The operator '$' is an alternative to '[[', and you are right, the 
latter is recommended programmatically.

Try something along the lines of the following.

VARrow[[ "varresult" ]][[ "Liabilities" ]]

And note that you can use numbers instead of the members' names.
str(VARrow) would give the structure of the variable and the appropriate 
numbers to use (just count).

Hope this helps,

Rui Barradas

Em 27-07-2012 09:57, Rmillan escreveu:
> Hi everyone,
> I'm working with the Vector Autoregressive Model (VAR), and it seems like
> the ur.ca package provides the best
> function for this purpose.
> My problem is, that I don't know how to extract a certain value from the
> output without using the variables names.
> I was hoping that this could be done by using numerical value, e.g. [1],
> instead of writing for instance $Liabilities. The reason why I want to do
> this is, that this would help me to automize the process, since I may not
> use the variable Liabilities next time.
> Here is an example when the process works, but I have to do it manually by
> typing in $Liabilities
> VARrow<-VAR(data,p=1,type="const")
> row<-VARrow$varresult$Liabilities$coefficient
> row[1]
> Liabilities.l1
>      0.06898797
> It would be nice if I could type in e.g. colnames(data)[1] instead of
> Liabilities (because colnames(data)[1] referes to Liabilites) but this
> command just says the value is NULL instead 0.06898797....
> Any help is much appriciated
> --
> View this message in context: http://r.789695.n4.nabble.com/Extracting-results-from-the-VAR-output-tp4638072.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> 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