[R] Fitting this data with a gaussian would be great
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 have tried a variety of options for the formula with the same effect. What I want to do with this data is simply fit it with a non linear model, most likely a gaussian. Thanks in advance, Samantha [[alternative HTML version deleted]] __ 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.
[R] Fitting a gaussian distribution to a plot
I have a peak I would like to fit with a gaussian distribution, and am having difficulties. First of all I am having difficulties getting R to except my function input, and additionally I am having trouble plotting the non linear model on my scatterplot of data (the peak). Here is my log: 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) plot(small) mean(small) [1] 563996.7 sd(small) [1] 55996.21 x -c(0:35) x -as.numeric(x) f - ((1/(55996.21)*sqrt(2*pi)))*exp^(-((x-563996.7)^2)/(2*(55996.21^2))) Error in exp^(-((x - 563996.7)^2)/(2 * (55996.21^2))) : non-numeric argument to binary operator From this point, to fit a non-linear model so I type nlm(f,507680)? I have tried reading up on this and looking for additional information on the internet but I am truly stuck. Thank you in advance! Samantha __ 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.