# How can I set a maximum and minimum level for a dependent variable?

I have to make sure that a dependent variable I explain using linear regression ranges between a minimum of 0% and a maximum of 30% (it is an investment weight in a portfolio). How should I proceed ?

A natural tool is the CDF, because by definition its range is 0 to 1. By multiplying a CDF by 30, you get your desired range. In logistic regression, the linear predictor is transformed to a probability using just that (the logistic CDF to be precise).

I'm going to give you some R-code that will let you fit a linear regression and then transform it to a [0, 30] scale using a logistic CDF multiplied by 30. The predictions are nice, but unfortunately the coefficients are a bit more difficult to interpret.

set.seed(123)
x <- rnorm(100) # explanatory variable
y <- 15 + 5*x + rnorm(100) # response taking values between 0, 30

pseudo.p <- y/30 # on the same scale as probabilities
pseudo.log.odds <- log(pseudo.p / (1 - pseudo.p)) # like logistic regression

my.lm <- lm(pseudo.log.odds ~ x)
plot(30 * plogis(my.lm\$fitted.values) ~ y) # predicted vs actual


Not sure I quite have a handle on your question. I assume the issue is that standard issue with modeling a proportion - you don't want your models to provide predictions <0 or >1. (And I'm thus ignoring the <30% requirement, but if this is important you can just rescale your output to be a proportion of a proportion)

There are a number of standard approaches to this issue. My sense is that the most established is to use a beta distribution. But the optimal approach partly/mostly depends on which is easily implemented in your software of choice. Log link models should work well as well. You can find some more complex approaches listed here: http://www.stata.com/meeting/germany10/germany10_buis.pdf

Implementation of log models for proportions here: http://www.ats.ucla.edu/stat/stata/faq/proportion.htm

Recent stackexchange thread: Generalized linear models with continuous proportions

These are both Stata references, but the concepts are applicable to your software of choice.