Re: [R] Unable to Understand Results of pglm function

2019-04-23 Thread Paul Bernal
Hi Dr. Mackay,

Thank you so much for your valuable feedback.

I wonder why, when  applying the summary function over the pglm model, it
shows infinite as value for the standard errors.

Is this something we should expect? Or is there something else that needs
to be adjusted, either in the dataset(in the dataset's structure) or in the
pglm parameters.

Best regards,

Paul

El mar., 23 de abril de 2019 9:55 p. m., Duncan Mackay 
escribió:

> Hi Paul
>
> I think you may have too many IDs DATE for your model as you posted
>
> I converted your DATE into date format and named it df3
> str(df3)
> 'data.frame':   527 obs. of  11 variables:
>  $ TRANSIT : int  1 1 1 0 1 1 1 1 1 1 ...
>  $ ID  : int  1 1 2 2 3 4 5 5 6 7 ...
>  $ DATE: Factor w/ 377 levels "1-Aug-17","1-Aug-18",..: 47 75 89
> 252 3 221 62 99 224 114 ...
>  $ SHIPNAME: Factor w/ 482 levels "Aby Jeannette",..: 295 295 151 151
> 19 41 292 292 201 148 ...
>  $ Draft   : int  12 12 12 13 12 12 12 12 12 12 ...
>  $ TOTALCOST   : int  194364 219364 198260 237456 197159 198992 194337
> 219337 199198 196604 ...
>  $ BUNKER  : int  350 405 276 350 373 355 370 343 345 288 ...
>  $ CHARTERVALUE: int  14000 12825 10475 11850 13250 12100 11875 14500
> 12500 10500 ...
>  $ dt  : Date, format: "2018-03-15" "2018-08-19" "2017-07-20"
> "2017-12-19" ...
>  $ dtym: chr  "201803" "201808" "201707" "201712" ...
>  $ dty : chr  "2018" "2018" "2017" "2017" ...
>
> Here are 2 results
>
> > model1 = pglm(TRANSIT~ Draft+TOTALCOST+BUNKER+CHARTERVALUE + dty,
> +  effect=c("time"),
> +  model=c("pooling"),
> +  family=binomial('logit'),
> +  index=c("ID"),
> +  start = NULL, data=df3)
> >
> > summary(model1)
> 
> Maximum Likelihood estimation
> Newton-Raphson maximisation, 11 iterations
> Return code 2: successive function values within tolerance limit
> Log-Likelihood: -14.14988
> 6  free parameters
> Estimates:
>Estimate Std. error t value Pr(> t)
> (Intercept)   1.023e+02Inf   0   1
> Draft-5.088e+00Inf   0   1
> TOTALCOST-1.708e-04Inf   0   1
> BUNKER   -6.712e-03Inf   0   1
> CHARTERVALUE  2.524e-04Inf   0   1
> dty2018   2.215e+00Inf   0   1
> 
>
> > model1=pglm(TRANSIT~ Draft+TOTALCOST+BUNKER+CHARTERVALUE + dty,
> +  effect=c("time"),
> +  model=c("pooling"),
> +  family=binomial('logit'),
> +  index=c("ID","dty"),
> +  start = NULL, data=df3)
> Warning messages:
> 1: In pdata.frame(data, index) :
>   duplicate couples (id-time) in resulting pdata.frame
>  to find out which, use e.g. table(index(your_pdataframe), useNA = "ifany")
> 2: In is.pbalanced.default(index[[1]], index[[2]]) :
>   duplicate couples (id-time)
>
> >
> > summary(model1)
> 
> Maximum Likelihood estimation
> Newton-Raphson maximisation, 11 iterations
> Return code 2: successive function values within tolerance limit
> Log-Likelihood: -14.14988
> 6  free parameters
> Estimates:
>Estimate Std. error t value Pr(> t)
> (Intercept)   1.023e+02Inf   0   1
> Draft-5.088e+00Inf   0   1
> TOTALCOST-1.708e-04Inf   0   1
> BUNKER   -6.712e-03Inf   0   1
> CHARTERVALUE  2.524e-04Inf   0   1
> dty2018   2.215e+00Inf   0   1
> 
>
> I have no knowledge of the pglm package and was trying it out on your data
> without going through the help properly
> NBB your DATE column has several formats which do not help
>
> Regards
>
> Duncan
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2350
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul
> Bernal
> Sent: Wednesday, 24 April 2019 06:44
> To: yves.croiss...@univ-reunion.fr
> Cc: r-help@r-project.org
> Subject: [R] Unable to Understand Results of pglm function
>
> Dear Yves,
>
> Hope you are doing great. I have been testing the pglm function from the
> pglm package, in order to fit a logit regression to a panel dataset, and I
> do not understand the results and/or errors produced

Re: [R] Unable to Understand Results of pglm function

2019-04-23 Thread Duncan Mackay
Hi Paul

I think you may have too many IDs DATE for your model as you posted

I converted your DATE into date format and named it df3
str(df3)
'data.frame':   527 obs. of  11 variables:
 $ TRANSIT : int  1 1 1 0 1 1 1 1 1 1 ...
 $ ID  : int  1 1 2 2 3 4 5 5 6 7 ...
 $ DATE: Factor w/ 377 levels "1-Aug-17","1-Aug-18",..: 47 75 89 252 3 
221 62 99 224 114 ...
 $ SHIPNAME: Factor w/ 482 levels "Aby Jeannette",..: 295 295 151 151 19 41 
292 292 201 148 ...
 $ Draft   : int  12 12 12 13 12 12 12 12 12 12 ...
 $ TOTALCOST   : int  194364 219364 198260 237456 197159 198992 194337 219337 
199198 196604 ...
 $ BUNKER  : int  350 405 276 350 373 355 370 343 345 288 ...
 $ CHARTERVALUE: int  14000 12825 10475 11850 13250 12100 11875 14500 12500 
10500 ...
 $ dt  : Date, format: "2018-03-15" "2018-08-19" "2017-07-20" 
"2017-12-19" ...
 $ dtym: chr  "201803" "201808" "201707" "201712" ...
 $ dty : chr  "2018" "2018" "2017" "2017" ...

Here are 2 results 

> model1 = pglm(TRANSIT~ Draft+TOTALCOST+BUNKER+CHARTERVALUE + dty,
+  effect=c("time"), 
+  model=c("pooling"), 
+  family=binomial('logit'),
+  index=c("ID"), 
+  start = NULL, data=df3)
> 
> summary(model1)

Maximum Likelihood estimation
Newton-Raphson maximisation, 11 iterations
Return code 2: successive function values within tolerance limit
Log-Likelihood: -14.14988 
6  free parameters
Estimates:
   Estimate Std. error t value Pr(> t)
(Intercept)   1.023e+02Inf   0   1
Draft-5.088e+00Inf   0   1
TOTALCOST-1.708e-04Inf   0   1
BUNKER   -6.712e-03Inf   0   1
CHARTERVALUE  2.524e-04Inf   0   1
dty2018   2.215e+00Inf   0   1


> model1=pglm(TRANSIT~ Draft+TOTALCOST+BUNKER+CHARTERVALUE + dty,
+  effect=c("time"), 
+  model=c("pooling"), 
+  family=binomial('logit'),
+  index=c("ID","dty"), 
+  start = NULL, data=df3)
Warning messages:
1: In pdata.frame(data, index) :
  duplicate couples (id-time) in resulting pdata.frame
 to find out which, use e.g. table(index(your_pdataframe), useNA = "ifany")
2: In is.pbalanced.default(index[[1]], index[[2]]) :
  duplicate couples (id-time)

> 
> summary(model1)

Maximum Likelihood estimation
Newton-Raphson maximisation, 11 iterations
Return code 2: successive function values within tolerance limit
Log-Likelihood: -14.14988 
6  free parameters
Estimates:
   Estimate Std. error t value Pr(> t)
(Intercept)   1.023e+02Inf   0   1
Draft-5.088e+00Inf   0   1
TOTALCOST-1.708e-04Inf   0   1
BUNKER   -6.712e-03Inf   0   1
CHARTERVALUE  2.524e-04Inf   0   1
dty2018   2.215e+00Inf   0   1


I have no knowledge of the pglm package and was trying it out on your data 
without going through the help properly
NBB your DATE column has several formats which do not help

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2350

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul Bernal
Sent: Wednesday, 24 April 2019 06:44
To: yves.croiss...@univ-reunion.fr
Cc: r-help@r-project.org
Subject: [R] Unable to Understand Results of pglm function

Dear Yves,

Hope you are doing great. I have been testing the pglm function from the
pglm package, in order to fit a logit regression to a panel dataset, and I
do not understand the results and/or errors produced by the function, so I
want to be able to understand whether there is a problem with the structure
of my dataset, or I am not using the function properly or if there is
something else going on that I am ignoring. Also, I would like to know what
the start argument is for, or at least an example of how to use it, since I
don´t know how to properly apply it.

Here the details of what I am using and under what environment settings:
1-R version: 3.5.3
2-packages called: plm and pglm
3-Running on a 64-bit Operating System
4-Windows 8

Here is the code with the different things I have tried so far:
> PGLM_Model11 <-
pglm(dataframe3$TRANSIT~dataframe3$Draft+dataframe3$TOTALCOST+dataframe3$BUNKER+dataframe3$CHARTERVALUE,
effect=c("twoways"), model=c("random"), family=binomial('logit'),
index=c("ID","DATE"), start = NULL, data=dataframe3)
>
> summary(PGLM_Model11)

[R] Unable to Understand Results of pglm function

2019-04-23 Thread Paul Bernal
Dear Yves,

Hope you are doing great. I have been testing the pglm function from the
pglm package, in order to fit a logit regression to a panel dataset, and I
do not understand the results and/or errors produced by the function, so I
want to be able to understand whether there is a problem with the structure
of my dataset, or I am not using the function properly or if there is
something else going on that I am ignoring. Also, I would like to know what
the start argument is for, or at least an example of how to use it, since I
don´t know how to properly apply it.

Here the details of what I am using and under what environment settings:
1-R version: 3.5.3
2-packages called: plm and pglm
3-Running on a 64-bit Operating System
4-Windows 8

Here is the code with the different things I have tried so far:
> PGLM_Model11 <-
pglm(dataframe3$TRANSIT~dataframe3$Draft+dataframe3$TOTALCOST+dataframe3$BUNKER+dataframe3$CHARTERVALUE,
effect=c("twoways"), model=c("random"), family=binomial('logit'),
index=c("ID","DATE"), start = NULL, data=dataframe3)
>
> summary(PGLM_Model11)

Maximum Likelihood estimation
Newton-Raphson maximisation, 0 iterations
Return code 100: Initial value out of range.

>
> PGLM_Model12 <-
pglm(dataframe3$TRANSIT~dataframe3$Draft+dataframe3$TOTALCOST+dataframe3$BUNKER+dataframe3$CHARTERVALUE,
effect=c("twoways"), model=c("pooling"), family=binomial('logit'),
index=c("ID","DATE"), start = NULL, data=dataframe3)
>
> summary(PGLM_Model12)

Maximum Likelihood estimation
Newton-Raphson maximisation, 11 iterations
Return code 2: successive function values within tolerance limit
Log-Likelihood: -14.95426
5  free parameters
Estimates:
  Estimate Std. error t value Pr(> t)
(Intercept) 93.9680425Inf   0   1
dataframe3$Draft-5.3820652Inf   0   1
dataframe3$TOTALCOST-0.0001689Inf   0   1
dataframe3$BUNKER0.0072934Inf   0   1
dataframe3$CHARTERVALUE  0.0008862Inf   0   1

>
> PGLM_Model13 <-
pglm(dataframe3$TRANSIT~dataframe3$Draft+dataframe3$TOTALCOST+dataframe3$BUNKER+dataframe3$CHARTERVALUE,
effect=c("twoways"), model=c("within"), family=binomial('logit'),
index=c("ID","DATE"), start = NULL, data=dataframe3)
Error in maxRoutine(fn = logLik, grad = grad, hess = hess, start = start,
:
  argument "start" is missing, with no default
>
> PGLM_Model14 <-
pglm(dataframe3$TRANSIT~dataframe3$Draft+dataframe3$TOTALCOST+dataframe3$BUNKER+dataframe3$CHARTERVALUE,
effect=c("twoways"), model=c("between"), family=binomial('logit'),
index=c("ID","DATE"), start = NULL, data=dataframe3)
Error in maxRoutine(fn = logLik, grad = grad, hess = hess, start = start,
:
  argument "start" is missing, with no default

Below the dput of the dataset I am using for your reference:

> dput(dataframe3)
structure(list(TRANSIT = c(1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L,
1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L,
0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L,
1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L,
1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L,
0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L,
1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L,
0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L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