clpm
is used to fit the linear probability model while ensuring that the predicted probabilities are in the (0,1) interval. The function can also be applied to any variable for which predictions between 0 and 1 are required.
clpm(formula , data, subset, na.action, weights, contrasts = NULL,
lambda = NULL, control = clpm.control(), ...)
clpm
returns an object of class "clpm
".
The functions summary
and predict
are used to obtain and print a summary and estimate model predictions.
An object of class “clpm
”, a list containing the following items:
a named vector of coefficients.
the estimated variance-covariance matrix.
the residuals, that is the response minus the fitted values.
the numeric rank of the fitted linear model.
the fitted values, that represent conditional means or, for a binary response, conditional probabilities.
(only for weighted fits) the specified weights.
the residual degrees of freedom.
the value of the minimized loss function.
the value of the gradient.
logical. The convergence status.
the number of iterations.
the values from clpm.control.
the lambda value applied for model estimation.
(only where relevant) the contrasts used.
(only where relevant) a record of the levels of the factors used in fitting.
the matched call.
the terms object used.
if requested (the default), the model frame used.
a two-sided formula of the form y ~ x1 + x2 + ...
: a symbolic description of the linear probability model.
The y
argument must be a variable (binary or continous) for which we want predictions to be inside the (0,1) interval. The model specification is exactly as in lm.
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data
, the variables are taken from environment(formula)
, typically the environment from which clpm
is called.
an optional vector specifying a subset of observations to be used in the fitting process.
a function which indicates what should happen when the data contain NAs. See lm for details.
an optional vector of weights to be used in the fitting process. Should be NULL
or a numeric vector. See lm.
an optional list. See the contrasts.arg
of model.matrix.default.
a tuning constant that defines how important it is to obtain predictions in the (0,1) interval. If lambda
is too small, the constraints may not be respected. On the other hand, if lambda
is too large, the objective function might lose its convexity. If no value is supplied,
an optimal value will be selected iteratively.
see clpm.control.
for future arguments.
Andrea Beci andreabeci08@gmail.com, Paolo Frumento paolo.frumento@unipi.it
For more details, see lm.
x <- runif(100)
y <- rbinom(100, 1, x)
fit <- clpm(y~x)
summary(fit)
predict(fit)
Run the code above in your browser using DataLab