Reputation: 1780
I'm trying to fit curves with the DRC package in R.
Example:
x_yrs<-c(2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
2015, 2016, 2017)
y<-c(1.89, 0.34, 0.47, 2.46, 2.13, 7.49, 47.24, 117.84, 202.8, 322.7,
540.72, 744.22, 1148.7)
MaxPop<-110000
Y_Adj<-y/MaxPop
EV<-drm(y~ x_yrs,fct = LL.3(fixed = c(NA, NA, NA)))
plot(EV, broken = TRUE, type = "all")
EV<-drm(y~ x_yrs,fct = LL.5(fixed = c(NA, NA, NA, NA, NA)))
plot(EV, broken = TRUE, type = "all")
x_yrs_Adj<- x_yrs-2004
EV<-drm(Y_Adj~ x_yrs_Adj,fct = LL.5(fixed = c(NA, NA, NA, NA, NA)))
plot(EV, broken = TRUE, type = "all",xlim = c(0, 40), ylim = c(0, 1))
I would like to max value of the curve to be "1" or the "MaxPop" ie as the upper asymptote.
How would I go about changing the drm model to accomplish this?
Upvotes: 0
Views: 938
Reputation: 50668
"I would like to set the future population size to reach 110,000." I don't think it will be possible to fit a model with that constraint based on the data you give. The response that you have for the support of the function doesn't even get near to that (potentially?) asymptotic region. So I think you need to rethink your approach.
That aside, in drc
you can realise constraints by specifying values for specific parameters through the fixed
function argument.
EV <- drm(Y_Adj ~ x_yrs_Adj, fct = LL.5(fixed = c(NA, 0, 1, NA, NA)))
You can find out about the individual parameters if you do e.g. ?LL.5
:
LL.5(fixed = c(NA, NA, NA, NA, NA), names = c("b", "c", "d", "e", "f"), ...)
[...]
The five-parameter logistic function is given by the expression
f(x) = c + \frac{d-c}{(1+\exp(b(\log(x)-\log(e))))^f}
So in this case, we set c
to zero and then fix d = 1
.
Let's show the plot
plot(EV, broken = TRUE, type = "all", xlim = c(0, 40000), ylim = c(0, 1))
You can see the issue here. As you don't have any support of values x_yrs_Adj
closer to the function's asymptotic behaviour, your fit (and the resulting estimated parameters) will be poor.
Upvotes: 1