Hi, all!
Anyone know an easy way to specify the following model.
Panel dataset, with stock through time, by firm.
I want to run a model of y on a bunch of explanatory variables, and one
dummy for each firm, which is 1 for observations that come from firm i,
and 0 everywhere else. I have over
Hi
If you'd like to fit a fixed effect model without random
effects, you can use lm() or aov() (see ?lm and ?aov). If your
variable is a factor (?factor) then you can specify your model
in lm() without coding all dummy variables.
Regards,
Christoph Buser
You can turn the identity vector of the firms into a factor and do lm
Jean
On Mon, 5 Sep 2005, Tobias Muhlhofer wrote:
Hi, all!
Anyone know an easy way to specify the following model.
Panel dataset, with stock through time, by firm.
I want to run a model of y on a bunch of
So are you guys saying to me that if I have variable firm which is the
factor of all firm identifiers, I could just go
lm(y ~ x + firm)
and that will implicitly include a dummy for each level of factor firm,
thus making this a fixed effects (aka LSDV) model?
T
Jean Eid wrote:
You can turn
You will need to ensure that firm is a factor and not numerical (i.e.
continuous). Here is an example
firm - factor( sample(1:3, 20, replace=T) )
x1 - runif(20)
y- rnorm(20)
summary( fit - lm( y ~ -1 + x1 + firm ) )
...
Coefficients:
Estimate Std. Error t value Pr(|t|)
here's an example
data(iris)
iris1-iris
iris1$setosa-0
iris1[iris1$Species%in%setosa, setosa]-1
iris1$versicolor-0
iris1$virginica-0
iris1[iris1$Species%in%virginica, virginica]-1
iris1[iris1$Species%in%versicolor, versicolor]-1
iris1-iris1[, !colnames(iris1)%in%Species]
Dang! That's awesome!
Being at the end of an empirical PhD in which all the econometrics was
done in R, I was already a longtime R enthusiast, but you never stop
learning more neat features!!!
YAY to everyone involved in R's development
Toby
Adaikalavan Ramasamy wrote:
You will need