[R] GLM problems.

Daniel Jimenez jimenez.daniel77 at gmail.com
Thu Mar 1 18:44:42 CET 2007


Dear R users I'm new in R management and maybe It's a silly question. I'm
working with GLM to obtain predictive models. I have some problesm with the
prediction instruction:



> DatosTotal <- read.csv("Var_perdizcsv.csv", sep =";")
> edvariable <- edit(DatosTotal)
> pre <- predict(rlfinal, DatosTotal, type = 'probs')
Erro en match.arg(type) : 'arg' should be one of link, response, terms
>


I check the database and the name variables are the same... I do not know
what happen. Please help me.

I attach the complet proccess.

Thank you.

-- 
Daniel Jiménez García
------------ próxima parte ------------

R : Copyright 2006, The R Foundation for Statistical Computing
Version 2.3.1 (2006-06-01)
ISBN 3-900051-07-0

R es un software libre y viene sin GARANTIA ALGUNA.
Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.
Escriba 'contributors()' para obtener mas informacion y
'citation()' para saber como citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line de ayuda,
o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

[Previously saved workspace restored]

> Datos <- read.csv("variables_perdiz_01_03.csv", sep =";")
> attach(Datos)
> library(MASS)
> 
> rl0 <- glm(PRESAUS ~ 1, family = binomial)
> 
> rl1 <- stepAIC(rl0, direction = c("both"), scope = PRESAUS ~ 1 + elev + vias + orient + pend + 
+ freg + frsec + labsec + matarb + matcl + matden + ripar + visec + pinar + forest + matorrales + 
+ abandonos + ombro + termic, keep = extractAIC)
Start:  AIC= 99.04 
 PRESAUS ~ 1 

             Df Deviance     AIC
+ freg        1   91.415  95.415
+ matorrales  1   93.457  97.457
+ ripar       1   93.766  97.766
+ matarb      1   94.975  98.975
<none>            97.041  99.041
+ forest      1   95.043  99.043
+ abandonos   1   95.093  99.093
+ matden      1   95.133  99.133
+ ombro       1   95.655  99.655
+ pend        1   95.986  99.986
+ termic      1   96.156 100.156
+ vias        1   96.641 100.641
+ elev        1   96.680 100.680
+ pinar       1   96.710 100.710
+ orient      1   96.775 100.775
+ labsec      1   96.987 100.987
+ visec       1   97.028 101.028
+ matcl       1   97.040 101.040
+ frsec       1   97.041 101.041

Step:  AIC= 95.42 
 PRESAUS ~ freg 

             Df Deviance    AIC
+ termic      1   87.885 93.885
+ abandonos   1   88.134 94.134
+ forest      1   88.550 94.550
+ elev        1   88.668 94.668
+ ripar       1   88.802 94.802
<none>            91.415 95.415
+ matorrales  1   89.648 95.648
+ matarb      1   90.023 96.023
+ matden      1   90.443 96.443
+ pinar       1   90.796 96.796
+ vias        1   91.154 97.154
+ ombro       1   91.156 97.156
+ pend        1   91.233 97.233
+ frsec       1   91.340 97.340
+ matcl       1   91.345 97.345
+ visec       1   91.347 97.347
+ labsec      1   91.378 97.378
+ orient      1   91.410 97.410
- freg        1   97.041 99.041

Step:  AIC= 93.89 
 PRESAUS ~ freg + termic 

             Df Deviance     AIC
+ abandonos   1   83.370  91.370
+ matorrales  1   83.491  91.491
+ matden      1   83.771  91.771
<none>            87.885  93.885
+ ripar       1   86.312  94.312
+ elev        1   86.501  94.501
+ forest      1   86.719  94.719
+ pend        1   86.743  94.743
+ visec       1   87.118  95.118
+ matarb      1   87.242  95.242
- termic      1   91.415  95.415
+ orient      1   87.416  95.416
+ vias        1   87.498  95.498
+ labsec      1   87.544  95.544
+ ombro       1   87.718  95.718
+ pinar       1   87.720  95.720
+ frsec       1   87.856  95.856
+ matcl       1   87.878  95.878
- freg        1   96.156 100.156

Step:  AIC= 91.37 
 PRESAUS ~ freg + termic + abandonos 

             Df Deviance     AIC
+ matden      1   80.343  90.343
+ matorrales  1   80.823  90.823
<none>            83.370  91.370
+ visec       1   81.465  91.465
+ ripar       1   81.791  91.791
+ forest      1   82.089  92.089
+ labsec      1   82.335  92.335
+ pend        1   82.699  92.699
+ vias        1   83.057  93.057
+ elev        1   83.091  93.091
+ matarb      1   83.166  93.166
+ pinar       1   83.193  93.193
+ orient      1   83.242  93.242
+ ombro       1   83.282  93.282
+ matcl       1   83.357  93.357
+ frsec       1   83.369  93.369
- abandonos   1   87.885  93.885
- termic      1   88.134  94.134
- freg        1   94.026 100.026

Step:  AIC= 90.34 
 PRESAUS ~ freg + termic + abandonos + matden 

             Df Deviance    AIC
<none>            80.343 90.343
+ ripar       1   78.766 90.766
+ visec       1   78.862 90.862
- matden      1   83.370 91.370
- abandonos   1   83.771 91.771
+ pend        1   79.825 91.825
+ labsec      1   79.837 91.837
+ matorrales  1   79.861 91.861
+ forest      1   79.965 91.965
+ matarb      1   80.009 92.009
+ frsec       1   80.087 92.087
+ vias        1   80.171 92.171
+ matcl       1   80.217 92.217
+ elev        1   80.240 92.240
+ ombro       1   80.322 92.322
+ pinar       1   80.329 92.329
+ orient      1   80.342 92.342
- termic      1   87.726 95.726
- freg        1   90.534 98.534
> tabla <- data.frame(rl1$keep)
> tabla
       X1       X2       X3      X4       X5
1  1.0000  2.00000  3.00000  4.0000  5.00000
2 99.0406 95.41544 93.88513 91.3704 90.34343
> rlfinal <- glm(PRESAUS ~ freg + termic + abandonos + matden , family = binomial)
> summary (rlfinal)

Call:
glm(formula = PRESAUS ~ freg + termic + abandonos + matden, family = binomial)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-2.08022  -0.82070   0.04674   0.90439   1.95034  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)   
(Intercept) -5.888148   2.533235  -2.324  0.02011 * 
freg        -0.004076   0.001440  -2.830  0.00465 **
termic       0.017090   0.006828   2.503  0.01231 * 
abandonos   -0.002735   0.001556  -1.758  0.07871 . 
matden       0.002493   0.001534   1.625  0.10414   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 97.041  on 69  degrees of freedom
Residual deviance: 80.343  on 65  degrees of freedom
AIC: 90.343

Number of Fisher Scoring iterations: 4

> DatosTotal <- read.csv("Var_perdizcsv.csv", sep =";")
> edvariable <- edit(DatosTotal)
> pre <- predict(rlfinal, DatosTotal, type = 'probs')
Erro en match.arg(type) : 'arg' should be one of link, response, terms
> 


More information about the R-help mailing list