[R] nls and rbinom function: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
peter dalgaard
pdalgd at gmail.com
Tue Jan 3 09:11:31 CET 2012
On Jan 3, 2012, at 05:25 , G Vishwanath wrote:
> I am trying to learn nls using a simple simulation. I assumed that the binomial prob varies linearly as 0.2 + 0.3*x in x {0,1},
> and the objective is to recover the known parameters a=0.2, b=0.3
>
> ..data frame d has 1000 rows...
>
> d$x<-runif(0,1)
...(1000,0,1), I presume.
>
>
> d$y<-rbinom(1000,1,0.2+0.3*d$x)
>
> table(d$y,cut(d$x,breaks=5));
>
> (-0.000585,0.199] (0.199,0.399] (0.399,0.599] (0.599,0.799] (0.799,0.999]
> 0 154 149 130 122 114
> 1 34 48 71 76 102
>
> z <- nls(y ~ rbinom(1000,1,a+b*x),data=d,start= list(a =0.1,b=0.2),trace=T);
>
This makes no sense. Random numbers in a model specification????
y~a+b*x might give a result, but you're fitting a model which assumes Gaussian errors with constant variance to data that are nothing of the sort.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list