curve fitting

31 views
Skip to first unread message

Kazimir Menzel

unread,
Mar 15, 2013, 2:17:52 PM3/15/13
to ggp...@googlegroups.com
Dear list-members,

I would like to fit the following model to a ggplot:

PastedGraphic-1.pdf

Kazimir Menzel

unread,
Mar 16, 2013, 8:33:09 AM3/16/13
to Kazimir Menzel, ggp...@googlegroups.com
Sorry for the annoyance, just noticed, that Apple Mail made me somewhat unreadable. Here is the content of the mail again, the formula now in Latex code:

Dear list-members,

I would like to fit the following model to a ggplot:
 
Y = - k \ln(1 - X/N), where N = \sumX.

I was trying this with stat_function as below, but to no avail. The code represents the solution with the least error informations.

mod_1_fit <- stat_function(data = Frequencies,
aes(x = A, y = B),
#geom = "line",
#fun = -log(1-x/sum(A))*mod_1_res[4,3],
fun = log(1-A/sum(A))*mod_1_k,
colour = "red")

I am new to R, to statistics, and to model fitting, and made my way through trial and error. Unfortunately, I don't know how to interprete the error notice.

"Error in eval(expr, envir, enclos) : object 'A' not found" 


If this helps, the plot is transformed via coord_trans("log,"log", c(.5, sum(A)), c(.5, sum(A)).

Testing the curve alone, it works well in base graphics, so my best guess is that I am misunderstanding some of the intricacies of stat_function().

Thanks for your help!

K.M.
 
I found that stat_function required a starting point at the origin, but I thought this would not be affected by the coord_trans() command.

Kaz.


On Mar 15, 2013, at 07:17 PM, Kazimir Menzel <kazimir...@me.com> wrote:

Dear list-members,

I would like to fit the following model to a ggplot:

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


.

I was trying this with stat_function as below, but to no avail. The code represents the solution with the least error informations.

mod_1_fit <- stat_function(data = Frequencies,
aes(x = A, y = B),
#geom = "line",
#fun = -log(1-x/sum(A))*mod_1_res[4,3],
fun = log(1-A/sum(A))*mod_1_k,
colour = "red")

I am new to R, to statistics, and to model fitting, and made my way through trial and error. Unfortunately, I don't know how to interprete the error notice.

"Error in eval(expr, envir, enclos) : object 'A' not found" 


If this helps, the plot is transformed via coord_trans("log,"log", c(.5, sum(A)), c(.5, sum(A)).

Testing the curve alone, it works well in base graphics, so my best guess is that I am misunderstanding some of the intricacies of stat_function().

Thanks for your help!

K.M.
Reply all
Reply to author
Forward
0 new messages