fitted.lmvar: Fitted values for an 'lmvar' object

Description Usage Arguments Details Value See Also Examples

Description

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.

Usage

1
2
3
## S3 method for class 'lmvar'
fitted(object, mu = TRUE, sigma = TRUE, log = FALSE,
  interval = c("none", "confidence", "prediction"), level = 0.95, ...)

Arguments

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 (log = FALSE) or for e^Y (log = TRUE).

interval

Character string, specifying the type of interval. Possible values are

  • "none" No interval, this is the default

  • "confidence" Confidence intervals for the estimators

  • "prediction" Prediction intervals

level

Numeric value between 0 and 1, specifying the confidence level

...

For compatibility with fitted generic.

Details

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.

Value

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

See Also

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 β_σ.

Examples

 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)

lmvar documentation built on May 16, 2019, 5:06 p.m.