[R-sig-ME] GLMM with bounded parameters
Thierry Onkelinx
thierry.onkelinx at inbo.be
Fri Dec 16 17:11:02 CET 2016
Dear Pierre,
You could fit the model with a Bayesian technique and use an informative
prior.
Here is an example using INLA (download it from r-inla.org)
Note that I've forced x to be negative and x2 to be positive to illustrate
their effect.
x <- runif(300,0,10)
fitness <- rpois(300,10*dnorm(x,mean=5,sd=2))
library(INLA)
library(ggplot2)
dataset <- data.frame(
fitness,
x,
x2 = x ^ 2
)
model <- inla(
fitness ~ x + x2,
data = dataset,
family = "poisson",
control.fixed = list(
mean = list(x = -10, x2 = .2),
prec = list(x = 1, x2 = 1e4)
),
control.predictor = list(compute = TRUE)
)
summary(model)
dataset$fit <- model$summary.fitted.values$mean
ggplot(dataset, aes(x = x, y = fitness)) +
geom_point() +
geom_line(aes(y = fit))
Best regards,
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
2016-12-16 13:43 GMT+01:00 Pierre de Villemereuil <
pierre.de.villemereuil op mailoo.org>:
> Dear all,
>
> I'm trying to fit a predictive bell curve on count data with Poisson noise
> around the curve. The idea is to estimate the optimum of fitness according
> to
> some trait.
>
> The good news is that I don't need to resort to non-linear modelling to do
> that, because the exponential link combined with a polynomial formula can
> do
> the job as shown in the dummy example below:
> x <- runif(300,0,10)
> fitness <- rpois(300,10*dnorm(x,mean=5,sd=2))
>
> mod = glm(fitness ~ x + I(x^2),family="poisson")
> plot(fitness ~ x)
> points(predict(mod,type="response") ~ x,col="red")
>
> My problem is that I'd like to impose some constraints on the parameters to
> ensure that a bell-shape is fitted, e.g. that the parameter for x is
> positive
> and the parameter for I(x^2) is negative.
>
> Is there a way to enforce such constraints in mixed models packages
> available
> in R? I'm currently using lme4, but I'm happy to switch to any other
> package.
>
> Cheers,
> Pierre.
>
> _______________________________________________
> R-sig-mixed-models op r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list