[R] Fitting this data with a gaussian would be great

Ben Bolker bbolker at gmail.com
Sat Feb 23 00:32:32 CET 2013


Samantha Warnes <warnes <at> wisc.edu> writes:

> 
> Hello,I'm still working with this data set, and 
> trying to fit it with a nonlinear model. Here is my data
> > small <- c(507680,507670,508832,510184,511272,513380,515828,
  519160,525046,
  534046,547982,567124,590208,614506,637876,656846,669054,672976,668800,
656070,637136,614342,590970,570752,554480,542882,535630,531276,528682,
  527682,527020,526834,526802,526860)
> 
> test <- glm(dnorm(x), data=small)
> Error in formula.default(object, env = baseenv()) : invalid formula
> 

  I'm sorry, but as stated the question doesn't make much sense.
  You haven't stated your nonlinear model at all, and you haven't
said anything about any predictor variables.
  
  If you want fit a *constant* normal model you can

1. Compute the mean and standard deviation of the data (which
are the parameters of the model): mean(small), sd(small)

2. use an intercept-only model with lm(small~1) or glm(small~1)
(although the latter is definitely overkill)

3. You *can* use a nonlinear fitting method to estimate an
intercept-only model

nls(small~a,start=list(a=564000))

but it doesn't really mean much.

  Ben Bolker



More information about the R-help mailing list