londonphd
2013-Apr-09 14:59 UTC
[R] sorting the VAR model output according to variable names??
I was wondering if one can have the coefficients of VAR model sorted according to variable names rather than lags. If you notice below, the output is sorted according to lags.>VAR(cbind(fossil,labour),p=2,type="const")VAR Estimation Results: ======================= Estimated coefficients for equation fossil: =========================================== Call: fossil = fossil.l1 + labour.l1 + fossil.l2 + labour.l2 + const fossil.l1 labour.l1 fossil.l2 labour.l2 const 0.4686535 -0.5324335 0.2308964 0.8777865 -0.6711897 Estimated coefficients for equation labour: =========================================== Call: labour = fossil.l1 + labour.l1 + fossil.l2 + labour.l2 + const fossil.l1 labour.l1 fossil.l2 labour.l2 const 0.01431961 0.99648957 0.04160058 -0.11316312 1.11396823 If you take the last equation above (labour equation) the output is given as follows: fossil.l1 labour.l1 fossil.l2 labour.l2 const is there any way I can have the output of this equation as follows: fossil.l1 fossil.l2 labour.l1 labour.l2 const It makes it easy to do hypothesis testing on specific lagged coefficients. -- View this message in context: http://r.789695.n4.nabble.com/sorting-the-VAR-model-output-according-to-variable-names-tp4663770.html Sent from the R help mailing list archive at Nabble.com.
Pfaff, Bernhard Dr.
2013-Apr-10 08:12 UTC
[R] sorting the VAR model output according to variable names??
Dear LondonPhd, assuming that you have assigned 'mod' to your VAR() call, you can run the following: lapply(coef(mod), function(x) x[sort(rownames(x)), ]) In general, the coef-method will retrieve the estimated coefficients and you can then do the reordering to your liking. Best, Bernhard -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von londonphd Gesendet: Dienstag, 9. April 2013 16:59 An: r-help at r-project.org Betreff: [R] sorting the VAR model output according to variable names?? I was wondering if one can have the coefficients of VAR model sorted according to variable names rather than lags. If you notice below, the output is sorted according to lags.>VAR(cbind(fossil,labour),p=2,type="const")VAR Estimation Results: ======================= Estimated coefficients for equation fossil: ==========================================Call: fossil = fossil.l1 + labour.l1 + fossil.l2 + labour.l2 + const fossil.l1 labour.l1 fossil.l2 labour.l2 const 0.4686535 -0.5324335 0.2308964 0.8777865 -0.6711897 Estimated coefficients for equation labour: ==========================================Call: labour = fossil.l1 + labour.l1 + fossil.l2 + labour.l2 + const fossil.l1 labour.l1 fossil.l2 labour.l2 const 0.01431961 0.99648957 0.04160058 -0.11316312 1.11396823 If you take the last equation above (labour equation) the output is given as follows: fossil.l1 labour.l1 fossil.l2 labour.l2 const is there any way I can have the output of this equation as follows: fossil.l1 fossil.l2 labour.l1 labour.l2 const It makes it easy to do hypothesis testing on specific lagged coefficients. -- View this message in context: http://r.789695.n4.nabble.com/sorting-the-VAR-model-output-according-to-variable-names-tp4663770.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. ***************************************************************** Confidentiality Note: The information contained in this ...{{dropped:10}}