[R-sig-phylo] fitting cuadratic model using gnls

2013-12-10 Thread Jorge Sánchez Gutiérrez
Hello everyone,

 

I’m trying to fit nonlinear models using the function “gnls” in ape. For
example, I run a simple quadratic regression of moult duration (duration)
and latitude (latitude_used) as follows:

 

mod - duration ~ latitude_used +I(latitude_used^2)

init-list(alpha=1,beta=1)

m3 - gnls(mod, data=data, start=init, correlation = dataCor)

 

However, I get the following error message:

 

“Error in gnls(mod, data=data, start = init, correlation = dataCor) : 

  step halving factor reduced below minimum in NLS step”

 

I’ve also tried with several correlation structures and different starting
values for estimation, but without success. I would be very grateful if you
can provide any suggestions.

 

Thanks in advance,

Jorge S. Gutiérrez


[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Re: [R-sig-phylo] fitting cuadratic model using gnls

2013-12-10 Thread Theodore Garland Jr
I don't know, but one thing to watch out for is a high correlation between X 
and Xsquared.
That gives multicollinearity and can lead to numerical problems.
One thing that is commonly done is:
  1.  standardize the X variable (subtract mean and divide by standard 
deviation)
  2.  square that value and use it for the quadratic
This is referred to as an orthogonol polynomial.

Cheers,
Ted

Theodore Garland, Jr., Professor
Department of Biology
University of California, Riverside
Riverside, CA 92521
Office Phone:  (951) 827-3524
Wet Lab Phone:  (951) 827-5724
Dry Lab Phone:  (951) 827-4026
Home Phone:  (951) 328-0820
Skype:  theodoregarland
Facsimile:  (951) 827-4286 = Dept. office (not confidential)
Email:  tgarl...@ucr.edu
http://www.biology.ucr.edu/people/faculty/Garland.html
http://scholar.google.com/citations?hl=enuser=iSSbrhwJ

Inquiry-based Middle School Lesson Plan:
Born to Run: Artificial Selection Lab
http://www.indiana.edu/~ensiweb/lessons/BornToRun.html

Fail Lab: Episode One
http://testtube.com/faillab/zoochosis-episode-one-evolution
http://www.youtube.com/watch?v=c0msBWyTzU0


From: r-sig-phylo-boun...@r-project.org [r-sig-phylo-boun...@r-project.org] on 
behalf of Jorge Sánchez Gutiérrez [jorgesgutier...@unex.es]
Sent: Tuesday, December 10, 2013 9:48 AM
To: r-sig-phylo@r-project.org
Subject: [R-sig-phylo] fitting cuadratic model using gnls

Hello everyone,



I’m trying to fit nonlinear models using the function “gnls” in ape. For
example, I run a simple quadratic regression of moult duration (duration)
and latitude (latitude_used) as follows:



mod - duration ~ latitude_used +I(latitude_used^2)

init-list(alpha=1,beta=1)

m3 - gnls(mod, data=data, start=init, correlation = dataCor)



However, I get the following error message:



“Error in gnls(mod, data=data, start = init, correlation = dataCor) :

  step halving factor reduced below minimum in NLS step”



I’ve also tried with several correlation structures and different starting
values for estimation, but without success. I would be very grateful if you
can provide any suggestions.



Thanks in advance,

Jorge S. Gutiérrez


[[alternative HTML version deleted]]


___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] fitting cuadratic model using gnls

2013-12-10 Thread Ben Bolker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 13-12-10 12:57 PM, Theodore Garland Jr wrote:
 I don't know, but one thing to watch out for is a high correlation 
 between X and Xsquared. That gives multicollinearity and can lead 
 to numerical problems. One thing that is commonly done is: 1. 
 standardize the X variable (subtract mean and divide by standard 
 deviation) 2.  square that value and use it for the quadratic This 
 is referred to as an orthogonol polynomial.
 
 Cheers, Ted
 

  Yes.  Therefore, you would be (much) better off wit

 m3 - gls(duration ~ poly(latitude_used,2), data=data,
correlation = dataCor)

(A quadratic model is still a *linear* fit in the statistical sense.)

poly() will generate orthogonal polynomials by default, which will be
more stable and are more appropriate if you're planning to test the
significance of terms.  If it is important to you to have the
parameters interpretable as slope and curvature at the equator (i.e.
where latitude=0), you may be able to get away with

m3 - gls(duration ~ poly(latitude_used,2,raw=TRUE), data=data,
correlation = dataCor)



 Theodore Garland, Jr., Professor Department of Biology University 
 of California, Riverside Riverside, CA 92521 Office Phone:  (951) 
 827-3524 Wet Lab Phone:  (951) 827-5724 Dry Lab Phone:  (951) 
 827-4026 Home Phone:  (951) 328-0820 Skype:  theodoregarland 
 Facsimile:  (951) 827-4286 = Dept. office (not confidential)
 Email: tgarl...@ucr.edu 
 http://www.biology.ucr.edu/people/faculty/Garland.html 
 http://scholar.google.com/citations?hl=enuser=iSSbrhwJ
 
 Inquiry-based Middle School Lesson Plan: Born to Run: Artificial 
 Selection Lab 
 http://www.indiana.edu/~ensiweb/lessons/BornToRun.html
 
 Fail Lab: Episode One 
 http://testtube.com/faillab/zoochosis-episode-one-evolution 
 http://www.youtube.com/watch?v=c0msBWyTzU0
 
  From: 
 r-sig-phylo-boun...@r-project.org 
 [r-sig-phylo-boun...@r-project.org] on behalf of Jorge Sánchez 
 Gutiérrez [jorgesgutier...@unex.es] Sent: Tuesday, December 10, 
 2013 9:48 AM To: r-sig-phylo@r-project.org Subject: [R-sig-phylo] 
 fitting cuadratic model using gnls
 
 Hello everyone,
 
 
 
 I’m trying to fit nonlinear models using the function “gnls” in 
 ape. For example, I run a simple quadratic regression of moult 
 duration (duration) and latitude (latitude_used) as follows:
 
 
 
 mod - duration ~ latitude_used +I(latitude_used^2)
 
 init-list(alpha=1,beta=1)
 
 m3 - gnls(mod, data=data, start=init, correlation = dataCor)
 
 
 
 However, I get the following error message:
 
 
 
 “Error in gnls(mod, data=data, start = init, correlation =
 dataCor) :
 
 step halving factor reduced below minimum in NLS step”
 
 
 
 I’ve also tried with several correlation structures and different 
 starting values for estimation, but without success. I would be 
 very grateful if you can provide any suggestions.
 
 
 
 Thanks in advance,
 
 Jorge S. Gutiérrez
 
 
 [[alternative HTML version deleted]]
 
 
 ___ R-sig-phylo
 mailing list - R-sig-phylo@r-project.org 
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable 
 archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSp2DoAAoJEOCV5YRblxUHn4gH/jYtxFo6aj2DlHAPw2FXufA4
CwtJmIHpWlnD5mhg5YqBgJNldn2XPxqx/qEf0mMzRgd2gAyIQiXd91WI6sqkaVhF
FmYSPzClqx14jZSlF64KE54l/8W4mp81rDyYnh+/SSebltCrX8Cv7NqYqvNDhYQC
M7i/avh0NNv/PZuDuUwbj95doQmdeUyeSlig0sxHaP14C7FxzvxODUBhcTB6yQzN
0wuK+iIaUKqSGm3jmcpY08oy0RJ34QfyH175UezRmSaE/RI+XCohhBbdtU5+WgRX
lBRYmwtCIGAJ+DNmhlnhE3u6ZFdnzhw95gYd1LGL3Sr+JZl1U+VIKfIjhlrTgLQ=
=lLum
-END PGP SIGNATURE-

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] fitting cuadratic model using gnls

2013-12-10 Thread Jorge Sánchez Gutiérrez
Thanks Ted and Ben for your useful comments. I used poly() to generate
orthogonal polynomials of degree 2 and it seems to work well. 

Cheers, Jorge

-Mensaje original-
De: Ben Bolker [mailto:bbol...@gmail.com] 
Enviado el: martes, 10 de diciembre de 2013 19:44
Para: r-sig-phylo@r-project.org; Jorge Sánchez Gutiérrez
Asunto: Re: [R-sig-phylo] fitting cuadratic model using gnls

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 13-12-10 12:57 PM, Theodore Garland Jr wrote:
 I don't know, but one thing to watch out for is a high correlation 
 between X and Xsquared. That gives multicollinearity and can lead to 
 numerical problems. One thing that is commonly done is: 1.
 standardize the X variable (subtract mean and divide by standard
 deviation) 2.  square that value and use it for the quadratic This is 
 referred to as an orthogonol polynomial.
 
 Cheers, Ted
 

  Yes.  Therefore, you would be (much) better off wit

 m3 - gls(duration ~ poly(latitude_used,2), data=data,
correlation = dataCor)

(A quadratic model is still a *linear* fit in the statistical sense.)

poly() will generate orthogonal polynomials by default, which will be more
stable and are more appropriate if you're planning to test the significance
of terms.  If it is important to you to have the parameters interpretable as
slope and curvature at the equator (i.e.
where latitude=0), you may be able to get away with

m3 - gls(duration ~ poly(latitude_used,2,raw=TRUE), data=data,
correlation = dataCor)



 Theodore Garland, Jr., Professor Department of Biology University of 
 California, Riverside Riverside, CA 92521 Office Phone:  (951)
 827-3524 Wet Lab Phone:  (951) 827-5724 Dry Lab Phone:  (951)
 827-4026 Home Phone:  (951) 328-0820 Skype:  theodoregarland
 Facsimile:  (951) 827-4286 = Dept. office (not confidential)
 Email: tgarl...@ucr.edu
 http://www.biology.ucr.edu/people/faculty/Garland.html
 http://scholar.google.com/citations?hl=enuser=iSSbrhwJ
 
 Inquiry-based Middle School Lesson Plan: Born to Run: Artificial 
 Selection Lab
 http://www.indiana.edu/~ensiweb/lessons/BornToRun.html
 
 Fail Lab: Episode One
 http://testtube.com/faillab/zoochosis-episode-one-evolution
 http://www.youtube.com/watch?v=c0msBWyTzU0
 
  From: 
 r-sig-phylo-boun...@r-project.org
 [r-sig-phylo-boun...@r-project.org] on behalf of Jorge Sánchez 
 Gutiérrez [jorgesgutier...@unex.es] Sent: Tuesday, December 10,
 2013 9:48 AM To: r-sig-phylo@r-project.org Subject: [R-sig-phylo] 
 fitting cuadratic model using gnls
 
 Hello everyone,
 
 
 
 I’m trying to fit nonlinear models using the function “gnls” in ape. 
 For example, I run a simple quadratic regression of moult duration 
 (duration) and latitude (latitude_used) as follows:
 
 
 
 mod - duration ~ latitude_used +I(latitude_used^2)
 
 init-list(alpha=1,beta=1)
 
 m3 - gnls(mod, data=data, start=init, correlation = dataCor)
 
 
 
 However, I get the following error message:
 
 
 
 “Error in gnls(mod, data=data, start = init, correlation =
 dataCor) :
 
 step halving factor reduced below minimum in NLS step”
 
 
 
 I’ve also tried with several correlation structures and different 
 starting values for estimation, but without success. I would be very 
 grateful if you can provide any suggestions.
 
 
 
 Thanks in advance,
 
 Jorge S. Gutiérrez
 
 
 [[alternative HTML version deleted]]
 
 
 ___ R-sig-phylo mailing 
 list - R-sig-phylo@r-project.org 
 https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive 
 at http://www.mail-archive.com/r-sig-phylo@r-project.org/
 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSp2DoAAoJEOCV5YRblxUHn4gH/jYtxFo6aj2DlHAPw2FXufA4
CwtJmIHpWlnD5mhg5YqBgJNldn2XPxqx/qEf0mMzRgd2gAyIQiXd91WI6sqkaVhF
FmYSPzClqx14jZSlF64KE54l/8W4mp81rDyYnh+/SSebltCrX8Cv7NqYqvNDhYQC
M7i/avh0NNv/PZuDuUwbj95doQmdeUyeSlig0sxHaP14C7FxzvxODUBhcTB6yQzN
0wuK+iIaUKqSGm3jmcpY08oy0RJ34QfyH175UezRmSaE/RI+XCohhBbdtU5+WgRX
lBRYmwtCIGAJ+DNmhlnhE3u6ZFdnzhw95gYd1LGL3Sr+JZl1U+VIKfIjhlrTgLQ=
=lLum
-END PGP SIGNATURE-

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/