The problem is badly scaled -- parameters from very small to very big.

nlmrt package manages a bit better, but scaling would likely make it and nls both happier. nlxb insists on having its data in a data frame.

Here's my code

rm(list=ls())
Laptop_sale <- c(1405,
1863,2027,2669,2938,5275,6595,6943,8621,10905,12420,22400,32380,31600,34900,43163,47838,47592)
CuSale <- Laptop_sale
time <- seq_along(Laptop_sale)
Bass.Model <- Laptop_sale ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q /
p) * exp(-(p + q) * time) + 1)^2)
Bass.Fit <- nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m =max(CuSale)), trace = TRUE)
Bass.Fit
library(nlmrt)
xdata<-data.frame(Laptop_sale, time)
Bass.Fitn <- nlxb(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m = max(CuSale)), data=xdata,trace=TRUE)
Bass.Fitn


JN



Message: 22
Date: Tue, 27 Nov 2012 07:11:13 -0800 (PST)
From: Yifen <yifen.c...@gmail.com>
To: r-help@r-project.org
Subject: Re: [R] Problems with nls
Message-ID: <1354029073140-4650971.p...@n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi all,

I am encountering the same problem when I use nls to estimate the Bass
diffusion model. I used similar code in the previous replies and it works
with the data in this original post. However, I got an error when I use my
own data.

Error in nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m =
max(CuSale)),  :
  step factor 0.000488281 reduced below 'minFactor' of 0.000976563


Here is my code:

Laptop_sale <- c(1405,
1863,2027,2669,2938,5275,6595,6943,8621,10905,12420,22400,32380,31600,34900,43163,47838,47592)
CuSale <- Laptop_sale
time <- seq_along(Laptop_sale)
Bass.Model <- Laptop_sale ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q /
p) * exp(-(p + q) * time) + 1)^2)
Bass.Fit <- nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m =
max(CuSale)), trace = TRUE)


Can someone help me to figure out what the problem is? Thank you very much.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to