normal1sdff | R Documentation |
Maximum likelihood estimation of the standard deviation, including inference for conditional quantiles, of a univariate normal distribution.
normal1sdff(zero = NULL, link = "loglink",
fixed.mean = 0, p.quant = NULL,
var.arg = FALSE)
zero |
Allows to model the single linear predictor in this family function as intercept–only. See below for important details about this. |
link |
This is the link function applied to the standard deviation.
If |
fixed.mean |
Numeric, a vector or a matrix. It allocates the (fixed) mean of the response in the fitting process. See below for further details. |
p.quant |
Numeric. A prototype vector of probabilities indicating the quantiles of interest, when quantile regression is to be performed. |
var.arg |
If |
This family function is a variant of
uninormal
to estimate the standard deviation of a Normal distribution
with known mean. The estimated values are returned as
the fitted values, unlike some other family functions where the mean
is returned as fitted values. However, here the mean is
assumed to be known.
By default, the response is supposedly centered on its mean,
that is, fixed.mean
= 0
. Change this accordingly:
For a single response or multiple responses, fixed.mean
must
be a numeric vector where each entry is the mean of each response,
only if the mean is fixed. When the mean is not constant,
fixed.mean
must be matrix with the number of columns matching
the number of responses.
Quantile regression:
The (single) linear/additive predictor by default is the log
of the standard deviation. However, if quantile regression is of
primary interest, then the response must be entered using the function
Q.reg
, and the corresponding
p
–quantiles through p.quant
in the
vglm
or vgam
call.
Additionally, set normalsdQlink
as the link function via the argument link
.
This family VGAM function handles multiple responses.
An object of class "vglmff"
.
See vglmff-class
for further details.
Be aware of the argument zero
:
by default, the single linear/additive predictor in this family
function, say \eta
, can be modeled in terms of covariates,
i.e., zero = NULL
.
To model \eta
as intercept–only, set zero = "sd"
.
See zero
for more details about this.
V. Miranda.
normal1sdQlink
,
loglink
,
uninormal
,
CommonVGAMffArguments
,
zero
,
vgam
,
vglm
.
set.seed(121216)
my.mean <- -1 # Mean (CONSTANT)
my.sd <- 2.5
y <- rnorm(100, mean = my.mean, sd = 2.0) # Generate some data.
normdat <- data.frame(y = y) # Setting up our data.
# Plotting the data
plot(y, main = c("Y ~ Normal ( mean(known), sd = 2.5 ). "),
ylab = "The data", pch = 20,
xlim = c(0, 100), ylim = c(-7, 7), col = "blue")
abline(h = 0, v = 0, lwd = 2, col = "black")
### EXAMPLE 1. Estimate the SD with two responses. The mean is fixed. ###
fit1 <- vglm(cbind(y, y) ~ 1, family = normal1sdff(fixed.mean = my.mean),
data = normdat, trace = TRUE, crit = "coef")
Coef(fit1)
summary(fit1)
### EXAMPLE 2. Quantile regression. The link normal1sdQlink() is used. ###
my.p <- c(25, 50, 75) / 100 # Quantiles 25%, 50% and 75% are of interest.
fit2 <- vglm(Q.reg(y, length.arg = 3) ~ 1,
family = normal1sdff(fixed.mean = my.mean, p.quant = my.p,
link = normal1sdQlink),
data = normdat, trace = TRUE, crit = "coef")
summary(fit2)
head(predict(fit2))
constraints(fit2)
### EXAMPLE 3. Complete the plot. Quantiles matching. ###
( my.c3Q <- coef(fit2, matrix = TRUE) )
with(normdat, lines(rep(my.c3Q[1], 100), col = "tan" , lty = "dotted", lwd = 2))
with(normdat, lines(rep(my.c3Q[2], 100), col = "orange", lty = "dotted", lwd = 2))
with(normdat, lines(rep(my.c3Q[3], 100), col = "brown1", lty = "dotted", lwd = 2))
legend(20, 7.0, c("Percentil 75", "Percentil 50", "Percentil 25"),
col = c("brown1", "orange", "tan"),
lty = rep("dotted", 3), lwd = rep(2, 3), cex = 0.75)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.