Re: [R] extract cov matrix in summary.rq and use as a matrix.
Dear Michael, Thank you very much for your suggestion. It indeed worked! All the best, Julia > CC: r-help@r-project.org > From: michael.weyla...@gmail.com > Subject: Re: [R] extract cov matrix in summary.rq and use as a matrix. > Date: Mon, 5 Dec 2011 07:55:45 -0500 > To: julia.l...@hotmail.co.uk > > I'm not at my desk so this is untested, but I'm pretty sure double brackets > will do the trick: > > qf2_1[[3]] > > M > > On Dec 5, 2011, at 7:14 AM, Julia Lira wrote: > > > > > Dear all, > > > > I need to extract the covariance matrix of my quantile regression > > estimation to use in a test. My regression is: > > > > qf2_1 <- summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE) > > > > I can extract the covaraince matrix by using: qf2_1 [3]. However, if I try > > to use it in the test, it does not work. I only need to transform qf2_1[3] > > in a matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, ncol=3) but > > it also does not work. By using the latter, I find: > > [,1] [,2] [,3] > > [1,] Numeric,9 Numeric,9 Numeric,9 > > [2,] Numeric,9 Numeric,9 Numeric,9 > > [3,] Numeric,9 Numeric,9 Numeric,9 > > > > Is there any other way to do it? > > > > Thanks a lot in advance! > > > > All the best, > > > > Julia > > > > > > > > > > > > > > > >[[alternative HTML version deleted]] > > > > __ > > R-help@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-help@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.
Re: [R] extract cov matrix in summary.rq and use as a matrix.
No problem, almost all "complicated" objects that get returned are internally lists so you have to use [[ to get at them as [ will just give you a list again. Take a look at ? '[[' # those should be back ticks for the official documentation. Best, M On Dec 5, 2011, at 8:09 AM, Julia Lira wrote: > Dear Michael, > > Thank you very much for your suggestion. > > It indeed worked! > > All the best, > > Julia > > > CC: r-help@r-project.org > > From: michael.weyla...@gmail.com > > Subject: Re: [R] extract cov matrix in summary.rq and use as a matrix. > > Date: Mon, 5 Dec 2011 07:55:45 -0500 > > To: julia.l...@hotmail.co.uk > > > > I'm not at my desk so this is untested, but I'm pretty sure double brackets > > will do the trick: > > > > qf2_1[[3]] > > > > M > > > > On Dec 5, 2011, at 7:14 AM, Julia Lira wrote: > > > > > > > > Dear all, > > > > > > I need to extract the covariance matrix of my quantile regression > > > estimation to use in a test. My regression is: > > > > > > qf2_1 <- summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE) > > > > > > I can extract the covaraince matrix by using: qf2_1 [3]. However, if I > > > try to use it in the test, it does not work. I only need to transform > > > qf2_1[3] in a matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, > > > ncol=3) but it also does not work. By using the latter, I find: > > > [,1] [,2] [,3] > > > [1,] Numeric,9 Numeric,9 Numeric,9 > > > [2,] Numeric,9 Numeric,9 Numeric,9 > > > [3,] Numeric,9 Numeric,9 Numeric,9 > > > > > > Is there any other way to do it? > > > > > > Thanks a lot in advance! > > > > > > All the best, > > > > > > Julia > > > > > > > > > > > > > > > > > > > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@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-help@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.
Re: [R] extract cov matrix in summary.rq and use as a matrix.
I'm not at my desk so this is untested, but I'm pretty sure double brackets will do the trick: qf2_1[[3]] M On Dec 5, 2011, at 7:14 AM, Julia Lira wrote: > > Dear all, > > I need to extract the covariance matrix of my quantile regression estimation > to use in a test. My regression is: > > qf2_1 <- summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE) > > I can extract the covaraince matrix by using: qf2_1 [3]. However, if I try to > use it in the test, it does not work. I only need to transform qf2_1[3] in a > matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, ncol=3) but it > also does not work. By using the latter, I find: > [,1] [,2] [,3] > [1,] Numeric,9 Numeric,9 Numeric,9 > [2,] Numeric,9 Numeric,9 Numeric,9 > [3,] Numeric,9 Numeric,9 Numeric,9 > > Is there any other way to do it? > > Thanks a lot in advance! > > All the best, > > Julia > > > > > > > >[[alternative HTML version deleted]] > > __ > R-help@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. __ R-help@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.
[R] extract cov matrix in summary.rq and use as a matrix.
Dear all, I need to extract the covariance matrix of my quantile regression estimation to use in a test. My regression is: qf2_1 <- summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE) I can extract the covaraince matrix by using: qf2_1 [3]. However, if I try to use it in the test, it does not work. I only need to transform qf2_1[3] in a matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, ncol=3) but it also does not work. By using the latter, I find: [,1] [,2] [,3] [1,] Numeric,9 Numeric,9 Numeric,9 [2,] Numeric,9 Numeric,9 Numeric,9 [3,] Numeric,9 Numeric,9 Numeric,9 Is there any other way to do it? Thanks a lot in advance! All the best, Julia [[alternative HTML version deleted]] __ R-help@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.