[R] Still problems with "step()" function
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Mar 24 01:27:45 CET 2006
It looks some your data has been wrapped around by the
email processing. Suggest that after reading it in you
issue the command:
dput(testData)
and put
testData <-
followed by the output from the dput into your email.
On 3/23/06, Kenneth Cabrera <krcabrer at epm.net.co> wrote:
> Hi R users:
>
> I don´t know if anybody have had the same problem with 'step()' funtion.
>
> If I type the commands
> -------------------------------------------------------------------------------
> testData<-read.table("testData.dat",header=T)
> model1J<-glm(MCHNV~offset(Offset1),data=testData,family="poisson")
> step(model1J,direction="forward",
> scope=(list(upper=~IA+IM+altura+Region+Region:IA+Region:IM+Region:altura+offset(Offset1),
> lower=~offset(Offset1))))
> -------------------------------------------------------------------------------
> I got the folowing error message:
>
> -------------------------------------------------------------------------------
> .
> .
> Df Deviance AIC
> + IA:Region 8 540.24 1377.73
> + IM 1 586.84 1410.32
> + altura:Region 8 574.21 1411.70
> <none> 600.74 1422.23
>
> Step: AIC= 1377.73
> MCHNV ~ Region + IA + altura + Region:IA + offset(Offset1)
>
> Error in factor.scope(ffac, list(add = fadd, drop = fdrop)) :
> upper scope does not include model
> -------------------------------------------------------------------------------
>
> What am I doing wrong?
>
> Thank you for your help.
>
> I put here the database I use, so you can replicate the problem.
> (I am using R221 on WinXP)
>
> -------------------------------------------------------------------------------
> testdata.dat
>
> "MCHNV" "IA" "IM" "altura" "Region" "Offset1"
> 215 26.9863956381346 1.07456622007468 2 "URABA" -0.185125484126689
> 325 21.443816698054 1.05477685097601 4 "URABA" 0.118671529717499
> 435 24.3172115328382 1.08970363580813 8 "URABA" 0.363948427905231
> 327 22.9861973271014 1.09309079792113 200 "URABA" 0.241376319575269
> 150 18.1768608561301 0.983952398124775 30 "BAJO CAUCA" -0.683196849706777
> 949 10.6563785744498 0.97821952889272 25 "URABA" 1.30128098679293
> 417 15.0910419778194 1.02464131763495 28 "URABA" 0.314810739840034
> 528 13.6340158642317 0.913249100021176 50 "BAJO CAUCA" 0.986562784859487
> 572 15.2055383362367 0.999321512574634 34 "URABA" 0.714908672341458
> 1255 16.9860295444068 1.00064160401003 2 "URABA" 1.54158724552593
> 517 17.9909267660402 1.00311566921978 50 "BAJO CAUCA" 0.67141268841394
> 221 26.714962883463 1.03642655495856 100 "BAJO CAUCA" -0.122167633974208
> 306 20.1507989217486 1.05350982751705 50 "BAJO CAUCA" 0.0411419433311752
> 274 27.4221304422647 1.03894736842105 125 "BAJO CAUCA" 0.0344014267173323
> 307 11.8064337044690 1.02694423605901 650 "NORDESTE" 0.242161557149972
> 203 25.7458563535912 1.02557953637090 75 "URABA" -0.608806032126194
> 258 27.2816742408892 1.08604552865165 1550 "NORTE" 0.340748793388473
> 126 26.0150722854506 0.9960092095165 1165 "NORTE" -0.551647618286246
> 88 21.6368286445013 1.10034379028792 1200 "NORTE" -0.901402119380404
> 85 25.1843952723718 1.05835010060362 1700 "NORTE" -0.763569644856491
> 75 18.6270125223614 1.09069658719028 1850 "NORTE" -1.03282454813011
> 64 29.9515311742675 1.08689655172414 1200 "OCCIDENTE" -1.03845836584836
> 77 26.2046204620462 1.11247966534976 650 "OCCIDENTE" -1.10563690360507
> 49 12.6096949435855 1.06872703695699 1475 "NORTE" -1.06421086195078
> 133 18.7464907355418 1.09098914000587 1535 "NORDESTE" -0.616186139423817
> 192 10.5534246575342 0.947705442902882 2300 "NORTE" 0.508021696433256
> 32 17.2654236774291 1.0462158808933 1875 "NORTE" -1.18417017702976
> 73 17.0988006853227 1.06583294006607 850 "OCCIDENTE" -1.04128722204884
> 139 15.3530911090010 1.03178310316816 1550 "NORDESTE" -0.245900538436826
> 52 19.3008705114255 1.02785822645152 1675 "NORTE" -0.473208760194684
> 17 6.27750073335289 0.95582329317269 2550 "NORTE" -1.69826912614072
> 307 26.0375981018434 1.03257159815996 450 "OCCIDENTE" 0.131028262406404
> 127 17.2681438238026 1.05732223283745 980 "NORDESTE" -0.520875959619492
> 182 15.4432793136320 1.05083088954057 700 "NORDESTE" -0.16960278438618
> 24 7.7125328659071 1.0375 1800 "NORTE" -1.76609172247948
> 51 30.1453193646502 1.18054532056006 25 "URABA" -2.21640739675299
> 141 14.8701064405557 1.08226897069872 1300 "OCCIDENTE" -0.138113302129634
> 40 24.7907034861927 1.08357198646186 1625 "OCCIDENTE" -1.18090753139494
> 76 17.3296398891967 1.11061739943873 1250 "NORDESTE" -1.11474167059799
> 40 10.7364199781261 1.09309423884014 700 "OCCIDENTE" -0.711311151187616
> 100 19.3800588668138 1.14100039385585 75 "MAGDALENA MEDIO" -0.86988435906
> 42 10.3085483055134 1.00222807372899 1800 "NORTE" -0.898942093539542
> 18 8.80185302168878 1.02085106382979 1925 "OCCIDENTE" -1.48722027970985
> 20 16.6951761888471 1.11658218682114 500 "OCCIDENTE" -1.99510039324608
> 18 4.50797141286421 1.08840413318025 2300 "NORTE" -1.22417551164346
> 75 6.84546862896979 0.940623825629463 1050 "NORDESTE" -0.648173814917214
> 26 8.21845174973489 1.07633027522936 2550 "NORTE" -1.48722027970985
> 21 6.19588744588745 1.24954351795496 1920 "OCCIDENTE" -1.9241486572738
> 216 16.9889711436773 1.06553284443751 1350 "OCCIDENTE" 0.188137942115395
> 81 5.59826387611726 1.02449921811006 2550 "NORTE" 0.162968828278140
> 90 8.68694955964772 1.03136617100372 1450 "NORDESTE" -0.233193887167711
> 69 3.65186966980101 0.890711135611907 2200 "NORTE" -0.415515443961666
> 138 16.1123827476325 1.01692767267131 550 "OCCIDENTE" -0.139262067333508
> 79 9.67841682127396 1.05692478931468 750 "OCCIDENTE" -0.638658995275876
> 69 13.5423542354235 1.00617965129111 950 "MAGDALENA MEDIO"
> -0.97021907389971
> 52 5.6497484139138 1.01988510826337 2475 "NORTE" -0.136965855073157
> 59 8.7686432740111 1.02820400409177 1975 "NORDESTE" -0.512493680866688
> 69 11.9602529358627 1.00325732899023 780 "OCCIDENTE" -0.807436326962073
> 173 6.86294126054023 0.969987048820317 1300 "VALLE DE ABURRA"
> 0.436963775167535
> 29 19.2194992008524 1.0319350473613 1800 "SUROESTE" -1.26584820804402
> 118 4.64579055441478 0.948 1425 "VALLE DE ABURRA" 0.392717535285662
> 23 9.50905993495431 0.976430976430976 1875 "ORIENTE" -1.21739582465808
> 1456 2.79913286437223 0.912491945614184 1450 "VALLE DE ABURRA"
> 2.50894864426824
> 156 10.2515243902439 1.03805825242718 1475 "NORDESTE" -0.0693500781347932
> 26 8.66738894907909 1.01016333938294 1650 "ORIENTE" -1.53247687129797
> 208 3.6576768917803 0.934502240405221 1425 "VALLE DE ABURRA"
> 0.718814927308523
> 294 12.4953778763831 0.936918076139056 125 "MAGDALENA MEDIO"
> 0.368801123736573
> 84 15.2370770972205 1.03298389158783 1150 "OCCIDENTE" -0.398986142010455
> 57 21.2257484260568 1.06829657188414 625 "OCCIDENTE" -1.09961278900169
> 84 7.8413206434768 1.04918881601657 2150 "ORIENTE" 0.0295588022415444
> 121 12.5950805097303 1.04278074866310 1000 "ORIENTE" -0.162518929497775
> 112 6.23108480731724 0.99369804237061 2150 "ORIENTE" 0.272314595320659
> 25 4.72859966550099 1.00763125763126 1925 "ORIENTE" -1.20731170559145
> 9281 3.11622388590868 0.859808006713988 1550 "VALLE DE ABURRA"
> 4.33235045310693
> 36 15.9319508257792 1.06752246469833 1440 "OCCIDENTE" -1.09064411901893
> 71 6.69567319313512 0.976588628762542 2000 "ORIENTE" -0.369615455214467
> 812 2.47749261819931 0.900774538520513 1550 "VALLE DE ABURRA"
> 2.04485009691022
> 135 24.8112304583644 1.01435304198800 18 "URABA" -1.01060141134540
> 215 3.94306597422581 0.92939648374078 1775 "VALLE DE ABURRA"
> 0.580538236177291
> 94 2.71509876129896 0.934334930708457 1550 "VALLE DE ABURRA"
> 0.151002873536527
> 302 1.79760050991181 0.863916626564004 1575 "VALLE DE ABURRA"
> 1.57277392806251
> 148 4.80243967117475 1.00074278438031 2120 "ORIENTE" 0.579978482454307
> 42 18.7818696883853 1.02873563218391 1800 "OCCIDENTE" -1.17118298150295
> 84 5.24955116696589 0.882901764586573 2150 "ORIENTE" 0.407463110770837
> 114 19.0728713579217 1.05623621661358 1600 "SUROESTE" -0.269187489815617
> 54 12.6099706744868 1.09948152948801 1900 "SUROESTE" -1.26940060964839
> 309 3.58964845561636 0.971704768125408 2125 "ORIENTE" 1.20896034583698
> 148 11.3911041683795 1.01024708701760 1000 "ORIENTE" 0.0207825391825284
> 87 7.48350816481021 0.949198988195616 2050 "ORIENTE" -0.0693500781347932
> 75 15.0857882809971 0.999676323029616 1550 "SUROESTE" -0.659712404473708
> 275 19.6855832458419 0.99394006170119 1800 "SUROESTE" 0.441475545631197
> 171 12.2966073388367 1.02639721523883 375 "MAGDALENA MEDIO"
> -0.100925918589961
> 210 4.08228296275315 0.963297650493535 1750 "VALLE DE ABURRA"
> 0.789820067820206
> 209 21.4270750408514 1.02262711864407 2000 "SUROESTE" 0.0797349680188535
> 150 9.83262770545642 0.990626969124134 1400 "SUROESTE" 0.0168571170664228
> 69 6.28415300546448 1.02701607456437 2175 "ORIENTE" -0.502526820951296
> 157 4.2754914877677 0.962433460076046 2200 "ORIENTE" 0.56360780920496
> 110 10.4337099078042 1.05496997998666 1050 "ORIENTE" -0.391562202939173
> 93 13.9745206313318 0.995055517002082 1300 "ORIENTE" 0.0610950993598108
> 98 14.0491684743312 0.99971081550029 1350 "SUROESTE" -0.612489277542491
> 40 8.79131920024113 1.06194323596437 2350 "SUROESTE" -0.901402119380404
> 132 15.2282010300124 1.03248511099080 150 "MAGDALENA MEDIO"
> -0.62548853208613
> 155 19.1379750063759 1.06694781233527 1250 "SUROESTE" -0.151986356997882
> 152 6.89338235294118 1.01801801801802 2150 "ORIENTE" 0.630207380786071
> 62 5.51527398074409 1.01774793140664 2500 "ORIENTE" -0.331285709933913
> 52 18.3089033659066 1.01807723911257 1325 "SUROESTE" -1.09362474715707
> 50 23.5368956743003 1.03578996939016 1250 "ORIENTE" -0.999672340813206
> 124 10.3041872432253 1.00624427608026 1800 "SUROESTE" 0.0601539228197471
> 248 13.7563263088668 1.01527025469632 1100 "SUROESTE" 0.459953293392234
> 52 12.0249520153551 0.990068754774637 1800 "SUROESTE" -0.787457860031187
> 181 12.0066668763169 0.967759900990099 1800 "SUROESTE" 0.29266961396282
> 76 9.25797503467406 0.954370905805286 2000 "SUROESTE" -0.140412153716745
> 118 11.4912313643021 1.03321371306406 2125 "ORIENTE" 0.268499253035007
> 73 14.2689601250977 1.01163888015099 1750 "ORIENTE" -0.62548853208613
> 66 15.2254249815225 1.11626694473410 1550 "SUROESTE" -0.610645959048202
> 65 14.0718562874251 0.998290598290598 987.5 "SUROESTE" -0.884307686021104
> 75 9.21820303383897 0.964776990412672 1600 "SUROESTE" -0.136965855073157
> 33 9.9353894916494 1.00906196424198 2050 "SUROESTE" -1.01335244471729
> 71 8.6011885743498 1.01454685890834 1750 "SUROESTE" -0.372514007968479
> 84 14.7106815614409 1.04203511469947 1650 "ORIENTE" -0.375420986759788
> 223 8.6682462336269 0.990833036667853 2475 "ORIENTE" 0.745739630679116
> 229 10.9155102240965 1.02915422885572 1350 "SUROESTE" 0.673964361143171
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list