Zhang Yanwei - Princeton-MRAm
2008-Aug-08 14:50 UTC
[R] Multivariate regression with constraints
Hi all, I am running a bivariate regression with the following: p1=c(184,155,676,67,922,22,76,24,39) p2=c(1845,1483,2287,367,1693,488,435,1782,745) I1=c(1530,1505,2505,204,2285,269,1271,298,2023) I2=c(8238,6247,6150,2748,4361,5549,2657,3533,5415) R1=I1-p1 R2=I2-p2 x1=cbind(p1,R1) y1=cbind(p2,R2) fit1=lm(y1~-1+x1) summary(fit1) Response 2: Coefficients: Estimate Std. Error t value Pr(>|t|) x1p1 -1.4969 2.7004 -0.554 0.59662 x1R1 3.0937 0.8366 3.698 0.00767 ** One can see that in the second regression, i.e. R2~-1+p1+R1, the coefficient for p1 is not significant. I wonder if I can run this bivariate regression again with the constraint that the coefficient for p1 in the second regression equation is zero? Thanks a lot. Sincerely, Yanwei Zhang Department of Actuarial Research and Modeling Munich Re America Tel: 609-275-2176 Email: yzhang@munichreamerica.com<mailto:yzhang@munichreamerica.com> [[alternative HTML version deleted]]
Hi Zhang , take a look to sur package http://www.systemfit.org/ regards, Patrizio Frederic +------------------------------------------------- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frederic at unimore.it +------------------------------------------------- 2008/8/8 Zhang Yanwei - Princeton-MRAm <YZhang at munichreamerica.com>:> Hi all, > I am running a bivariate regression with the following: > > p1=c(184,155,676,67,922,22,76,24,39) > p2=c(1845,1483,2287,367,1693,488,435,1782,745) > I1=c(1530,1505,2505,204,2285,269,1271,298,2023) > I2=c(8238,6247,6150,2748,4361,5549,2657,3533,5415) > R1=I1-p1 > R2=I2-p2 > > x1=cbind(p1,R1) > y1=cbind(p2,R2) > > fit1=lm(y1~-1+x1) > summary(fit1) > > Response 2: > Coefficients: > Estimate Std. Error t value Pr(>|t|) > x1p1 -1.4969 2.7004 -0.554 0.59662 > x1R1 3.0937 0.8366 3.698 0.00767 ** > > > One can see that in the second regression, i.e. R2~-1+p1+R1, the coefficient for p1 is not significant. I wonder if I can run this bivariate regression again with the constraint that the coefficient for p1 in the second regression equation is zero? Thanks a lot. > > Sincerely, > Yanwei Zhang > Department of Actuarial Research and Modeling > Munich Re America > Tel: 609-275-2176 > Email: yzhang at munichreamerica.com<mailto:yzhang at munichreamerica.com> > > > [[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. >
Zhang Yanwei - Princeton-MRAm
2008-Aug-08 17:25 UTC
[R] Multivariate regression with constraints
Thanks. If I set the coefficient of p1 equal to zero, then I only have three parameters left in the model. Suppose e is the residual matrix for this regression, 2 by 2 here. Is the covariance matrix for the residuals, 2 by 2, still estimated by t(e)%*%e/(n-3), where n is the number of observations? Also, I want to specify different weights for each of the two equations. For example, the first regression weighted by p1, and the second by R1. How can I do that using systemfit? The systemfit("SUR") seems to deal with this problem, but it does not allow one to set the weights explicitely. I wonder if you would help me out on that. Thanks a lot. Really appreiciate. Sincerely, Yanwei Zhang Department of Actuarial Research and Modeling Munich Re America Tel: 609-275-2176 Email: yzhang at munichreamerica.com -----Original Message----- From: Patrizio Frederic [mailto:frederic.patrizio at gmail.com] Sent: Friday, August 08, 2008 12:57 PM To: Zhang Yanwei - Princeton-MRAm Cc: r-help at r-project.org Subject: Re: [R] Multivariate regression with constraints Hi Zhang , take a look to sur package http://www.systemfit.org/ regards, Patrizio Frederic +------------------------------------------------- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, Via Berengario 51, 41100 | Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frederic at unimore.it +------------------------------------------------- 2008/8/8 Zhang Yanwei - Princeton-MRAm <YZhang at munichreamerica.com>:> Hi all, > I am running a bivariate regression with the following: > > p1=c(184,155,676,67,922,22,76,24,39) > p2=c(1845,1483,2287,367,1693,488,435,1782,745) > I1=c(1530,1505,2505,204,2285,269,1271,298,2023) > I2=c(8238,6247,6150,2748,4361,5549,2657,3533,5415) > R1=I1-p1 > R2=I2-p2 > > x1=cbind(p1,R1) > y1=cbind(p2,R2) > > fit1=lm(y1~-1+x1) > summary(fit1) > > Response 2: > Coefficients: > Estimate Std. Error t value Pr(>|t|) > x1p1 -1.4969 2.7004 -0.554 0.59662 > x1R1 3.0937 0.8366 3.698 0.00767 ** > > > One can see that in the second regression, i.e. R2~-1+p1+R1, the coefficient for p1 is not significant. I wonder if I can run this bivariate regression again with the constraint that the coefficient for p1 in the second regression equation is zero? Thanks a lot. > > Sincerely, > Yanwei Zhang > Department of Actuarial Research and Modeling Munich Re America > Tel: 609-275-2176 > Email: yzhang at munichreamerica.com<mailto:yzhang at munichreamerica.com> > > > [[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. >
Zhang Yanwei - Princeton-MRAm
2008-Aug-08 17:43 UTC
[R] Multivariate regression with constraints
I should have stated this better. I want to fit this bivariate regressions with weights as well as contemporaneous correlation. One should use the systemfit(method="SUR") to have the model include the comtemporaneous correlation. But how can I specify the weights in addition? Just divide all the terms in the first equation by sqrt(p1) and those in the second by sqrt(R1) and then fit the bivariate regression? Thanks. Sincerely, Yanwei Zhang Department of Actuarial Research and Modeling Munich Re America Tel: 609-275-2176 Email: yzhang at munichreamerica.com -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Zhang Yanwei - Princeton-MRAm Sent: Friday, August 08, 2008 1:26 PM To: Patrizio Frederic Cc: r-help at r-project.org Subject: Re: [R] Multivariate regression with constraints Thanks. If I set the coefficient of p1 equal to zero, then I only have three parameters left in the model. Suppose e is the residual matrix for this regression, 2 by 2 here. Is the covariance matrix for the residuals, 2 by 2, still estimated by t(e)%*%e/(n-3), where n is the number of observations? Also, I want to specify different weights for each of the two equations. For example, the first regression weighted by p1, and the second by R1. How can I do that using systemfit? The systemfit("SUR") seems to deal with this problem, but it does not allow one to set the weights explicitely. I wonder if you would help me out on that. Thanks a lot. Really appreiciate. Sincerely, Yanwei Zhang Department of Actuarial Research and Modeling Munich Re America Tel: 609-275-2176 Email: yzhang at munichreamerica.com -----Original Message----- From: Patrizio Frederic [mailto:frederic.patrizio at gmail.com] Sent: Friday, August 08, 2008 12:57 PM To: Zhang Yanwei - Princeton-MRAm Cc: r-help at r-project.org Subject: Re: [R] Multivariate regression with constraints Hi Zhang , take a look to sur package http://www.systemfit.org/ regards, Patrizio Frederic +------------------------------------------------- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, Via Berengario 51, 41100 | Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frederic at unimore.it +------------------------------------------------- 2008/8/8 Zhang Yanwei - Princeton-MRAm <YZhang at munichreamerica.com>:> Hi all, > I am running a bivariate regression with the following: > > p1=c(184,155,676,67,922,22,76,24,39) > p2=c(1845,1483,2287,367,1693,488,435,1782,745) > I1=c(1530,1505,2505,204,2285,269,1271,298,2023) > I2=c(8238,6247,6150,2748,4361,5549,2657,3533,5415) > R1=I1-p1 > R2=I2-p2 > > x1=cbind(p1,R1) > y1=cbind(p2,R2) > > fit1=lm(y1~-1+x1) > summary(fit1) > > Response 2: > Coefficients: > Estimate Std. Error t value Pr(>|t|) > x1p1 -1.4969 2.7004 -0.554 0.59662 > x1R1 3.0937 0.8366 3.698 0.00767 ** > > > One can see that in the second regression, i.e. R2~-1+p1+R1, the coefficient for p1 is not significant. I wonder if I can run this bivariate regression again with the constraint that the coefficient for p1 in the second regression equation is zero? Thanks a lot. > > Sincerely, > Yanwei Zhang > Department of Actuarial Research and Modeling Munich Re America > Tel: 609-275-2176 > Email: yzhang at munichreamerica.com<mailto:yzhang at munichreamerica.com> > > > [[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. >______________________________________________ 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.