Description Usage Arguments Details Value See Also Examples
Estimators and confidence intervals for the expected values and standard deviations of the response vector Y. Prediction intervals for Y. Alternatively, estimators and intervals can be for e^Y.
1 2 3 |
object |
An 'lmvar' object |
mu |
Boolean, specifies whether or not to return estimators and intervals for the expected values |
sigma |
Boolean, specifies whether or not to return estimators and intervals for the standard deviations |
log |
Boolean, specifies whether estimators and intervals should be for Y ( |
interval |
Character string, specifying the type of interval. Possible values are
|
level |
Numeric value between 0 and 1, specifying the confidence level |
... |
For compatibility with |
If log = FALSE
, fitted.lmvar
returns
estimators and intervals for the observations Y stored in object
.
If log = TRUE
, fitted.lmvar
returns estimators and intervals for e^Y.
Confidence intervals are calculated under the assumption of asymptotic normality. This assumption holds when the number of observations is
large. Intervals must be treated cautiously in case of a small number of observations.
Intervals can also be unreliable if
object
was created with a constraint on the minimum values of the standard deviations sigma.
This function is identical to the function predict.lmvar
in which the parameters X_mu
and
X_sigma
are left unspecified.
In the case mu = FALSE
and interval = "none"
: a numeric vector containing the estimators for
the standard deviation.
In the case sigma = FALSE
and interval = "none"
: a numeric vector containing the estimators for
the expected values.
In all other cases: a matrix with one column for each requested feature and one row for each observation. The column names are
mu
Estimators for the expected value μ
sigma
Estimators for the standard deviation σ
mu_lwr
Lower bound of the confidence interval for μ
mu_upr
Upper bound of the confidence interval for μ
sigma_lwr
Lower bound of the confidence interval for σ
sigma_upr
Upper bound of the confidence interval for σ
lwr
Lower bound of the prediction interval
upr
Upper bound of the prediction interval
predict.lmvar
for expected values, standard deviations and intervals for model matrices different from
the ones present in object
.
coef.lmvar
and confint
for maximum likelihood estimators and confidence intervals for
β_μ and β_σ.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # As example we use the dataset 'attenu' from the library 'datasets'. The dataset contains
# the response variable 'accel' and two explanatory variables 'mag' and 'dist'.
library(datasets)
# Create the model matrix for the expected values
X = cbind(attenu$mag, attenu$dist)
colnames(X) = c("mag", "dist")
# Create the model matrix for the standard deviations.
X_s = cbind(attenu$mag, 1 / attenu$dist)
colnames(X_s) = c("mag", "dist_inv")
# Carry out the fit
y = attenu$accel
fit = lmvar(y, X, X_s)
# Calculate the expected value of each observation
fitted(fit, sigma = FALSE)
# Calculate the standard deviation of each observation
fitted(fit, mu = FALSE)
# Calculate the expected values and their 95% confidence intervals
fitted(fit, sigma = FALSE, interval = "confidence")
# Calculate the standard deviations and their 80% confidence intervals
fitted(fit, mu = FALSE, interval = "confidence", level = 0.8)
# Calculate both the expected values and the standard deviations
fitted(fit)
# Calculate the expected values, the standard deviations and their 95% confidence intervals
fitted(fit, interval = "confidence")
# Calculate the expected values and the 90% prediction intervals
fitted(fit, interval = "prediction", level = 0.9)
# Fit the log of 'accel'
y = log(attenu$accel)
fit_log = lmvar(y, X, X_s)
# Calculate both the expected values and the standard deviations of the log of 'accel'
fitted(fit_log)
# Calculate the expected values and the standard deviations of 'accel'
fitted(fit_log, log = TRUE)
# Calculate the expected values and the standard deviations of 'accel',
# as well as their 90% confidence intervals
fitted(fit_log, log = TRUE, interval = "confidence", level = 0.9)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.