library(grid)
library(gridExtra)
library(broom)
library(BiodiversityR)
library("vegan")#[1]
library("MASS")#[2]
library(nlme)#[3]
library("bbmle")
Here are the data
I'm assessing which model best suit my data (null model/glm-poisson/4 parameter log). The idea of using log is to detect at which point the response (number, proportion of species) decreases/increases at certain values of forest cover in the landscape. I've been using the next code to fit a four parameter logistic regression using dpois (y=count of species):
logip=function(p,lambda,x){
a=p[1]
b=p[2]
c=p[3]
d=p[4]
Riq1 = d+(a/(1+exp((b-(FOREST700+km))/c)))
-sum(dpois(x,lambda=Riq1, log=TRUE))
}
parnames(logip)=c("a","b","c","d")
modTR.log=mle2(minuslog=logip, start= c(a=2,b=60,c=3,d=0.1),
data=list(x=Patch_Richness))
But now I want to use the same approach for dependent variable that is a proportion (y=proportion of species registered in one site). I think I should be using binomial, so I'm trying dbinom
in my previous function:
logip=function(p,size,prob){
a=p[1]
b=p[2]
c=p[3]
d=p[4]
Riq1 = d+(a/(1+exp((b-(FOREST500+km))/c)))
-sum(dbinom(size,prob=Riq1))
}parnames(logip)=c("a","b","c","d")
modTR.log=mle2(minuslog=logip, start= c(a=1,b=72,c=3,d=0.1),
data=list(x=cbind(Regional_Richness,Patch_Richness)))
I'm getting this message:
Error in mle2(minuslog = logip, start = c(a = 1, b = 72, c = 3, d = 0.1), : some named arguments in 'start' are not arguments to the specified log-likelihood function.
I don´t know if it is correct to use dbinom
and how to apply this in the function I'm using. Hope you can help me.
dnorm
instead ofdbinom
– user20650