From: John Fox <jfox_at_mcmaster.ca>

Date: Thu 05 Apr 2007 - 16:45:14 GMT

John Fox

Department of Sociology

McMaster University

Hamilton, Ontario

Canada L8S 4M4

905-525-9140x23604

http://socserv.mcmaster.ca/jfox

R-help@stat.math.ethz.ch 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. Received on Fri Apr 06 02:50:25 2007

Date: Thu 05 Apr 2007 - 16:45:14 GMT

Dear Martin,

I'll address only part of your question, which is how to get the code for linear.hypothesis() in the car package: linear.hypothesis() is an S3 generic function with several methods:

> library(car)

> methods("linear.hypothesis")

[1] linear.hypothesis.default* linear.hypothesis.glm*
[3] linear.hypothesis.lm* linear.hypothesis.mlm*

Non-visible functions are asterisked

So the function has methods for glm, lm, and mlm objects, along with a default method, which, as explained in ?linear.hypothesis, should work with models for which coef() and vcov() methods exist.

To see linear.hypothesis.default(), which isn't exported from the car namespace, you can, e.g., type

car:::linear.hypothesis.default

I'm not sure why you get different results for the F-test but similar results for the Wald test. Which F-test seems to square with the Wald test (you don't show the Wald tests)?

I hope this helps,

John

John Fox

Department of Sociology

McMaster University

Hamilton, Ontario

Canada L8S 4M4

905-525-9140x23604

http://socserv.mcmaster.ca/jfox

> -----Original Message-----

*> From: r-help-bounces@stat.math.ethz.ch
**> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Martin Ivanov
**> Sent: Thursday, April 05, 2007 11:28 AM
**> To: r-help@stat.math.ethz.ch
**> Subject: [R] about systemfit
**>
**> Hello. I am still a newbie in R. Excuse me if I am asking
**> something obvious. My efforts to get an answer through
**> browsing the mailing archives failed. I want to perform an
**> augmented Dickey-Fuller test and to obtain AIC and BIC and to
**> be able to impose some linear restrictions on the ADF
**> regression so as to decide the correct order of
**> autoregression. However I could find no obvious way to impose
**> linear restrictions or to obtain AIC from the the result of
**> ADF.test from uroot. That is why I turned to systemfit. I ran
**> the ADF regression with systemfit and obtained the same
**> coefficient estimates as through ADF.test (as it had to be).
**> Unfortunately I could not find how to extract AIC from the
**> result of systemfit, so I evaluated the ADF regression by lm.
**> So far so good. However the results of ftest.systemfit and
**> linear.hypothesis from the "car" package are very different,
**> while the results from waldtest.systemfit and
**> linear.hypothesis coincide. I have no explanation for this
**> issue a nd I could not see the code of linear.hypothesis.
**> When I type "linear.hypothesis" I get:
**> function (model, ...)
**> UseMethod("linear.hypothesis")
**> <environment: namespace:car>
**>
**> but when I type "ftest.systemfit", I do see the actual code. Why?
**> Anyway, here are the results in more detail:
**>
**> eqns<-list(eq = y ~ trend+ x1 + x[,1] + x[,2] + x[,3] + x[,4]
**> + x[,5] + x[,6] + x[,7] + x[,8] + x[,9] + x[,10] + x[,11] +
**> x[,12] + x[,13]
**>
**> Rrestr10<-matrix(0,10,16);Rrestr10[1,16]=Rrestr10[2,15]=Rrestr
*

10[3,14]=Rrestr10[4,13]=Rrestr10[5,12]=Rrestr10[6,11]=Rrestr10[7,10]=Rrestr1
0[8,9]=Rrestr10[9,8]=Rrestr10[10,7]=1

*>
*

> adfResc<-systemfit(method="OLS",eqns=eqns,R.restr=Rrestr10)

*>
**> adfResu<-systemfit(method="OLS",eqns=eqns)
**>
**> adfResulm<-lm(formula=eqns$eq)
**>
**> ftest.systemfit( object=adfResu, R.restr=Rrestr10) :
**>
**> F-test for linear parameter restrictions in equation systems
**> F-statistic: 9.083
**> degrees of freedom of the numerator: 10 degrees of freedom of
**> the denominator: 127
**> p-value: 3.449e-11
**>
**> linear.hypothesis(model=adfResulm,hypothesis.matrix=Rrestr10,t
**> est="F"):
**>
**> Res.Df RSS Df Sum of Sq F Pr(>F)
**> 1 127 7.3782
**> 2 137 7.6848 -10 -0.3066 0.5277 0.868
**>
**> As I said, the results of
**> the chisquare test with linear.hypothesis and the
**> waldtest.systemfit coincide.
**> I have one more problem. This is the output of lrtest.systemfit:
**> lrtest.systemfit(resultc=adfResc,resultu=adfResu)
**>
**> Likelihood-Ratio-test for parameter restrictions in equation systems
**> LR-statistic:
**> degrees of freedom:
**> p-value:
**>
**> Why do I get empty values?
**> In summary, I need to understand why the two ftests give
**> different results; why lrtest.systemfit gives empty output;
**> is there some way to extract AIC and BIC from object of class
**> systemfit or from the result of ADF.test.
**>
**> Excuse me if I am asking something too obvious, but I am
**> really at a loss.
**>
**> Any suggestions on any of the above questions will be welcomed.
**>
**> Regards,
**> Martin
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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. Received on Fri Apr 06 02:50:25 2007

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Thu 05 Apr 2007 - 17:30:54 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*