[R] restricted coefficient and factor for linear regression.
Oh Dong-hyun
r.arecibo at gmail.com
Fri Jun 13 19:23:18 CEST 2008
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?
Thanks in advance.
Best,
=========================================================
Dong-hyun Oh
Center of Excellence for Science and Innovation Studies
Royal Institute or Technology, Sweden
e-mail: oh.dongh at gmail.com
cel: +46 73 563 45 22
More information about the R-help
mailing list