# [R] constraints again

Pfaff, Bernhard Bernhard.Pfaff at drkw.com
Tue Oct 22 12:55:21 CEST 2002

```Hello Mark,

you might try a simple time trend as an regressor. BTW, is it really
neccesarry to estimate the model by nls? Wouldn't lm suffice?

Bernhard

-----Original Message-----
From: Mark Span [mailto:mspan at swets.nl]
Sent: 22 October 2002 11:55
To: 'r-help at lists.R-project.org'
Subject: [R] constraints again

I would like to fit the following function on my data.

out.nls<-nls(z ~ p1+

(p2*dat)+(p3*dat^2)+(p4*dat^3)+(p5*AgeS)+(p6*AgeS^2)+(p7*AgeS^3)+
(p8*(dat*AgeS))+(p9*(dat^2*AgeS))+(p10*(dat^3*AgeS))+

(p11*(dat*AgeS^2))+(p12*(dat*AgeS^3))+(p13*(dat^2*AgeS^2))+
(p14*(dat^2*AgeS^3))+(p15*(dat^3*AgeS^3)),

start=list(p1=0,p2=0,p3=0,p4=0,p5=0,p6=0,p7=0,p8=0,p9=0,p10=0,p11=0,p12=0,p1
3=0,p14=0,p15=0),trace=trace,
control=control)

which relates the z-score on a IQ subtest to Age (AgeS) and Raw Score (dat).
Allthough the dataset is quite large, older subjects usually do not provide
large 'raw scores', and young subjects do not provide low scores. This leads
to incorrect fits for large raw scores for older subjects and low raw scores
for young subjects. I would like to constrain the fit so, that the 'link'
between raw score and z-score for all ages is monotonical. Can anybody
direct me to an answer?

Looking through FAQ and list, I realize that there is no 'easy way'. So
presumably I am looking for directions...

Mark M. Span

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

----------------------------------------------------------------------
If you have received this e-mail in error or wish to read our e-mail
disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.
----------------------------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```