par.est: Estimation in linear regression models

View source: R/par.est.R

par.estR Documentation

Estimation in linear regression models

Description

This routine computes the ordinary least squares estimate for \beta from a sample (Y_i, X_{i1},...,X_{ip}), i=1,...,n, where:

\beta = (\beta_1,...,\beta_p)

is an unknown vector parameter and

Y_i = X_{i1}*\beta_1+ ... + X_{ip}*\beta_p + \epsilon_i.

The random errors, \epsilon_i, are allowed to be time series.

Usage

par.est(data = data)

Arguments

data

data[, 1] contains the values of the response variable, Y;

data[, 2:(p+1)] contains the values of the explanatory variables, X_1, ..., X_p.

Details

See Seber (1977) and Judge et al. (1980).

Value

A vector containing the corresponding estimate.

Author(s)

German Aneiros Perez ganeiros@udc.es

Ana Lopez Cheda ana.lopez.cheda@udc.es

References

Judge, G.G., Griffiths, W.E., Carter Hill, R., Lutkepohl, H. and Lee, T-C. (1980) The Theory and Practice of Econometrics. Wiley.

Seber, G.A.F. (1977) Linear Regression Analysis. Wiley.

See Also

Other related functions are plrm.beta and plrm.est.

Examples

# EXAMPLE 1: REAL DATA
data(barnacles1)
data <- as.matrix(barnacles1)
data <- diff(data, 12)
data <- cbind(data[,1],1,data[,-1])

beta <- par.est(data=data)
beta
residuos <- data[,1] - data[,-1]%*%beta
mean(residuos^2)/var(data[,1])

fitted.values <- data[,-1]%*%beta
plot(data[,1], fitted.values, xlab="y", ylab="y.hat", main="y.hat vs y")
abline(0,1)



# EXAMPLE 2: SIMULATED DATA
## Example 2a: independent data

set.seed(1234)
# We generate the data
n <- 100
beta <- c(0.05, 0.01)

x <- matrix(rnorm(200,0,1), nrow=n)
sum <- x%*%beta
epsilon <- rnorm(n, 0, 0.01)
y <-  sum + epsilon
data_ind <- matrix(c(y,x),nrow=100)

# We estimate the parametric component of the PLR model
par.est(data_ind)


## Example 2b: dependent data

set.seed(1234)
# We generate the data
x <- matrix(rnorm(200,0,1), nrow=n)
sum <- x%*%beta
epsilon <- arima.sim(list(order = c(1,0,0), ar=0.7), sd = 0.01, n = n)
y <-  sum + epsilon
data_dep <- matrix(c(y,x),nrow=100)

# We estimate the parametric component of the PLR model
par.est(data_dep)


PLRModels documentation built on Aug. 19, 2023, 5:10 p.m.

Related to par.est in PLRModels...