Learn R Programming

micsr (version 0.1-1)

clm: Constrained least squares

Description

Compute the least squares estimator using linear constrains on the coefficients.

Usage

clm(x, R, q = NULL)

# S3 method for clm vcov(object, ...)

# S3 method for clm summary(object, ...)

Value

an object of class clm which inherits from class lm

Arguments

x

a linear model fitted by lm,

R

a matrix of constrains (one line for each constrain, one column for each coefficient),

q

an optional vector of rhs values (by default a vector of 0)

object

a clm object for the summary and the vcov methods

...

further arguments

Examples

Run this code
# Cobb-Douglas production function for the apple data set
# First compute the total production
apples <- apples %>% mutate(prod = apples + otherprod)
# unconstrained linear model
cd <- lm(log(prod) ~ log(capital) + log(labor) +
         log(materials), apples)
# constrained linear model imposing constant
# return to scales
crs <- clm(cd, R = matrix(c(0, 1, 1, 1), nrow = 1),
               q = 1)

Run the code above in your browser using DataLab