Jinghua Xie
2010-Aug-27 12:26 UTC
[R] calculate the elasticities by linear.hypothesi commander
Dear all If I run the model and get the estimated parameter a11. Then I want to use the estimated parameter to calculate the elasticities by using the formula e11=a11/mw1-1. What I have done is using the command of linear. Hypothesis.> formulas1=dWfresh~dlnPfresh+dlnPfrozen+dlnPsmoke+dlnQP+cosL1+sinL1+cosL2> formulas2=dWsmoke~dlnPfresh+dlnPfrozen+dlnPsmoke+dlnQP+cosL1+sinL1+cosL2> formulas12=list(formulas1,formulas2)> > salmon1=systemfit(formulas12, data=Fsalmon2, method="SUR")> summary (salmon1)>MWfresh<-mean (Wfresh2, data=Fsalmon)>MWfrozen<-mean (Wfrozen2, data=Fsalmon)>MWsmoke<-mean (Wsmoke2, data=Fsalmon)>restricte11=c("eq1_dlnPfresh/MWfresh-1=0")>linear.hypothesis(salmonsdlnf1r, restricte11, test="Chisq")It does not work. However, if I replace MWfresh with the pure numerical number restricte11=c("eq1_dlnPfresh/0.42-1=0") It works. Can anyone help me to work it out.? Thanks Jinghua Xie University of Tromsø, Norway [[alternative HTML version deleted]]
John Fox
2010-Aug-27 13:20 UTC
[R] calculate the elasticities by linear.hypothesi commander
Dear Jinghua Xie, This is, I assume, the linear.hypothesis function in the car package, which is deprecated in favour of linearHypothesis. Please see below:> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]On> Behalf Of Jinghua Xie > Sent: August-27-10 8:26 AM > To: r-help at r-project.org > Subject: [R] calculate the elasticities by linear.hypothesi commander > > Dear all > > > > If I run the model and get the estimated parameter a11. Then I want touse> the estimated parameter to calculate the elasticities by using the formula > e11=a11/mw1-1. What I have done is using the command of linear. > Hypothesis. > > > > > formulas1=dWfresh~dlnPfresh+dlnPfrozen+dlnPsmoke+dlnQP+cosL1+sinL1+cos > > L2 > > > formulas2=dWsmoke~dlnPfresh+dlnPfrozen+dlnPsmoke+dlnQP+cosL1+sinL1+cos > > L2 > > > formulas12=list(formulas1,formulas2) > > > > salmon1=systemfit(formulas12, data=Fsalmon2, method="SUR") > > > summary (salmon1) > > > > >MWfresh<-mean (Wfresh2, data=Fsalmon) > > >MWfrozen<-mean (Wfrozen2, data=Fsalmon) > > >MWsmoke<-mean (Wsmoke2, data=Fsalmon) > > > > >restricte11=c("eq1_dlnPfresh/MWfresh-1=0") > > > > >linear.hypothesis(salmonsdlnf1r, restricte11, test="Chisq") > > > > It does not work. However, if I replace MWfresh with the pure numerical > number > > restricte11=c("eq1_dlnPfresh/0.42-1=0") > > > > It works.linearHypothesis interprets names such as eq1_dlnPfresh and MWfresh as coefficient names, so you have to use numeric constants; I don't think "eq1_dlnPfresh/0.42-1=0" will work, however, because division isn't allowed; you would have to rephrase as "2.38*eq1_dlnPfresh - 1". The deltaMethod function, also in the car package, is more flexible. I hope this helps, John -------------------------------- John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox> > > > Can anyone help me to work it out.? > > > > Thanks > > > > Jinghua Xie > > University of Tromsx, Norway > > > > > > > [[alternative HTML version deleted]]