Re: [R] restricted coefficient and factor in linear regression.

From: Paul Johnson <pauljohn32_at_gmail.com>
Date: Sun, 15 Jun 2008 14:14:52 -0500

On Sat, Jun 14, 2008 at 7:49 AM, Oh Dong-hyun <oh.dongh_at_gmail.com> wrote:
> Hi,
>
> my data set is data.frame(id, yr, y, l, e, k).
>
> I would like to estimate Lee and Schmidts (1993, OUP) model in R.
>
> My colleague wrote SAS code as follows:
> ** procedures for creating dummy variables are omitted **
> ** di# and dt# are dummy variables for industry and time **
> data a2; merge a1 a2 a; by id yr;
> proc sysnlin maxit=100 outest=beta2;
> endogenous y;
> exogenous l e k di1-di12 dt2-dt10;
> parms a0 0.94 al -0.14 ae 1.8 ak -0.9
> b1 0 b2 0 b3 0 b4 0 b5 0 b6 0 b7 0 b8 0 b9 0 b10 0 b11 0
> b12 0 c2 0 c3 0 c4 0 c5 0 c6 0 c7 0 c8 0 c9 0 c10 0;
> y=a0+al*l+ae*e+ak*k
> +(b1*di1+b2*di2+b3*di3+b4*di4+b5*di5+b6*di6
> +b7*di7+b8*di8+b9*di9+b10*di10+b11*di11+b12*di12)*
> (1*dt1+c2*dt2+c3*dt3+c4*dt4+c5*dt5+c6*dt6+c7*dt7
> +c8*dt8+c9*dt9+c10*dt10);
> title '***** lee/schmidt parameter estimates *****';
>
> My R code is as follows:
> ##############
> library(plm)
> dt <- read.table("dt.dta", sep = "\t", header= T)
> dt$id <- factor(dt$id)
> dt$yr <- factor(dt$yr)
> fit.model <- I(log(y)) ~ I(log(l)) + I(log(e)) + yr * id
> re.fit.gls <- pggls(fit.model, data = dt)
> #################
>
> I've got the following error message:
> ##### Error message ###############
> Error in dimnames(x) <- dn :
> length of 'dimnames' [2] not equal to array extent
> #### End of Error message############
>
> I would like to figure out three things.
> 1. How can I restrict coefficient in model? As you can see in SAS code,
> coefficient of dt1 is restricted to 1.
> 2. If it is possible to restrict coefficients, it is possible to restrict
> coefficients of factors? If so, how?
>

Hello, I've not used the package plm very much. I've been reading its docs now and I don't think it is exactly what you want, since you've not described a panel data problem. Possibly you need to take this up with the plm author.

If I were you, I'd go in another direction. First, fit with ordinary 'lm', just to check sanity of data. Second, get the package "systemfit" in which there is a nonlinear system fitting routine comparable to the SAS sysnlin that your colleague is using.

Let us know how it works out.

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

______________________________________________
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.
Received on Sun 15 Jun 2008 - 19:18:37 GMT

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 Sun 15 Jun 2008 - 21:31:11 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.

list of date sections of archive