Re: [R] error in vcovNW
Hi Thanks for the reminder. Actually I want to analyse whether present value of variable A is Granger caused by lag values of B and test linear hypothesis "B1,B2,B3,B4,B5=0". Therefore, to get robust standard error NeweyWest estimates are applied. Saba On Saturday, 19 December 2015, 23:26, Achim Zeileiswrote: On Sat, 19 Dec 2015, Saba Sehrish wrote: > Thank you. The issue is resolved by scaling the data in millions. That solves the numerical problem but the second issue (inappropriateness of the Newey-West estimator for an autoregressive model) persists. > Saba > > > On Saturday, 19 December 2015, 15:06, Achim Zeileis > wrote: > > > On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote: > > > Hi I am using NeweyWest standard errors to correct lm( ) output. For > example: > > lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5) > > vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)) > > > > I am using package(sandwich) for NeweyWest. Now when I run this command, > it gives following error: > > Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) > :system is computationally singular: reciprocal condition number = > 7.49468e-18 > > > > Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are > > simply lag variables. Can you help me removing this error please? > > Without trying to replicate the error, there are at least two issues: > > (1) You should scale your data to use more reasonable orders of magnitude, > e.g., in millions. This will help avoiding numerical problems. > > (2) More importantly, you should not employ HAC/Newey-West standard errors > in autoregressive models. If you use an autoregressive specification, you > should capture all relevant autocorrelations - and then no HAC estimator > is necessary. Alternatively, one may treat autocorrelation as a nuisance > parameter and not model it - but instead capture it in HAC standard > errors. Naturally, the former strategy will typically perform better if > the autocorrelations are more substantial. > > > Saba > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] error in vcovNW
On Sat, 19 Dec 2015, Saba Sehrish wrote: Thank you. The issue is resolved by scaling the data in millions. That solves the numerical problem but the second issue (inappropriateness of the Newey-West estimator for an autoregressive model) persists. Saba On Saturday, 19 December 2015, 15:06, Achim Zeileiswrote: On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote: > Hi I am using NeweyWest standard errors to correct lm( ) output. For example: > lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5) > vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)) > > I am using package(sandwich) for NeweyWest. Now when I run this command, it gives following error: > Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system is computationally singular: reciprocal condition number = 7.49468e-18 > > Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are > simply lag variables. Can you help me removing this error please? Without trying to replicate the error, there are at least two issues: (1) You should scale your data to use more reasonable orders of magnitude, e.g., in millions. This will help avoiding numerical problems. (2) More importantly, you should not employ HAC/Newey-West standard errors in autoregressive models. If you use an autoregressive specification, you should capture all relevant autocorrelations - and then no HAC estimator is necessary. Alternatively, one may treat autocorrelation as a nuisance parameter and not model it - but instead capture it in HAC standard errors. Naturally, the former strategy will typically perform better if the autocorrelations are more substantial. > Saba __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] error in vcovNW
Hi I am using NeweyWest standard errors to correct lm( ) output. For example: lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5) vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)) I am using package(sandwich) for NeweyWest. Now when I run this command, it gives following error: Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system is computationally singular: reciprocal condition number = 7.49468e-18 Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are simply lag variables. Can you help me removing this error please? SabaA B 739171876.1 -30023111.44 487266676 21283768.23 372851476.2 -40442678.43 63229603.27 10656220.9 42006490.16 -11533497.55 190745334.6 -5394116.27 172710138.6 -15091006.48 231059302.6 23568469.87 519602621.8 64131342.59 997358074.8 23623980.29 291864614.4 65303351.45 80844732.71 69354076.9 701170068.3 106386633.8 440463911.3 105165515.5 67256920.87 57943316.76 64101070.8 50209212.89 -71028831.0331292473.88 -197854142.532805225.46 -189290263.34638671.93 -520470164.7962640792.4 -471115277.3-1093666458 -955868238 -102261874.8 -1098715609 -101020121.9 -738546938.5-6916.12 -1085874990 -136045443.9 193157212.1 -2473692.63 -6269415.53 -28891931 199824564.8 5127403.1 302376261.5 6655585.13 -67851220.11-13741489.54 -370952947 -24219268.21 34404761.25 27283468.9 -428849252.4-85765593.88 -924463014 -112574045.5 -495270249.6-2965265.14 -668618574.5-39930551.16 -10436100.7790010638.89 -281751636.5-22157882.66 -385194083 43186980.6 104681563.1 40450660.38 -15283793.5260454998.18 -26567438.3752683189.8 -98612309.0825319905.01 21402708.99 44019777.51 -74846057.0545104511.78 -951203476.39858962.32 -338231274.186293283.74 -424023473.5102767273.6 20027128.13 185851266 -815545.8 163237321.2 46996041.85 194808435 134571135.3 122988858.9 -183703166 53086443.78 212728895.5 73301796.9 -197466304.2-11713239.02 -393762814.711580149.74 -343324235.6-13610112.45 -260888613.910047787.51 -759009960.6-151251490.8 -383721497 -151251490.8 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] error in vcovNW
Thank you. The issue is resolved by scaling the data in millions. Saba On Saturday, 19 December 2015, 15:06, Achim Zeileiswrote: On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote: > Hi I am using NeweyWest standard errors to correct lm( ) output. For example: > lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5) > vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)) > > I am using package(sandwich) for NeweyWest. Now when I run this command, it > gives following error: > Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) > :system is computationally singular: reciprocal condition number = 7.49468e-18 > > Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are > simply lag variables. Can you help me removing this error please? Without trying to replicate the error, there are at least two issues: (1) You should scale your data to use more reasonable orders of magnitude, e.g., in millions. This will help avoiding numerical problems. (2) More importantly, you should not employ HAC/Newey-West standard errors in autoregressive models. If you use an autoregressive specification, you should capture all relevant autocorrelations - and then no HAC estimator is necessary. Alternatively, one may treat autocorrelation as a nuisance parameter and not model it - but instead capture it in HAC standard errors. Naturally, the former strategy will typically perform better if the autocorrelations are more substantial. > Saba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] error in vcovNW
On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote: Hi I am using NeweyWest standard errors to correct lm( ) output. For example: lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5) vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)) I am using package(sandwich) for NeweyWest. Now when I run this command, it gives following error: Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system is computationally singular: reciprocal condition number = 7.49468e-18 Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are simply lag variables. Can you help me removing this error please? Without trying to replicate the error, there are at least two issues: (1) You should scale your data to use more reasonable orders of magnitude, e.g., in millions. This will help avoiding numerical problems. (2) More importantly, you should not employ HAC/Newey-West standard errors in autoregressive models. If you use an autoregressive specification, you should capture all relevant autocorrelations - and then no HAC estimator is necessary. Alternatively, one may treat autocorrelation as a nuisance parameter and not model it - but instead capture it in HAC standard errors. Naturally, the former strategy will typically perform better if the autocorrelations are more substantial. Saba __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.