Re: [R] plm issues: error for within or random, but not for pooling

2010-02-24 Thread Liviu Andronic
Dear Giovanni
Thank you for the quick reply and sorry  for not being able to respond
in kind: since our last e-mail we decided to change the way we measure
the variables, and this took some time. I managed to track down the
original issue, I think, to an improperly specified subset vector to
the data=df[ , ] argument. I guess this would count as a user error.

Working with plm I encountered some other potential issues:
- [, var] subsetting: on my data the following works fine
 summary(ibes.kld.df.p[ , ]$ibes1.delta1y.diff)
total sum of squares : 2472.4
  id time
0.289638 0.032026

but the below takes 100% CPU for about a minute, and then fails.
 summary(ibes.kld.df.p[ , ibes1.delta1y.diff])
Error in substring(blanks, 1, pad) : invalid substring argument(s)

I am not sure what characteristics of my data causes this (perhaps
many NAs?), but I cannot reproduce a dummy example based on EmplUK:
 data(EmplUK, package = plm)
 E - pdata.frame(EmplUK, index = c(firm, year), drop.index = 
 TRUE,row.names = TRUE)
 summary(E$emp)
total sum of squares : 261540
   id  time
0.9807654 0.0091085
 summary(E[, emp])  ##in the dummy, both ways of subsetting work fine
total sum of squares : 261540
   id  time
0.9807654 0.0091085


- p.value of coef t test == p.value of regression F test (for pooling
and within, but not for random):
 x.pool - try(plm(get(x.ibes.diff1) ~ get(x.kld.diff1), ibes.kld.df.p, 
 model=pooling))
 summary(x.pool); x.ibes.diff1; x.kld.diff1
Oneway (individual) effect Pooling Model

Call:
plm(formula = get(x.ibes.diff1) ~ get(x.kld.diff1), data = ibes.kld.df.p,
model = pooling)

Unbalanced Panel: n=2336, T=1-15, N=9330

Residuals :
   Min. 1st Qu.  Median 3rd Qu.Max.
-5.4500 -0.1500  0.0799  0.2100  4.0500

Coefficients :
 Estimate Std. Error t-value Pr(|t|)
(Intercept)   -0.1199 0.0056   -21.4   2e-16 ***
get(x.kld.diff1)   0.0297 0.0165 1.80.071 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:2720
Residual Sum of Squares: 2720
F-statistic: 3.25802 on 1 and 9328 DF, p-value: 0.0711
[1] ibes2.delta12y.diff
[1] kld.delta1y_prod.diff
 x.fe - try(plm(get(x.ibes.diff1) ~ get(x.kld.diff1), ibes.kld.df.p, 
 model=within))
 summary(x.fe); x.ibes.diff1; x.kld.diff1
Oneway (individual) effect Within Model

Call:
plm(formula = get(x.ibes.diff1) ~ get(x.kld.diff1), data = ibes.kld.df.p,
model = within)

Unbalanced Panel: n=2336, T=1-15, N=9330

Residuals :
   Min. 1st Qu.  Median 3rd Qu.Max.
-4.1000 -0.1200  0.0121  0.1600  4.1300

Coefficients :
 Estimate Std. Error t-value Pr(|t|)
get(x.kld.diff1)   0.0324 0.01661.950.051 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:1790
Residual Sum of Squares: 1780
F-statistic: 3.80843 on 1 and 6993 DF, p-value: 0.051
[1] ibes2.delta12y.diff
[1] kld.delta1y_prod.diff


I suppose that this is OK, since for the pooling case I can confirm it
with the simple lm(), but I am not sure that I understand why this
happens?
 x.simp - try(lm(get(x.ibes.diff1) ~ get(x.kld.diff1), ibes.kld.df.p))
 summary(x.simp); x.ibes.diff1; x.kld.diff1

Call:
lm(formula = get(x.ibes.diff1) ~ get(x.kld.diff1), data = ibes.kld.df.p)

Residuals:
Min  1Q  Median  3Q Max
-5.4501 -0.1501  0.0799  0.2099  4.0499

Coefficients:
 Estimate Std. Error t value Pr(|t|)
(Intercept)   -0.1199 0.0056   -21.4   2e-16 ***
get(x.kld.diff1)   0.0297 0.0165 1.80.071 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.54 on 9328 degrees of freedom
  (3966 observations deleted due to missingness)
Multiple R-squared: 0.000349,   Adjusted R-squared: 0.000242
F-statistic: 3.26 on 1 and 9328 DF,  p-value: 0.0711

[1] ibes2.delta12y.diff
[1] kld.delta1y_prod.diff


For random, the two are different:
 x.re - try(plm(get(x.ibes.diff1) ~ get(x.kld.diff1), ibes.kld.df.p, 
 model=random))
 summary(x.re); x.ibes.diff1; x.kld.diff1
Oneway (individual) effect Random Effect Model
   (Swamy-Arora's transformation)

Call:
plm(formula = get(x.ibes.diff1) ~ get(x.kld.diff1), data = ibes.kld.df.p,
model = random)

Unbalanced Panel: n=2336, T=1-15, N=9330

Effects:
var std.dev share
idiosyncratic 0.255   0.505  0.88
individual0.036   0.190  0.12
theta  :
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
 0.0639  0.1620  0.2340  0.2640  0.4060  0.4340

Residuals :
Min.  1st Qu.   Median Mean  3rd Qu. Max.
-5.24000 -0.14300  0.06630 -0.00171  0.19700  3.79000

Coefficients :
 Estimate Std. Error t-value Pr(|t|)
(Intercept)  -0.115100.00708  -16.26   2e-16 ***
get(x.kld.diff1)  0.029350.015921.840.065 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:2420
Residual Sum of Squares: 2420
F-statistic: -0.417224 on 1 and 9328 DF, p-value: 1
[1] 

[R] plm issues: error for within or random, but not for pooling

2010-02-04 Thread Liviu Andronic
Dear all
I am working on unbalanced panel data and I can readily fit a
pooling model using plm(), but not a within or random model.
Reproducing the examples in vignette(plm) and in the AER package I
encountered no such issues.

##unfortunately I cannot disclose the data, and it is too big anyway
 dim(ibes.kld.exp.p[x.subs , ])
[1] 1318934
 summary(ibes.kld.exp.p[x.subs , ]$ibes1y.meanest)
total sum of squares : 28058
  id time
0.752284 0.018656
 summary(ibes.kld.exp.p[x.subs , ]$employee_kld)
total sum of squares : 9146.5
  id time
0.637098 0.073421

##fitting a pooling model works OK
 x - plm(ibes1y.meanest ~ employee_kld, ibes.kld.exp.p[x.subs , ], 
 model=pooling)
 summary(x)
Oneway (individual) effect Pooling Model

Call:
plm(formula = ibes1y.meanest ~ employee_kld, data = ibes.kld.exp.p[x.subs,
], model = pooling)

Unbalanced Panel: n=3041, T=1-16, N=13189

Residuals :
   Min. 1st Qu.  Median 3rd Qu.Max.
 -6.530  -0.871  -0.189   0.629  13.200

Coefficients :
 Estimate Std. Error t-value Pr(|t|)
(Intercept)1.5607 0.0127  122.73   2e-16 ***
employee_kld   0.1118 0.01527.35  2.2e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:28100
Residual Sum of Squares: 27900
F-statistic: 53.954 on 1 and 13187 DF, p-value: 2.17e-13
 plmtest(x, individual)

Lagrange Multiplier Test - (Honda)

data:  ibes1y.meanest ~ employee_kld
normal = 1675.7, p-value  2.2e-16
alternative hypothesis: significant effects


##fitting a within or random model fails
 x - plm(ibes1y.meanest ~ employee_kld, ibes.kld.exp.p[x.subs , ], 
 model=within)
Error in Tapply.matrix(x, effect, mean, ...) : subscript out of bounds
 x - plm(ibes1y.meanest ~ employee_kld, ibes.kld.exp.p[x.subs , ], 
 model=random)
Error in Tapply.matrix(x, effect, mean, ...) : subscript out of bounds


Would this be an issue with my data (which is a bit specific, since
employee_kld is categorical)? Or perhaps there is an issue in plm()
for unbalanced data?

Please let me know your opinion
Liviu


 sessionInfo()
R version 2.10.1 (2009-12-14)
x86_64-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
 [1] tcltk grid  splines   stats graphics  grDevices utils
 [8] datasets  methods   base

other attached packages:
 [1] RcmdrPlugin.sos_0.2-0tcltk2_1.1-1 RcmdrPlugin.Export_0.3-0
 [4] Hmisc_3.7-0  xtable_1.5-6 Rcmdr_1.5-5
 [7] car_1.2-16   ggplot2_0.8.5digest_0.4.2
[10] reshape_0.8.3plyr_0.1.9   proto_0.3-8
[13] plm_1.2-3sandwich_2.2-5   zoo_1.6-2
[16] MASS_7.3-5   Formula_0.2-0kinship_1.1.0-23
[19] lattice_0.18-3   nlme_3.1-96  survival_2.35-8
[22] fortunes_1.3-7   sos_1.2-4brew_1.0-3
[25] hints_1.0.1-1

loaded via a namespace (and not attached):
[1] cluster_1.12.1 tools_2.10.1



-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

__
R-help@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.


[R] R: plm issues: error for within or random, but not for pooling

2010-02-04 Thread Millo Giovanni
Dear Liviu,

it's difficult to tell without seeing the data. I might guess that you have 
some completely empty groups about which Tapply complains when doing the 
time-demeaning, but it would be just a guess.

I realize you can't share the data in the present form, but may I suggest you 
try and subset your data in some random way, find a problematic subset (one 
which gives the error) then change labels and everything so that the data 
become unrecognizable, and send us that example? You can also randomly 
transform them, as this is likely to be a missing values issue.

Giovanni

-Messaggio originale-
Da: Liviu Andronic [mailto:landronim...@gmail.com] 
Inviato: giovedì 4 febbraio 2010 12:32
A: r-help@r-project.org Help
Cc: yves.croiss...@let.ish-lyon.cnrs.fr; Millo Giovanni
Oggetto: plm issues: error for within or random, but not for pooling

Dear all
I am working on unbalanced panel data and I can readily fit a pooling model 
using plm(), but not a within or random model.
Reproducing the examples in vignette(plm) and in the AER package I 
encountered no such issues.

##unfortunately I cannot disclose the data, and it is too big anyway
 dim(ibes.kld.exp.p[x.subs , ])
[1] 1318934
 summary(ibes.kld.exp.p[x.subs , ]$ibes1y.meanest)
total sum of squares : 28058
  id time
0.752284 0.018656
 summary(ibes.kld.exp.p[x.subs , ]$employee_kld)
total sum of squares : 9146.5
  id time
0.637098 0.073421

##fitting a pooling model works OK
 x - plm(ibes1y.meanest ~ employee_kld, ibes.kld.exp.p[x.subs , ], 
 model=pooling)
 summary(x)
Oneway (individual) effect Pooling Model

Call:
plm(formula = ibes1y.meanest ~ employee_kld, data = ibes.kld.exp.p[x.subs,
], model = pooling)

Unbalanced Panel: n=3041, T=1-16, N=13189

Residuals :
   Min. 1st Qu.  Median 3rd Qu.Max.
 -6.530  -0.871  -0.189   0.629  13.200

Coefficients :
 Estimate Std. Error t-value Pr(|t|)
(Intercept)1.5607 0.0127  122.73   2e-16 ***
employee_kld   0.1118 0.01527.35  2.2e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:28100
Residual Sum of Squares: 27900
F-statistic: 53.954 on 1 and 13187 DF, p-value: 2.17e-13
 plmtest(x, individual)

Lagrange Multiplier Test - (Honda)

data:  ibes1y.meanest ~ employee_kld
normal = 1675.7, p-value  2.2e-16
alternative hypothesis: significant effects


##fitting a within or random model fails
 x - plm(ibes1y.meanest ~ employee_kld, ibes.kld.exp.p[x.subs , ], 
 model=within)
Error in Tapply.matrix(x, effect, mean, ...) : subscript out of bounds
 x - plm(ibes1y.meanest ~ employee_kld, ibes.kld.exp.p[x.subs , ], 
 model=random)
Error in Tapply.matrix(x, effect, mean, ...) : subscript out of bounds


Would this be an issue with my data (which is a bit specific, since 
employee_kld is categorical)? Or perhaps there is an issue in plm() for 
unbalanced data?

Please let me know your opinion
Liviu


 sessionInfo()
R version 2.10.1 (2009-12-14)
x86_64-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
 [1] tcltk grid  splines   stats graphics  grDevices utils
 [8] datasets  methods   base

other attached packages:
 [1] RcmdrPlugin.sos_0.2-0tcltk2_1.1-1 RcmdrPlugin.Export_0.3-0
 [4] Hmisc_3.7-0  xtable_1.5-6 Rcmdr_1.5-5
 [7] car_1.2-16   ggplot2_0.8.5digest_0.4.2
[10] reshape_0.8.3plyr_0.1.9   proto_0.3-8
[13] plm_1.2-3sandwich_2.2-5   zoo_1.6-2
[16] MASS_7.3-5   Formula_0.2-0kinship_1.1.0-23
[19] lattice_0.18-3   nlme_3.1-96  survival_2.35-8
[22] fortunes_1.3-7   sos_1.2-4brew_1.0-3
[25] hints_1.0.1-1

loaded via a namespace (and not attached):
[1] cluster_1.12.1 tools_2.10.1



--
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

Giovanni Millo
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4, 
34132 Trieste (Italy)
tel. +39 040 671184 
fax  +39 040 671160 

__
R-help@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.


Re: [R] plm Issues

2009-07-13 Thread Damien Moore
Duh! Thanks and good advice. I was using 2.7.2 because it was, until
recently, the latest version working with RPy (http://rpy.sourceforge.net/).
Also didn't realize plm was still actively developed.

Interesting that since plm now correctly handles diff and lag operations, it
actually breaks with the behavior of lm:

 a=ts(c(1,2,4))
 lm(a~diff(a))
Error in model.frame.default(formula = a ~ diff(a), drop.unused.levels =
TRUE) :
  variable lengths differ (found for 'diff(a)')

To regress a on its difference, one needs the more laborious:
 a=ts(c(1,2,4))
 adata=as.data.frame(cbind(a,diff(a)))
 colnames(adata)=c(a,diffa)
 lm(a~diffa,data=adata)

Call:
lm(formula = a ~ diffa, data = adata)

Coefficients:
(Intercept)diffa
  02

From the R help
Fitting Linear ModelsUsing time series

Considerable care is needed when using lm with time series.

Unless na.action = NULL, the time series attributes are stripped from the
variables before the regression is done. (This is necessary as omitting NAs
would invalidate the time series attributes, and if NAs are omitted in the
middle of the series the result would no longer be a regular time series.)

Even if the time series attributes are retained, they are not used to line
up series, so that the time shift of a lagged or differenced regressor would
be ignored. It is good practice to prepare a data argument by
ts.intersectts.union.html(...,
dframe = TRUE), then apply a suitable na.action to that data frame and call
lm with na.action = NULL so that residuals and fitted values are time
series.


On Sat, Jul 11, 2009 at 10:53 PM, milton ruser milton.ru...@gmail.comwrote:

 The first think one need to do when has a so old version, is update it :-)
 After, if the problem remain, try get help with the colleagues.

 best

 milton

 On Thu, Jul 9, 2009 at 10:58 AM, Damien Moore damienlmo...@gmail.comwrote:

 Hi List

 I'm having difficulty understanding how plm should work with dynamic
 formulas. See the commands and output below on a standard data set. Notice
 that the first summary(plm(...)) call returns the same result as the
 second
 (it shouldn't if it actually uses the lagged variable requested). The
 third
 call results in error (trying to use diff'ed variable in regression)

 Other info: I'm running R 2.7.2 on WinXP

 cheers



 *data(Gasoline,package=Ecdat)
 Gasoline_plm-plm.data(Gasoline,c(country,year))
 pdim(Gasoline_plm)
 **Balanced Panel: n=18, T=19, N=342
 *
 *summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
 **Oneway (individual) effect Within Model

 Call:
 plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)

 Balanced Panel: n=18, T=19, N=342

 Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
 -0.40100 -0.08410 -0.00858  0.08770  0.73400

 Coefficients :
 Estimate Std. Error t-value  Pr(|t|)
 lincomep -0.761830.03535 -21.551  2.2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Total Sum of Squares: 17.061
 Residual Sum of Squares: 6.9981
 Multiple R-Squared: 0.58981
 F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

 ** summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
 **Oneway (individual) effect Within Model

 Call:
 plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)

 Balanced Panel: n=18, T=19, N=342

 Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
 -0.40100 -0.08410 -0.00858  0.08770  0.73400

 Coefficients :
  Estimate Std. Error t-value  Pr(|t|)
 lag(lincomep) -0.761830.03535 -21.551  2.2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Total Sum of Squares: 17.061
 Residual Sum of Squares: 6.9981
 Multiple R-Squared: 0.58981
 F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

 *
 *summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
 *Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data =
 mydata,  :
  variable lengths differ (found for 'diff(lincomep)')
 *

[[alternative HTML version deleted]]


 __
 R-help@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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] plm Issues

2009-07-13 Thread Gabor Grothendieck
The dyn and dynlm packages can handle time series in lm and glm.
(dyn can also handle many additional regression functions as well)
In the case of dyn just write dyn$lm instead of lm like this:

 library(dyn)
 a - ts(c(1, 2, 4))
 dyn$lm(a ~ diff(a))

Call:
lm(formula = dyn(a ~ diff(a)))

Coefficients:
(Intercept)  diff(a)
  02


On Mon, Jul 13, 2009 at 10:17 AM, Damien Mooredamienlmo...@gmail.com wrote:
 Duh! Thanks and good advice. I was using 2.7.2 because it was, until
 recently, the latest version working with RPy (http://rpy.sourceforge.net/).
 Also didn't realize plm was still actively developed.

 Interesting that since plm now correctly handles diff and lag operations, it
 actually breaks with the behavior of lm:

 a=ts(c(1,2,4))
 lm(a~diff(a))
 Error in model.frame.default(formula = a ~ diff(a), drop.unused.levels =
 TRUE) :
  variable lengths differ (found for 'diff(a)')

 To regress a on its difference, one needs the more laborious:
 a=ts(c(1,2,4))
 adata=as.data.frame(cbind(a,diff(a)))
 colnames(adata)=c(a,diffa)
 lm(a~diffa,data=adata)

 Call:
 lm(formula = a ~ diffa, data = adata)

 Coefficients:
 (Intercept)        diffa
          0            2

 From the R help
 Fitting Linear ModelsUsing time series

 Considerable care is needed when using lm with time series.

 Unless na.action = NULL, the time series attributes are stripped from the
 variables before the regression is done. (This is necessary as omitting NAs
 would invalidate the time series attributes, and if NAs are omitted in the
 middle of the series the result would no longer be a regular time series.)

 Even if the time series attributes are retained, they are not used to line
 up series, so that the time shift of a lagged or differenced regressor would
 be ignored. It is good practice to prepare a data argument by
 ts.intersectts.union.html(...,
 dframe = TRUE), then apply a suitable na.action to that data frame and call
 lm with na.action = NULL so that residuals and fitted values are time
 series.


 On Sat, Jul 11, 2009 at 10:53 PM, milton ruser milton.ru...@gmail.comwrote:

 The first think one need to do when has a so old version, is update it :-)
 After, if the problem remain, try get help with the colleagues.

 best

 milton

 On Thu, Jul 9, 2009 at 10:58 AM, Damien Moore damienlmo...@gmail.comwrote:

 Hi List

 I'm having difficulty understanding how plm should work with dynamic
 formulas. See the commands and output below on a standard data set. Notice
 that the first summary(plm(...)) call returns the same result as the
 second
 (it shouldn't if it actually uses the lagged variable requested). The
 third
 call results in error (trying to use diff'ed variable in regression)

 Other info: I'm running R 2.7.2 on WinXP

 cheers



 *data(Gasoline,package=Ecdat)
 Gasoline_plm-plm.data(Gasoline,c(country,year))
 pdim(Gasoline_plm)
 **Balanced Panel: n=18, T=19, N=342
 *
 *summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
 **Oneway (individual) effect Within Model

 Call:
 plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)

 Balanced Panel: n=18, T=19, N=342

 Residuals :
    Min.  1st Qu.   Median  3rd Qu.     Max.
 -0.40100 -0.08410 -0.00858  0.08770  0.73400

 Coefficients :
         Estimate Std. Error t-value  Pr(|t|)
 lincomep -0.76183    0.03535 -21.551  2.2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Total Sum of Squares: 17.061
 Residual Sum of Squares: 6.9981
 Multiple R-Squared: 0.58981
 F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

 ** summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
 **Oneway (individual) effect Within Model

 Call:
 plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)

 Balanced Panel: n=18, T=19, N=342

 Residuals :
    Min.  1st Qu.   Median  3rd Qu.     Max.
 -0.40100 -0.08410 -0.00858  0.08770  0.73400

 Coefficients :
              Estimate Std. Error t-value  Pr(|t|)
 lag(lincomep) -0.76183    0.03535 -21.551  2.2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Total Sum of Squares: 17.061
 Residual Sum of Squares: 6.9981
 Multiple R-Squared: 0.58981
 F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

 *
 *summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
 *Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data =
 mydata,  :
  variable lengths differ (found for 'diff(lincomep)')
 *

        [[alternative HTML version deleted]]


 __
 R-help@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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




        [[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the 

Re: [R] plm Issues

2009-07-11 Thread spencerg

 Your script ran for me without error under the following configuration:

 sessionInfo()
R version 2.9.1 (2009-06-26)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] plm_1.1-4 sandwich_2.2-1 zoo_1.5-6 MASS_7.2-47
[5] Formula_0.1-3 kinship_1.1.0-22 lattice_0.17-25 nlme_3.1-92
[9] survival_2.35-4

loaded via a namespace (and not attached):
[1] grid_2.9.1 tools_2.9.1


I suggest you upgrade to R 2.9.1.


By the way, I did not know about plm. To find that function, I 
proceeded as follows:



library(RSiteSearch)
plm. - RSiteSearch.function('plm')
HTML(plm.)


This identified 82 different help pages in 11 different packages; 38 
matches were found in the plm package, which contained a function 
called plm. I assume this is the one you were using.



Hope this helps.
Spencer Graves


Damien Moore wrote:

Hi List

I'm having difficulty understanding how plm should work with dynamic
formulas. See the commands and output below on a standard data set. Notice
that the first summary(plm(...)) call returns the same result as the second
(it shouldn't if it actually uses the lagged variable requested). The third
call results in error (trying to use diff'ed variable in regression)

Other info: I'm running R 2.7.2 on WinXP

cheers



*data(Gasoline,package=Ecdat)
  

Gasoline_plm-plm.data(Gasoline,c(country,year))
pdim(Gasoline_plm)


**Balanced Panel: n=18, T=19, N=342
*
*summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
**Oneway (individual) effect Within Model

Call:
plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)

Balanced Panel: n=18, T=19, N=342

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-0.40100 -0.08410 -0.00858  0.08770  0.73400

Coefficients :
 Estimate Std. Error t-value  Pr(|t|)
lincomep -0.761830.03535 -21.551  2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares: 17.061
Residual Sum of Squares: 6.9981
Multiple R-Squared: 0.58981
F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

** summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
**Oneway (individual) effect Within Model

Call:
plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)

Balanced Panel: n=18, T=19, N=342

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-0.40100 -0.08410 -0.00858  0.08770  0.73400

Coefficients :
  Estimate Std. Error t-value  Pr(|t|)
lag(lincomep) -0.761830.03535 -21.551  2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares: 17.061
Residual Sum of Squares: 6.9981
Multiple R-Squared: 0.58981
F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

*
*summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
*Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data =
mydata,  :
  variable lengths differ (found for 'diff(lincomep)')
*

[[alternative HTML version deleted]]

  



__
R-help@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.



__
R-help@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.


Re: [R] plm Issues

2009-07-11 Thread milton ruser
The first think one need to do when has a so old version, is update it :-)
After, if the problem remain, try get help with the colleagues.

best

milton

On Thu, Jul 9, 2009 at 10:58 AM, Damien Moore damienlmo...@gmail.comwrote:

 Hi List

 I'm having difficulty understanding how plm should work with dynamic
 formulas. See the commands and output below on a standard data set. Notice
 that the first summary(plm(...)) call returns the same result as the second
 (it shouldn't if it actually uses the lagged variable requested). The third
 call results in error (trying to use diff'ed variable in regression)

 Other info: I'm running R 2.7.2 on WinXP

 cheers



 *data(Gasoline,package=Ecdat)
 Gasoline_plm-plm.data(Gasoline,c(country,year))
 pdim(Gasoline_plm)
 **Balanced Panel: n=18, T=19, N=342
 *
 *summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
 **Oneway (individual) effect Within Model

 Call:
 plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)

 Balanced Panel: n=18, T=19, N=342

 Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
 -0.40100 -0.08410 -0.00858  0.08770  0.73400

 Coefficients :
 Estimate Std. Error t-value  Pr(|t|)
 lincomep -0.761830.03535 -21.551  2.2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Total Sum of Squares: 17.061
 Residual Sum of Squares: 6.9981
 Multiple R-Squared: 0.58981
 F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

 ** summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
 **Oneway (individual) effect Within Model

 Call:
 plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)

 Balanced Panel: n=18, T=19, N=342

 Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
 -0.40100 -0.08410 -0.00858  0.08770  0.73400

 Coefficients :
  Estimate Std. Error t-value  Pr(|t|)
 lag(lincomep) -0.761830.03535 -21.551  2.2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Total Sum of Squares: 17.061
 Residual Sum of Squares: 6.9981
 Multiple R-Squared: 0.58981
 F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

 *
 *summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
 *Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data =
 mydata,  :
  variable lengths differ (found for 'diff(lincomep)')
 *

[[alternative HTML version deleted]]


 __
 R-help@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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@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.


[R] plm Issues

2009-07-09 Thread Damien Moore
Hi List

I'm having difficulty understanding how plm should work with dynamic
formulas. See the commands and output below on a standard data set. Notice
that the first summary(plm(...)) call returns the same result as the second
(it shouldn't if it actually uses the lagged variable requested). The third
call results in error (trying to use diff'ed variable in regression)

Other info: I'm running R 2.7.2 on WinXP

cheers



*data(Gasoline,package=Ecdat)
Gasoline_plm-plm.data(Gasoline,c(country,year))
pdim(Gasoline_plm)
**Balanced Panel: n=18, T=19, N=342
*
*summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
**Oneway (individual) effect Within Model

Call:
plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)

Balanced Panel: n=18, T=19, N=342

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-0.40100 -0.08410 -0.00858  0.08770  0.73400

Coefficients :
 Estimate Std. Error t-value  Pr(|t|)
lincomep -0.761830.03535 -21.551  2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares: 17.061
Residual Sum of Squares: 6.9981
Multiple R-Squared: 0.58981
F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

** summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
**Oneway (individual) effect Within Model

Call:
plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)

Balanced Panel: n=18, T=19, N=342

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-0.40100 -0.08410 -0.00858  0.08770  0.73400

Coefficients :
  Estimate Std. Error t-value  Pr(|t|)
lag(lincomep) -0.761830.03535 -21.551  2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares: 17.061
Residual Sum of Squares: 6.9981
Multiple R-Squared: 0.58981
F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

*
*summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
*Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data =
mydata,  :
  variable lengths differ (found for 'diff(lincomep)')
*

[[alternative HTML version deleted]]

__
R-help@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.