[R-sig-ME] R: gls() funcion after R upgrade

Phillip Alday ph||||p@@|d@y @end|ng |rom mp|@n|
Tue Feb 19 17:43:13 CET 2019


This seems like a bug / compiler issue on 32-bit Windows. I don't have a
convenient Windows machine to test it out myself, but you should report
it (along with your minimal example):

https://cran.r-project.org/web/packages/nlme/index.html

Also: for many reasons (performance, ability to work with larger
datasets, etc.), if you have access to the 64-bit versions, you should
be using them!

Phillip

On 19/2/19 5:02 pm, Fabio Fanoni wrote:
> Dear Phillip,
> 
> thanks for the reply
> 
> I tried both to re-install the package nlme (and all its dependencies) and to re-install R as a whole but I always get the same error message
> 
> The problem seems to be related to the varExp() variance function structures on a 32-bit windows platform
> With 64-bit windows platform, the old version 3.3.2 and the new version 3.5.2 produce the same results
> At the same time, the varPower() function always produces the same results regardless of the windows platform or version of R
> The following table shows the coefficients obtained according to the platform (32 bit / 62 bit), version of R and variance function
> 
> Platform	Version	weights	   	ITOD	   	EU_CH
> windows 32 bit	3.3.2	varExp()	-0.1053291	-0.4406068
> windows 32 bit	3.5.2	varExp()	<NA>	         <NA>
> windows 64 bit	3.3.2	varExp()	-0.3011427	-0.5537158
> windows 64 bit	3.5.2	varExp()	-0.3011427	-0.5537158
> windows 32 bit	3.3.2	varPower()	-0.3138869	-0.5010393
> windows 32 bit	3.5.2	varPower()	-0.3138869	-0.5010393
> windows 64 bit	3.3.2	varPower()	-0.3138868	-0.5010394
> windows 64 bit	3.5.2	varPower()	-0.3138868	-0.5010394
> 				
> linux 64 bit	3.5.2	varExp()	-0.3123153 	-0.4979789
> 
> These values differ from what I reported in the previous e-mail. For a “copy and paste” mistake, in the previous e-mail I reported the results obtained with the varPower() function instead of varExp() function. 
> 
> Here is the correct output
> 
>> gls(as.formula(f),correlation=corARMA(p=2,q=3,fixed=FALSE),data=db,weights=varExp(),method="ML")
> Generalized least squares fit by maximum likelihood
>   Model: as.formula(f) 
>   Data: db 
>   Log-likelihood: 12.11128
> 
> Coefficients:
>       ITOD      EU_CH 
> -0.1053291 -0.4406068 
> 
> Correlation Structure: ARMA(2,3)
>  Formula: ~1 
>  Parameter estimate(s):
>       Phi1       Phi2     Theta1     Theta2     Theta3 
>  0.6485554 -0.1750409  0.9450232  0.9566344  0.9566288 
> Variance function:
>  Structure: Exponential of variance covariate
>  Formula: ~fitted(.) 
>  Parameter estimates:
>         expon 
> -0.0007047246 
> Degrees of freedom: 71 total; 69 residual
> Residual standard error: 0.7740528
> 
> On the 3.5.2 version of R, the sessionInfo() show "Matrix products: default" whereas in the 3.3.2 version this message does not appear. 
> 
> If I set options(matprod="internal") on the 3.5.2 I avoid the error but the results I get are very different from those of version 3.3.2
> 
> If I use the REML method instead of the ML I get much more similar results but, at the same time, very different from those I would get with the same method on the version 3.2.2
> 
> Maybe these clues can inspire a solution?
> 
> 
> Fabio
> 
> 
> 
> 
> 
> -----Messaggio originale-----
> Da: Alday, Phillip <Phillip.Alday using mpi.nl> 
> Inviato: martedì 19 febbraio 2019 00:44
> A: Fabio Fanoni <fabio.fanoni using popso.it>; r-sig-mixed-models using r-project.org
> Oggetto: Re: [R-sig-ME] gls() funcion after R upgrade
> 
> Dear Fabio,
> 
> Your example runs fine on my machine, and I have a comparable R and nlme version. Have you tried re-installing nlme and all its dependencies?
> 
> install.packages("nlme",dependencies=TRUE)
> 
> Sometimes dependencies can get out of sync and this can lead to weird errors. (I've had this happen when lme4 was compiled against a different Rcpp version than Matrix.)
> 
> As a sidebar, I get different estimates than your old output had:
> 
> 
>>
> gls(as.formula(f),correlation=corARMA(p=2,q=3,fixed=FALSE),data=db,weights=varExp(),method="ML")
> Generalized least squares fit by maximum likelihood
>   Model: as.formula(f)
>   Data: db
>   Log-likelihood: 11.74371
> 
> Coefficients:
>       ITOD      EU_CH
> -0.3123153 -0.4979789
> 
> Correlation Structure: ARMA(2,3)
>  Formula: ~1
>  Parameter estimate(s):
>       Phi1       Phi2     Theta1     Theta2     Theta3
>  0.7542011 -0.2467866  0.8989841  0.9444138  0.9092150 Variance function:
>  Structure: Exponential of variance covariate
>  Formula: ~fitted(.)
>  Parameter estimates:
>       expon
> -0.01497128
> Degrees of freedom: 71 total; 69 residual Residual standard error: 0.817064
> 
> (Note that "power" is now called "expon" for "exponent".) The small differences in the exponent and the coefficients could be numerical issues, but the big differences in ARMA seem a bit worrying. The log-likelihood of 'my' fit is better, but the residual standard error is worse.
> 
> Best,
> 
> Phillip
> 
>> sessionInfo()
> R version 3.5.2 (2018-12-20)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Linux Mint 19.1
> 
> Matrix products: default
> BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
> LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
> 
> ::snip::
> 
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> other attached packages:
> [1] nlme_3.1-137
> 
> loaded via a namespace (and not attached):
> [1] compiler_3.5.2  grid_3.5.2      lattice_0.20-38
> 
> On 11/2/19 9:40 am, Fabio Fanoni wrote:
>> Dear all,
>>
>> I have been using the package nlme for about a year through the 
>> software R
>>
>> Recently, following an update of R (and the corresponding nlme package), in some situations the gls() function does not work.
>>
>>
>> The following lines of code
>>
>> require(nlme)
>> db<-read.csv2("G:\\Dati.csv",as.is=TRUE)
>> f<-"DELTA_INVNORM_STD ~ 0+ ITOD + EU_CH"
>> gls(as.formula(f),correlation=corARMA(p=2,q=3,fixed=FALSE),data=db,wei
>> ghts=varExp(),method="ML")
>>
>>
>> with the old version of R returns the following output:
>>
>> Generalized least squares fit by maximum likelihood
>>   Model: as.formula(f)
>>   Data: db
>>   Log-likelihood: -36.13853
>>
>> Coefficients:
>>       ITOD      EU_CH
>> -0.3138869 -0.5010393
>>
>> Correlation Structure: ARMA(2,3)
>> Formula: ~1
>>  Parameter estimate(s):
>>        Phi1        Phi2      Theta1      Theta2      Theta3
>>  0.50054107 -0.07357577  0.91847373  0.66706344  0.51689285 Variance 
>> function:
>> Structure: Power of variance covariate
>> Formula: ~fitted(.)
>>  Parameter estimates:
>>       power
>> -0.01893321
>> Degrees of freedom: 71 total; 69 residual Residual standard error: 
>> 0.4077908
>>
>>
>> while with the new one version of R ends with the following error 
>> message
>>
>> Error in `coef<-.corARMA`(`*tmp*`, value = value[parMap[, i]]) :
>>   NA/NaN/Inf in foreign function call (arg 1)
>>
>>
>>
>> here are the parameters of the old version of R
>>
>>> sessionInfo()
>> R version 3.3.2 (2016-10-31)
>> Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows >= 8 
>> x64 (build 9200)
>>
>> locale:
>> [1] LC_COLLATE=Italian_Italy.1252  LC_CTYPE=Italian_Italy.1252    LC_MONETARY=Italian_Italy.1252
>> [4] LC_NUMERIC=C                   LC_TIME=Italian_Italy.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] nlme_3.1-128
>>
>> loaded via a namespace (and not attached):
>> [1] tools_3.3.2     grid_3.3.2      lattice_0.20-34
>>
>>
>>
>> and the correspondents of the new one
>>
>>> sessionInfo()
>> R version 3.5.2 (2018-12-20)
>> Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows >= 8 
>> x64 (build 9200)
>>
>> Matrix products: default
>>
>> locale:
>> [1] LC_COLLATE=Italian_Italy.1252  LC_CTYPE=Italian_Italy.1252    LC_MONETARY=Italian_Italy.1252
>> [4] LC_NUMERIC=C                   LC_TIME=Italian_Italy.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] nlme_3.1-137
>>
>> loaded via a namespace (and not attached):
>> [1] compiler_3.5.2  tools_3.5.2     grid_3.5.2      lattice_0.20-38
>>
>> The data used are shown below
>>
>>
>> I wonder if someone could help me to solve this problem.
>>
>> Best regards,
>>
>> Fabio Fanoni
>>
>>
>> DELTA_INVNORM_STD;ITOD;EU_CH
>> -1,01888891391635;1,11744160507933;0,164921569515933
>> -1,7287582158078;1,33122211515022;0,192399322297369
>> -1,92084919508607;1,42620153798496;0,119394703266418
>> -1,07481132504896;1,40851069525448;-0,21451386962765
>> 0,368325144516397;1,143582080184;-0,541418306765893
>> 1,60232300735139;0,877753890833926;-0,540071359447086
>> 1,79762928248747;0,585114281768911;-0,457099318942592
>> 0,91995670533225;0,300270733467356;-0,292232806294851
>> -0,0262660321428139;0,20146037523289;-0,236469135573377
>> -1,02121152912805;0,0419782544708825;-0,345437279939175
>> -1,10672650470506;0,0574913198102401;-0,366584376685452
>> -1,39178681241528;0,33582796272111;-0,222730255141816
>> -1,1454072922613;0,119188584353956;-0,00950828000562807
>> -0,958672816825354;-0,0667970836192611;0,4570747351185
>> -1,32272038017045;-0,307712992787705;0,958678420940093
>> -0,907400017348963;-0,781894397724971;1,3426934842003
>> -1,24178782808971;-0,502123817789113;1,78543551198139
>> -0,727279530248652;-0,198729005124588;1,65424271463061
>> -0,663683090224516;-0,00292614483254617;1,29016249027665
>> -0,870662613154294;0,284152373447782;0,852269477692287
>> -0,740956260890321;0,212558271927232;0,359286261984589
>> -0,875175106507846;0,16921613723138;0,301636857743261
>> -0,159691021207123;0,344902273564796;0,406160071512065
>> 0,485359221230746;0,405193753056144;0,545299871378597
>> 0,91806657022351;0,51772409209882;0,664639525858513
>> 0,94182403298868;0,624398008842597;0,721750147939642
>> 0,772810225693767;0,669380547864261;0,746938090683181
>> 0,454079892235428;0,829860577818214;0,875841077996076
>> 0,216198540864624;0,85936757871922;1,06778126286636
>> -0,390013295840405;0,820301653758161;1,32356681853436
>> -1,08957286663887;0,735286971796754;1,51483352772482
>> -1,7181964072478;0,54188741408352;1,59807495122772
>> -2,14142427321141;0,3080114833751;1,30188093962788
>> -1,73631132303729;0,242276386254216;0,821154955431617
>> -1,14832298161027;-0,168559611137128;0,390400772122712
>> -0,199657255063557;-0,673990227176314;-0,425580724204736
>> 0,637711021315926;-1,26311924357155;-0,777807797606142
>> 1,13372564859946;-2,22697608948676;-1,02793616079627
>> 1,3387228312938;-2,67326030450369;-1,25476231880355
>> 1,13410628583832;-2,41425486942835;-0,769187327492251
>> 1,20371911407773;-1,73317141026889;-0,4868668898436
>> 1,04245681382429;-0,627677467262121;-0,517038541303494
>> 1,19122635858486;0,318264079861633;-0,902669938921763
>> 1,10644115835792;0,53399823108225;-1,58826681113873
>> 0,657027862693417;0,566924775110004;-2,16826290930735
>> 0,391546504792817;0,382793958142103;-2,37380727704873
>> -0,121513593301095;0,113508212335312;-2,28814134594747
>> 0,090587410027589;-0,10456301293743;-1,92150191643467
>> 0,293363258062962;-0,599038773090656;-1,5279235122598
>> 0,490646403474033;-1,16804784867814;-1,10646327070376
>> 0,663013157660536;-1,68022387383074;-0,281457211581005
>> 0,48006697458688;-2,17535440458421;0,0140633243390067
>> 0,33992207153128;-2,15751594621565;0,415319331867849
>> 0,485131796838891;-1,91164287702336;0,74289724468591
>> 0,645057199360022;-1,64072137764755;0,715150100824384
>> 0,830719890823037;-1,20839230550334;0,886616664628225
>> 1,00060688160202;-0,799350150825283;0,78775063121476
>> 0,799516770753564;-0,474799224784852;0,620190215847712
>> 0,884527141039385;-0,111321336688718;0,400772282236831
>> 0,77592825475446;0,41873781137028;0,214623979323192
>> 0,897761905934407;0,618216183184323;-0,371702774880583
>> 1,23087946317063;0,86282014652723;-1,04275259746654
>> 1,1730433788867;1,03592979384644;-1,50933562067236
>> 1,18413315011977;0,843466359597336;-1,89254251877396
>> 0,522306442129412;0,786432900675309;-1,199941514842
>> -0,423472231576842;0,534354713733984;-0,258289703958632
>> -1,02160314495135;0,445296924001273;0,367637345059225
>> -1,2194743130469;0,791437804698057;0,831122380946011
>> -0,682787491324478;0,735393577499657;0,636488297397258
>> -0,277058822726022;0,988210808618591;0,362382895620209
>> -0,0283252883031908;1,18581655608866;0,466771415869385
>>
>>
>>
>>
>> Fabio Fanoni
>> SVILUPPO MODELLI DI CREDITO
>> Piazza Garibaldi 16
>> 23100 Sondrio (SO)
>> Banca Popolare di Sondrio
>> Tel. +390342528920
>> fabio.fanoni using popso.it<mailto:fabio.fanoni using popso.it>
>>
>>
>> AVVERTENZE LEGALI - I contenuti di questo messaggio, proveniente da un indirizzo di posta elettronica aziendale della Banca Popolare di Sondrio, e gli eventuali allegati possono essere letti e utilizzati, per esigenze lavorative, da chi opera alle dipendenze o per conto della stessa, o ? comunque cointeressato nell'inerente relazione d'affari. Le dichiarazioni, ivi contenute, non impegnano contrattualmente la Banca Popolare di Sondrio se non nei limiti di quanto eventualmente previsto in accordi opportunamente formalizzati. Se il messaggio ? stato ricevuto per errore ce ne scusiamo, pregando di segnalare ci? al mittente e poi di distruggerlo senza farne alcun uso poich? l'utilizzo senza averne diritto ? vietato dalla legge e potrebbe costituire reato.
>>
>> DATI SOCIETARI - BANCA POPOLARE DI SONDRIO - Societ? cooperativa per 
>> azioni - Fondata nel 1871 Sede sociale e direzione generale: I - 23100 
>> SONDRIO SO - piazza Garibaldi, 16 Indirizzo Internet: 
>> http:[doppiabarra]www[punto]popso[punto]it - E-mail: 
>> info[chiocciola]popso[punto]it Iscritta al Registro delle Imprese di Sondrio al n. 00053810149, all'Albo delle Banche al n. 842, all'Albo delle Societ? Cooperative al n. A160536 Capogruppo del Gruppo bancario Banca Popolare di Sondrio, iscritto all'Albo dei Gruppi bancari al n. 5696.0 Aderente al Fondo Interbancario di Tutela dei Depositi e al Fondo Nazionale di Garanzia - Codice fiscale e partita IVA: 00053810149 Capitale sociale: EUR 1.360.157.331 - Riserve: EUR 947.325.264 (Dati approvati dall'Assemblea dei soci del 29 aprile 2017).
>>
>> N.B. I "filtri antivirus" e "antispam" in uso su molti sistemi di posta elettronica possono talvolta ritardare o impedire, in tutto o in parte, il recapito dei messaggi. In tali casi, salvo verifica di avvenuta ricezione, pu? essere necessario modificare i contenuti o le modalit? d'invio.
>>
>>
>> 	[[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list 
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list