I don't know if this should be a new item or not.
I modified the code to be:
library(Rcpp)
rm(list = ls())
datafile <- data.frame(
N = c(1.5, 2.6, 0.555555555555556, 0.535714285714286, 0.418604651162791, 0.557377049180328, 0.463157894736842, 0.762589928057554, 0.583673469387755, 0.528350515463918, 0.649241146711636, 0.534764826175869, 0.556295802798135, 0.250856164383562, 0.202258726899384, 0.351266723598064, 0.226669475458184, 0.1275974583548, 0.0906183368869936, 0.123027510124284, 0.119124595871674)
)
View(datafile)
datafile$a<-dlogis(datafile$N, location = 0, scale = 1, log = FALSE)
datafile does not become 2 columns N rows. It becomes 1 column N+1 rows where the datafile$a becomes one more entry.
I am wondering if anyone would know whether this is the problem my code with dlogis or with optim.
1) Console says I am running dlogis correct.
Console at the same time says I am not running it correctly when I call optim with dlogis. What is the correct way to call optim with the below code?
2) Also, when I call dlogis, I want to find the parameters location and scale so that the errors with the data I feed in can be minimized. Are there other things I should pay attention?
Thank you
library(Rcpp)
rm(list = ls())
datafile <- data.frame(
N = c(1.5, 2.6, 0.555555555555556, 0.535714285714286, 0.418604651162791, 0.557377049180328, 0.463157894736842, 0.762589928057554, 0.583673469387755, 0.528350515463918, 0.649241146711636, 0.534764826175869, 0.556295802798135, 0.250856164383562, 0.202258726899384, 0.351266723598064, 0.226669475458184, 0.1275974583548, 0.0906183368869936, 0.123027510124284, 0.119124595871674)
)
View(datafile)
datafile$a<-dlogis(datafile$N, location = 0, scale = 1, log = FALSE)
View(datafile)
optim(c(datafile$N, 0.5, 0.1), dlogis)
Console gives me this error msg:
> optim(c(datafile$N, 0.5, 0.1), dlogis)
Error in optim(c(datafile$N, 0.5, 0.1), dlogis) :
objective function in optim evaluates to length 23 not 1