Re: [R] nls() fit to Kahnemann/ Tversky function

2005-10-31 Thread Gabor Grothendieck
Note that a simple logistic with a saturation level of 1 seems
to do quite well.  Below we have removed the last point in order
to avoid the singularity:

x <- p.kum[-10]
y <- felt.prob.kum[-10]
plot(log(y/(1-y)) ~ x)
abline(lm(log(y/(1-y)) ~ x), col = "red")

On 10/31/05, Mark Hempelmann <[EMAIL PROTECTED]> wrote:
> Dear WizaRds,
>
> I would like to fit a curve to ten points with nls() for one
> unknown parameter gamma in the Kahnemann/ Tversky function, but somehow
> it won't work and I am unable to locate my mistake.
>
> p.kum <- seq(0.1,1, by=0.1)
> felt.prob.kum <- c(0.16, 0.23, 0.36, 0.49, 0.61, 0.71, 0.85, 0.89, 0.95,
> 1) ## how to find a function that fits these points nicely?
> plot(p.kum, felt.prob.kum) ## looks a little like an "S"
>
> gamma <- rep(0.5, 10)
> nls.dataframe <- data.frame(p.kum,felt.prob.kum, gamma)
>
> nls.kurve <- nls( formula = felt.prob.kum ~
> p.kum^gamma/(p.kum^gamma+(1-p.kum)^gamma)^(1/gamma), data=nls.dataframe,
> start=c(gamma=gamma), algorithm="plinear" )
>
> summary(nls.kurve)
>
> gives: Error in La.chol2inv(x, size) : 'size' cannot exceed nrow(x) = 10
>
> If I go with the Gauss-Newton algorithm I get an singular gradient
> matrix error, so I tried the Golub-Pereyra algorithm for partially
> linear least-squares.
>
> It also seems the nls model tries to find ten different gammas, but
> I want only one single gamma parameter for the function. I appreciate
> your help and support. Thank you.
>
> sol lucet omnibus
> Mark Hempelmann
>
> __
> R-help@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
>

__
R-help@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


Re: [R] nls() fit to Kahnemann/ Tversky function

2005-10-31 Thread apjaworski
Mark,

The parameter of your model (gamma) should not be a part of the dataframe.
In addition, the start argument should be a named list.

Something like this works

nls.dataframe <- data.frame(p.kum,felt.prob.kum)
nls.kurve <- nls( formula = felt.prob.kum ~
p.kum^gamma/(p.kum^gamma+(1-p.kum)^gamma)^(1/gamma), data=nls.dataframe,
start=list(gamma=.5), trace=TRUE) # trace shows convergence of the
algorithm.

but the fit is not very good as the fitted gamma is essentially 1.

Hope this helps,

Andy

__
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-
E-mail: [EMAIL PROTECTED]
Tel:  (651) 733-6092
Fax:  (651) 736-3122


   
 Mark Hempelmann   
 <[EMAIL PROTECTED] 
 e> To 
 Sent by:  r-help@stat.math.ethz.ch
 [EMAIL PROTECTED]  cc 
 at.math.ethz.ch   
   Subject 
   [R] nls() fit to Kahnemann/ Tversky 
 10/31/2005 04:14  function
 PM
   
   
   
   
   




Dear WizaRds,

 I would like to fit a curve to ten points with nls() for one
unknown parameter gamma in the Kahnemann/ Tversky function, but somehow
it won't work and I am unable to locate my mistake.

p.kum <- seq(0.1,1, by=0.1)
felt.prob.kum <- c(0.16, 0.23, 0.36, 0.49, 0.61, 0.71, 0.85, 0.89, 0.95,
1) ## how to find a function that fits these points nicely?
plot(p.kum, felt.prob.kum) ## looks a little like an "S"

gamma <- rep(0.5, 10)
nls.dataframe <- data.frame(p.kum,felt.prob.kum, gamma)

nls.kurve <- nls( formula = felt.prob.kum ~
p.kum^gamma/(p.kum^gamma+(1-p.kum)^gamma)^(1/gamma), data=nls.dataframe,
start=c(gamma=gamma), algorithm="plinear" )

summary(nls.kurve)

gives: Error in La.chol2inv(x, size) : 'size' cannot exceed nrow(x) = 10

 If I go with the Gauss-Newton algorithm I get an singular gradient
matrix error, so I tried the Golub-Pereyra algorithm for partially
linear least-squares.

 It also seems the nls model tries to find ten different gammas, but
I want only one single gamma parameter for the function. I appreciate
your help and support. Thank you.

sol lucet omnibus
Mark Hempelmann

__
R-help@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

__
R-help@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


[R] nls() fit to Kahnemann/ Tversky function

2005-10-31 Thread Mark Hempelmann
Dear WizaRds,

 I would like to fit a curve to ten points with nls() for one 
unknown parameter gamma in the Kahnemann/ Tversky function, but somehow 
it won't work and I am unable to locate my mistake.

p.kum <- seq(0.1,1, by=0.1)
felt.prob.kum <- c(0.16, 0.23, 0.36, 0.49, 0.61, 0.71, 0.85, 0.89, 0.95, 
1) ## how to find a function that fits these points nicely?
plot(p.kum, felt.prob.kum) ## looks a little like an "S"

gamma <- rep(0.5, 10)
nls.dataframe <- data.frame(p.kum,felt.prob.kum, gamma)

nls.kurve <- nls( formula = felt.prob.kum ~ 
p.kum^gamma/(p.kum^gamma+(1-p.kum)^gamma)^(1/gamma), data=nls.dataframe, 
start=c(gamma=gamma), algorithm="plinear" )

summary(nls.kurve)

gives: Error in La.chol2inv(x, size) : 'size' cannot exceed nrow(x) = 10

 If I go with the Gauss-Newton algorithm I get an singular gradient 
matrix error, so I tried the Golub-Pereyra algorithm for partially 
linear least-squares.

 It also seems the nls model tries to find ten different gammas, but 
I want only one single gamma parameter for the function. I appreciate 
your help and support. Thank you.

sol lucet omnibus
Mark Hempelmann

__
R-help@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