panel question (plm)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

panel question (plm)

Stephen J. Barr-2
Hello,

I am working on a data set (already as a plm.data object) located
here: http://econsteve.com/arch/plmWithDensity.Robj

With the following R session:
> library(plm)
...
>load("plmWithDensity.Robj")
>model <- plm(RATE ~ density08, data=plmWithDensity)
Error: subscript out of bounds

I am not understanding the "subscript out of bounds" error, as this is
a balanced panel and there are no holes in the data set. Any help
would be very much appreciated. The model I am trying to run is

> model2 <- plm(RATE~ AGR.PCT+SVC.PCT+IND.PCT+density08, data=plmWithDensity)

This code runs fine, but I do not get any coefficients for density08

> summary(model2)
Oneway (individual) effect Within Model

Call:
plm(formula = RATE ~ AGR.PCT + SVC.PCT + IND.PCT + density08,
    data = plmWithDensity)

Balanced Panel: n=89, T=26, N=2314

Residuals :
   Min. 1st Qu.  Median 3rd Qu.    Max.
-1860.0  -475.0    11.3   526.0  1250.0

Coefficients :
         Estimate Std. Error  t-value  Pr(>|t|)
AGR.PCT  34192.60    4281.07   7.9869 1.383e-15 ***
SVC.PCT   4024.83     457.17   8.8037 < 2.2e-16 ***
IND.PCT -16545.62    1541.32 -10.7347 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:    985150000
Residual Sum of Squares: 852060000
F-statistic: 115.692 on 3 and 2222 DF, p-value: < 2.22e-16
>

What is going on? Any advice is appreciated.
Thanks,
-stephen
==========================================
Stephen J. Barr
University of Washington
WEB: www.econsteve.com
==========================================

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: panel question (plm)

Achim Zeileis
On Tue, 19 May 2009, Stephen J. Barr wrote:

> Hello,

> I am working on a data set (already as a plm.data object) located
> here: http://econsteve.com/arch/plmWithDensity.Robj
>
> With the following R session:
> > library(plm)
> ...
> >load("plmWithDensity.Robj")
> >model <- plm(RATE ~ density08, data=plmWithDensity)
> Error: subscript out of bounds
>
> I am not understanding the "subscript out of bounds" error, as this is

I agree that the error is not very meaningful but the problem is due to
your data: density08 does not vary within your id variable (COURT), hence
the default within model cannot be estimated. And it is also the reason
why density08 gets no coefficient in a larger model.

Also note that your RATE variable is a factor...I'm pretty certain you
want a numeric variable here!

Yves & Giovanni: What happens in the code is that the model.matrix()
method silently omits the column from the regressor matrix. Hence, this
goes unnoticed in the larger model and results in a regressor matrix
without any columns in the case above. Thus, the subscript error.

hth,
Z

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: panel question (plm)

Stephen J. Barr-2
Ah, thank you for the help, and for the explanation of what is going
on. I suppose I will have to reload my data with plm.data set such
that RATE is not a factor. For my time index, will
2000,2000.25,2000.5, etc. work? Meaning 2000 quarter 1, 2000 quarter
2, etc? Or is there some special way that I need to format the time?

Thanks,
-stephen
==========================================
Stephen J. Barr
University of Washington
WEB: www.econsteve.com
==========================================



On Tue, May 19, 2009 at 4:39 PM, Achim Zeileis
<[hidden email]> wrote:

> On Tue, 19 May 2009, Stephen J. Barr wrote:
>
>> Hello,
>
>> I am working on a data set (already as a plm.data object) located
>> here: http://econsteve.com/arch/plmWithDensity.Robj
>>
>> With the following R session:
>> > library(plm)
>> ...
>> >load("plmWithDensity.Robj")
>> >model <- plm(RATE ~ density08, data=plmWithDensity)
>> Error: subscript out of bounds
>>
>> I am not understanding the "subscript out of bounds" error, as this is
>
> I agree that the error is not very meaningful but the problem is due to your
> data: density08 does not vary within your id variable (COURT), hence the
> default within model cannot be estimated. And it is also the reason why
> density08 gets no coefficient in a larger model.
>
> Also note that your RATE variable is a factor...I'm pretty certain you want
> a numeric variable here!
>
> Yves & Giovanni: What happens in the code is that the model.matrix() method
> silently omits the column from the regressor matrix. Hence, this goes
> unnoticed in the larger model and results in a regressor matrix without any
> columns in the case above. Thus, the subscript error.
>
> hth,
> Z
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: panel question (plm)

Achim Zeileis
On Tue, 19 May 2009, Stephen J. Barr wrote:

> Ah, thank you for the help, and for the explanation of what is going
> on. I suppose I will have to reload my data with plm.data set such
> that RATE is not a factor.

plmWithDensity$RATE <- as.numeric(as.character(plmWithDensity$RATE))

should suffice.

> For my time index, will
> 2000,2000.25,2000.5, etc. work? Meaning 2000 quarter 1, 2000 quarter
> 2, etc? Or is there some special way that I need to format the time?

That's ok. Internally, plm.data always stores it as a factor anyway.

Best,
Z

> Thanks,
> -stephen
> ==========================================
> Stephen J. Barr
> University of Washington
> WEB: www.econsteve.com
> ==========================================
>
>
>
> On Tue, May 19, 2009 at 4:39 PM, Achim Zeileis
> <[hidden email]> wrote:
>> On Tue, 19 May 2009, Stephen J. Barr wrote:
>>
>>> Hello,
>>
>>> I am working on a data set (already as a plm.data object) located
>>> here: http://econsteve.com/arch/plmWithDensity.Robj
>>>
>>> With the following R session:
>>>> library(plm)
>>> ...
>>>> load("plmWithDensity.Robj")
>>>> model <- plm(RATE ~ density08, data=plmWithDensity)
>>> Error: subscript out of bounds
>>>
>>> I am not understanding the "subscript out of bounds" error, as this is
>>
>> I agree that the error is not very meaningful but the problem is due to your
>> data: density08 does not vary within your id variable (COURT), hence the
>> default within model cannot be estimated. And it is also the reason why
>> density08 gets no coefficient in a larger model.
>>
>> Also note that your RATE variable is a factor...I'm pretty certain you want
>> a numeric variable here!
>>
>> Yves & Giovanni: What happens in the code is that the model.matrix() method
>> silently omits the column from the regressor matrix. Hence, this goes
>> unnoticed in the larger model and results in a regressor matrix without any
>> columns in the case above. Thus, the subscript error.
>>
>> hth,
>> Z
>>
>>
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: panel question (plm)

Stephen J. Barr-2
Thank you for the advice. For the density08 variable, that is
population density in year 2008. I also have population densities for
year 2000, so I could put them both in, and interpolate between them
for the times that are covered by the panel (2000-2008), and then just
have a "density" column that will vary both over time and across
various courts. I would assume that this would fix the problem of
density not showing up in my coefficients list, although I think it is
more of an econometrics issue :)

Thanks again,
-stephen

On Tue, May 19, 2009 at 3:35 PM, Achim Zeileis
<[hidden email]> wrote:

> On Tue, 19 May 2009, Stephen J. Barr wrote:
>
>> Ah, thank you for the help, and for the explanation of what is going
>> on. I suppose I will have to reload my data with plm.data set such
>> that RATE is not a factor.
>
> plmWithDensity$RATE <- as.numeric(as.character(plmWithDensity$RATE))
>
> should suffice.
>
>> For my time index, will
>> 2000,2000.25,2000.5, etc. work? Meaning 2000 quarter 1, 2000 quarter
>> 2, etc? Or is there some special way that I need to format the time?
>
> That's ok. Internally, plm.data always stores it as a factor anyway.
>
> Best,
> Z
>
>> Thanks,
>> -stephen
>> ==========================================
>> Stephen J. Barr
>> University of Washington
>> WEB: www.econsteve.com
>> ==========================================
>>
>>
>>
>> On Tue, May 19, 2009 at 4:39 PM, Achim Zeileis
>> <[hidden email]> wrote:
>>>
>>> On Tue, 19 May 2009, Stephen J. Barr wrote:
>>>
>>>> Hello,
>>>
>>>> I am working on a data set (already as a plm.data object) located
>>>> here: http://econsteve.com/arch/plmWithDensity.Robj
>>>>
>>>> With the following R session:
>>>>>
>>>>> library(plm)
>>>>
>>>> ...
>>>>>
>>>>> load("plmWithDensity.Robj")
>>>>> model <- plm(RATE ~ density08, data=plmWithDensity)
>>>>
>>>> Error: subscript out of bounds
>>>>
>>>> I am not understanding the "subscript out of bounds" error, as this is
>>>
>>> I agree that the error is not very meaningful but the problem is due to
>>> your
>>> data: density08 does not vary within your id variable (COURT), hence the
>>> default within model cannot be estimated. And it is also the reason why
>>> density08 gets no coefficient in a larger model.
>>>
>>> Also note that your RATE variable is a factor...I'm pretty certain you
>>> want
>>> a numeric variable here!
>>>
>>> Yves & Giovanni: What happens in the code is that the model.matrix()
>>> method
>>> silently omits the column from the regressor matrix. Hence, this goes
>>> unnoticed in the larger model and results in a regressor matrix without
>>> any
>>> columns in the case above. Thus, the subscript error.
>>>
>>> hth,
>>> Z
>>>
>>>
>>
>>
>

______________________________________________
[hidden email] 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.