From: Arne Henningsen <arne.henningsen_at_googlemail.com>

Date: Tue, 10 Jun 2008 08:33:19 +0200

Date: Tue, 10 Jun 2008 08:33:19 +0200

Hi Keith!

On Monday 09 June 2008 16:27, Woolner, Keith wrote:

> [...]

*> After I sent my initial message, I came across the Systemfit package,
**> which allows specification of constraints on parameters. In theory,
**> this should solve my problem perfectly. However, I was not able to get
**> it to work with my data, as every attempt yielded the following error:
**>
**> Error in dimnames(x) <- dn :
**> length of 'dimnames' [2] not equal to array extent
**>
**> I suspect that it is related to some of my variables being factors
**> rather than numeric.
*

Run this regression without constraints (works)

systemfit(X2 ~ X1 + E1 + E2,"OLS", data=df )

Take a look at the coefficients: We have *10* coefficients now (because "E1" and "E2" are factors. Hence, your restriction matrix must have *10* columns. For instance, if you want to restrict the coefficients of the "B"s in "E1" and "E2" (third and seventh coefficient, respectively) to be equal but opposite in sign, you could do the following:

tx2 <- matrix(0,nrow=1,ncol=10)

tx2[1,3]<- 1

tx2[1,7]<- 1

systemfit(X2 ~ X1 + E1 + E2,"OLS", data=df, restrict.matrix=tx2)

> Is systemfit able to deal with factors as independent variables having

*> constraints, and if so, is there some trick in formulating the problem?
**> I searched through the package documentation, but did not see mention of
**> factors being either supported or unsupported.
*

Until now, I thought that it not necessary to say something about factors, because they should work in systemfit as in other R functions (e.g. lm). The documentation says that "restrict.matrix" must be a j x k matrix, where k is the number of all parameters (NOT the number of all regressors, which differs if some regressors are factors). Hence, I think that the documentation is clear enough. However, please tell me if you have any suggestions for improving the documentation.

Best wishes,

Arne

-- Arne Henningsen http://www.arne-henningsen.nameReceived on Tue 10 Jun 2008 - 07:03:14 GMT

______________________________________________ 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.

- application/pgp-signature attachment: stored

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

Archive generated by hypermail 2.2.0, at Tue 10 Jun 2008 - 14:30:38 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.
*