[R] Waldtest and different sample sizes

Millo Giovanni giovanni.millo at generali.com
Wed May 21 18:28:55 CEST 2014


Dear Katharina,

if I get it right, you just want to assess the significance of 'lag(numfull_FCRlong,1)'. For this purpose, you can simply look at the relevant t-statistic in the model summary. BTW, the latter is the square root of the (F-version of the) Wald test for the restriction you are interested in, so it is asymptotically equivalent to what you wanted to do.

So you just need to estimate the nesting model (caus2, for you) and look at the p.value. Or do I make it too simple?

Best wishes,
Giovanni

Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 3,
34132 Trieste (Italy)
tel. +39 040 671184
fax  +39 040 671160

--------- original message ----------
Date: Wed, 21 May 2014 10:49:44 +0200
From: "Katharina Mersmann" <kmersman at smail.uni-koeln.de>
To: <r-help at r-project.org>
Subject: [R] Waldtest and different sample sizes
Message-ID: <000001cf74d1$9cc81960$d6584c20$@uni-koeln.de>
Content-Type: text/plain

Hey R Users!

I?m trying to run a waldtest comparing an restricted and unrestricted model.

But sample size is different (because of NA?s), so I get an error message:



> caus2<-plm(CSmean~ lag(CSmean,1)+ lag(numfull_FCRlong,1)+

+                GDP+linpol_GDPpCapita+fort_budget+fort_percentDebt+

+                linpol_primSurplus+Inflation+lagBYmean,

+                data = data.plm, index = c("countrynr","quartal"),model =
"within")

> waldtest(caus2,update(caus2,.~.-lag(numfull_FCRlong,1),test = "Chisq")

Fehler in waldtest.default(caus2, update(caus2, . ~ . ?
lag(numfull_FCRlong,1),  :

  models were not all fitted to the same size of dataset



So I tried to remove the NA?s first:

> data.plm.naomit<-na.omit(data.plm)

> caus2<-plm(CSmean~ lag(CSmean,1)+ lag(numfull_FCRlong,1)+

+                GDP+linpol_GDPpCapita+fort_budget+fort_percentDebt+

+                linpol_primSurplus+Inflation+lagBYmean,

+                data = data.plm.naomit, index =
c("countrynr","quartal"),model = "within")

Fehler in model.matrix.pFormula(formula, data, rhs = 1, model = model,  :

  NA in the individual index variable

Zus?tzlich: Warnmeldung:

In `[.data.frame`(index, as.numeric(rownames(mf)), ) :

  NAs durch Umwandlung erzeugt

> waldtest(caus2,update(caus2,.~.-lag(numfull_FCRlong,1),test = "Chisq")

Fehler in waldtest.default(caus2, update(caus2, . ~ . ?
lag(numfull_FCRlong,1),  :

  models were not all fitted to the same size of dataset



But this doesn?t work either, because of the error during the fitting
process, another way:

>
caus2_small<-update(caus2,.~.-lag(numfull_FCRlong,1),data=data.plm[-ch2$na.a
ction])

Fehler in -ch2$na.action : ung?ltiges Argument f?r un?ren Operator

> waldtest(caus2,ch2_small)



What should I do? Is the removal of NA?s a common procedure?





Thanks for your advice and have a nice day ;)

Katie


        [[alternative HTML version deleted]]

Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}



More information about the R-help mailing list