linearmodel {lestat} | R Documentation |
Compute the Posterior Distribution for a Linear Model
Description
Given a vector of data and a design matrix, describing how these data are thought to relate to some predictors in a linear model, the posterior for the parameters of this linear model is found, using a flat prior.
Usage
linearmodel(data, design)
Arguments
data |
A vector with data values. |
design |
A design matrix. The number of rows must be equal to the length of the data vector. The number of columns corresponds to the number of explanatory variables. |
Details
If is the i'th data value and
is the
j'th unknown parameter, and if
is the value in the i'th row
and j'th column of the design matrix, then one assumes that
is normally distributed with exptectation
and logged standard deviation . The computed probability
distribution is then the posterior for the joint distribution of
.
Value
If is the number of columns in the design matrix and if
,
then the output is a multivariate Normal-ExpGamma distribution representing
the posterior for the corresponding
values and the logged scale
parameter in the linear model. If
, the output is a Normal-ExpGamma
distribution representing the posterior.
Author(s)
Petter Mostad <mostad@chalmers.se>
See Also
fittedvalues
, leastsquares
,
linearpredict
Examples
data1 <- simulate(normal(3.3, log(2)), 9)
data2 <- simulate(normal(4.5, log(2)), 8)
data3 <- simulate(normal(2.9, log(2)), 7)
design <- designManyGroups(c(9,8,7))
posterior <- linearmodel(c(data1, data2, data3), design)
plot(posterior)