diff --git a/NEWS.md b/NEWS.md index db02f1a..22e6970 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# vinereg 0.10.0 + +NEW FEATURE + + * New function `pdf()` to compute the conditional log-likelihood. + + # vinereg 0.9.2 BUG FIX diff --git a/docs/404.html b/docs/404.html index 174e89a..0c7e488 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 66722ae..12bec01 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -17,7 +17,7 @@ diff --git a/docs/articles/abalone-example.html b/docs/articles/abalone-example.html index 06c864b..6fd7db6 100644 --- a/docs/articles/abalone-example.html +++ b/docs/articles/abalone-example.html @@ -33,7 +33,7 @@ @@ -100,51 +100,51 @@We consider the data set abalone
from the UCI Machine
Learning Repository (https://archive.ics.uci.edu/ml/datasets/abalone) and
focus on the female sub-population. In a first application we only
consider continuous variables and fit models to predict the quantiles of
weight (whole
) given the predictors length
,
diameter
, and height
.
-data(abalone, package = "AppliedPredictiveModeling")
-colnames(abalone) <- c(
- "sex", "length", "diameter", "height", "whole",
- "shucked", "viscera", "shell", "rings"
-)
-abalone_f <- abalone %>%
- dplyr::filter(sex == "F") %>% # select female abalones
- dplyr::select(-sex) %>% # remove id and sex variables
- dplyr::filter(height < max(height)) # remove height outlier
data(abalone, package = "AppliedPredictiveModeling")
+colnames(abalone) <- c(
+ "sex", "length", "diameter", "height", "whole",
+ "shucked", "viscera", "shell", "rings"
+)
+abalone_f <- abalone %>%
+ dplyr::filter(sex == "F") %>% # select female abalones
+ dplyr::select(-sex) %>% # remove id and sex variables
+ dplyr::filter(height < max(height)) # remove height outlier
-pairs(abalone_f, pch = ".")
pairs(abalone_f, pch = ".")
We consider the female subset and fit a parametric regression D-vine for the response weight given the covariates len, diameter and height (ignoring the discreteness of some of the variables). The D-vine based @@ -161,135 +161,135 @@
-fit_vine_par <- vinereg(
- whole ~ length + diameter + height,
- data = abalone_f,
- family_set = c("onepar", "t"),
- selcrit = "aic"
-)
fit_vine_par <- vinereg(
+ whole ~ length + diameter + height,
+ data = abalone_f,
+ family_set = c("onepar", "t"),
+ selcrit = "aic"
+)
The result has a field order
that shows the selected
covariates and their ranking order in the D-vine.
-fit_vine_par$order
## [1] "length" "height" "diameter"
+fit_vine_par$order
## [1] "length" "height" "diameter"
The field vine
contains the fitted D-vine, where the
first variable corresponds to the response. The object is of class
"vinecop_dist"
so we can use rvineocpulib
’s
functionality to summarize the model
-summary(fit_vine_par$vine)
## # A data.frame: 6 x 11
-## tree edge conditioned conditioning var_types family rotation parameters df
-## 1 1 1, 2 c,c gumbel 180 5.2 1
-## 1 2 2, 4 c,c gumbel 180 2.4 1
-## 1 3 4, 3 c,c gumbel 180 2.4 1
-## 2 1 1, 4 2 c,c t 0 0.45, 20.20 2
-## 2 2 2, 3 4 c,c t 0 0.91, 4.68 2
-## 3 1 1, 3 4, 2 c,c t 0 0.31, 7.39 2
-## tau loglik
-## 0.81 1629
-## 0.58 672
-## 0.59 709
-## 0.30 147
-## 0.73 1193
-## 0.20 72
+summary(fit_vine_par$vine)
## # A data.frame: 6 x 11
+## tree edge conditioned conditioning var_types family rotation parameters df
+## 1 1 1, 2 c,c gumbel 180 5.2 1
+## 1 2 2, 4 c,c gumbel 180 2.4 1
+## 1 3 4, 3 c,c gumbel 180 2.4 1
+## 2 1 1, 4 2 c,c t 0 0.45, 20.20 2
+## 2 2 2, 3 4 c,c t 0 0.91, 4.68 2
+## 3 1 1, 3 4, 2 c,c t 0 0.31, 7.39 2
+## tau loglik
+## 0.81 1629
+## 0.58 672
+## 0.59 709
+## 0.30 147
+## 0.73 1193
+## 0.20 72
We can also plot the contours of the fitted pair-copulas.
-contour(fit_vine_par$vine)
contour(fit_vine_par$vine)
-In order to visualize the predicted influence of the covariates, we plot the estimated quantiles arising from the D-vine model at levels 0.1, 0.5 and 0.9 against each of the covariates.
-# quantile levels
-alpha_vec <- c(0.1, 0.5, 0.9)
# quantile levels
+alpha_vec <- c(0.1, 0.5, 0.9)
We call the fitted()
function on
fit_vine_par
to extract the fitted values for multiple
quantile levels. This is equivalent to predicting the quantile at the
training data. The latter function is more useful for out-of-sample
predictions.
-pred_vine_par <- fitted(fit_vine_par, alpha = alpha_vec)
-# equivalent to:
-# predict(fit_vine_par, newdata = abalone.f, alpha = alpha_vec)
-head(pred_vine_par)
## 0.1 0.5 0.9
-## 1 0.6719522 0.7666997 0.8715491
-## 2 0.6969903 0.7903960 0.9012124
-## 3 0.6794323 0.7842671 0.8916937
-## 4 0.7755592 0.8800229 0.9974089
-## 5 0.5952851 0.6997763 0.8272583
-## 6 0.6757838 0.7729635 0.8858529
+pred_vine_par <- fitted(fit_vine_par, alpha = alpha_vec)
+# equivalent to:
+# predict(fit_vine_par, newdata = abalone.f, alpha = alpha_vec)
+head(pred_vine_par)
## 0.1 0.5 0.9
+## 1 0.6719522 0.7666997 0.8715491
+## 2 0.6969903 0.7903960 0.9012124
+## 3 0.6794323 0.7842671 0.8916937
+## 4 0.7755592 0.8800229 0.9974089
+## 5 0.5952851 0.6997763 0.8272583
+## 6 0.6757838 0.7729635 0.8858529
To examine the effect of the individual variables, we will plot the predicted quantiles against each of the variables. To visualize the relationship more clearly, we add a smoothed line for each quantile level. This gives an estimate of the expected effect of a variable (taking expectation with respect to all other variables).
-plot_effects(fit_vine_par)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
+plot_effects(fit_vine_par)
+## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
The fitted quantile curves suggest a non-linear effect of all three variables.
-This can be compared to linear quantile regression:
-pred_lqr <- pred_vine_par
-for (a in seq_along(alpha_vec)) {
- my.rq <- quantreg::rq(
- whole ~ length + diameter + height,
- tau = alpha_vec[a],
- data = abalone_f
- )
- pred_lqr[, a] <- quantreg::predict.rq(my.rq)
-}
-
-plot_marginal_effects <- function(covs, preds) {
- cbind(covs, preds) %>%
- tidyr::gather(alpha, prediction, -seq_len(NCOL(covs))) %>%
- dplyr::mutate(prediction = as.numeric(prediction)) %>%
- tidyr::gather(variable, value, -(alpha:prediction)) %>%
- ggplot(aes(value, prediction, color = alpha)) +
- geom_point(alpha = 0.15) +
- geom_smooth(method = "gam", formula = y ~ s(x, bs = "cs"), se = FALSE) +
- facet_wrap(~ variable, scale = "free_x") +
- ylab(quote(q(y* "|" * x[1] * ",...," * x[p]))) +
- xlab(quote(x[k])) +
- theme(legend.position = "bottom")
-}
-plot_marginal_effects(abalone_f[, 1:3], pred_lqr)
pred_lqr <- pred_vine_par
+for (a in seq_along(alpha_vec)) {
+ my.rq <- quantreg::rq(
+ whole ~ length + diameter + height,
+ tau = alpha_vec[a],
+ data = abalone_f
+ )
+ pred_lqr[, a] <- quantreg::predict.rq(my.rq)
+}
+
+plot_marginal_effects <- function(covs, preds) {
+ cbind(covs, preds) %>%
+ tidyr::gather(alpha, prediction, -seq_len(NCOL(covs))) %>%
+ dplyr::mutate(prediction = as.numeric(prediction)) %>%
+ tidyr::gather(variable, value, -(alpha:prediction)) %>%
+ ggplot(aes(value, prediction, color = alpha)) +
+ geom_point(alpha = 0.15) +
+ geom_smooth(method = "gam", formula = y ~ s(x, bs = "cs"), se = FALSE) +
+ facet_wrap(~ variable, scale = "free_x") +
+ ylab(quote(q(y* "|" * x[1] * ",...," * x[p]))) +
+ xlab(quote(x[k])) +
+ theme(legend.position = "bottom")
+}
+plot_marginal_effects(abalone_f[, 1:3], pred_lqr)
We also want to check whether these results change, when we estimate the pair-copulas nonparametrically.
-fit_vine_np <- vinereg(
- whole ~ length + diameter + height,
- data = abalone_f,
- family_set = "nonpar",
- selcrit = "aic"
-)
-fit_vine_np
## D-vine regression model: whole | length, height, diameter
-## nobs = 1306, edf = 95.59, cll = 1208.61, caic = -2226.04, cbic = -1731.39
+fit_vine_np <- vinereg(
+ whole ~ length + diameter + height,
+ data = abalone_f,
+ family_set = "nonpar",
+ selcrit = "aic"
+)
+fit_vine_np
## D-vine regression model: whole | length, height, diameter
+## nobs = 1306, edf = 94.85, cll = 1206.93, caic = -2224.16, cbic = -1733.35
-contour(fit_vine_np$vine)
contour(fit_vine_np$vine)
Now only the length and height variables are selected as predictors. Let’s have a look at the marginal effects.
-plot_effects(fit_vine_np, var = c("diameter", "height", "length"))
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
+plot_effects(fit_vine_np, var = c("diameter", "height", "length"))
+## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
The effects look similar to the parametric one, but slightly more wiggly. Note that even the diameter was not selected as a covariate, @@ -297,29 +297,29 @@
To deal with discrete variables, we use the methodology of Schallhorn et al. (2017). For estimating nonparametric pair-copulas with discrete variable(s), jittering is used (Nagler, 2017).
We let vinereg()
know that a variable is discrete by
declaring it ordered
.
-abalone_f$rings <- as.ordered(abalone_f$rings)
-fit_disc <- vinereg(rings ~ ., data = abalone_f, selcrit = "aic")
-fit_disc
## D-vine regression model: rings | shell, shucked, whole, height, viscera, length, diameter
-## nobs = 1306, edf = 9, cll = -2782.06, caic = 5582.12, cbic = 5628.69
+abalone_f$rings <- as.ordered(abalone_f$rings)
+fit_disc <- vinereg(rings ~ ., data = abalone_f, selcrit = "aic")
+fit_disc
## D-vine regression model: rings | shell, shucked, whole, height, viscera, length, diameter
+## nobs = 1306, edf = 9, cll = -2781.56, caic = 5581.12, cbic = 5627.7
-plot_effects(fit_disc)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
+plot_effects(fit_disc)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Kraus and Czado (2017), D-vine copula based quantile regression, Computational Statistics and Data Analysis, 110, 1-18
@@ -348,8 +348,7 @@Site built with pkgdown -2.0.1.
+Site built with pkgdown 2.0.7.
-library(vinereg)
-require(ggplot2)
-require(dplyr)
-require(purrr)
-require(scales)
-require(quantreg)
library(vinereg)
+require(ggplot2)
+require(dplyr)
+require(purrr)
+require(scales)
+require(quantreg)
-plot_marginal_effects <- function(covs, preds) {
- cbind(covs, preds) %>%
- tidyr::gather(alpha, prediction, -seq_len(NCOL(covs))) %>%
- dplyr::mutate(prediction = as.numeric(prediction)) %>%
- tidyr::gather(variable, value, -(alpha:prediction)) %>%
- dplyr::mutate(value = as.numeric(value)) %>%
- ggplot(aes(value, prediction, color = alpha)) +
- geom_point(alpha = 0.15) +
- geom_smooth(span = 0.5, se = FALSE) +
- facet_wrap(~ variable, scale = "free_x") +
- theme(legend.position = "none") +
- theme(plot.margin = unit(c(0, 0, 0, 0), "mm")) +
- xlab("")
-}
plot_marginal_effects <- function(covs, preds) {
+ cbind(covs, preds) %>%
+ tidyr::gather(alpha, prediction, -seq_len(NCOL(covs))) %>%
+ dplyr::mutate(prediction = as.numeric(prediction)) %>%
+ tidyr::gather(variable, value, -(alpha:prediction)) %>%
+ dplyr::mutate(value = as.numeric(value)) %>%
+ ggplot(aes(value, prediction, color = alpha)) +
+ geom_point(alpha = 0.15) +
+ geom_smooth(span = 0.5, se = FALSE) +
+ facet_wrap(~ variable, scale = "free_x") +
+ theme(legend.position = "none") +
+ theme(plot.margin = unit(c(0, 0, 0, 0), "mm")) +
+ xlab("")
+}
## instant dteday season yr mnth holiday weekday workingday weathersit
-## 1 1 2011-01-01 1 0 1 0 6 0 2
-## 2 2 2011-01-02 1 0 1 0 0 0 2
-## 3 3 2011-01-03 1 0 1 0 1 1 1
-## 4 4 2011-01-04 1 0 1 0 2 1 1
-## 5 5 2011-01-05 1 0 1 0 3 1 1
-## 6 6 2011-01-06 1 0 1 0 4 1 1
-## temp atemp hum windspeed casual registered cnt
-## 1 0.344167 0.363625 0.805833 0.1604460 331 654 985
-## 2 0.363478 0.353739 0.696087 0.2485390 131 670 801
-## 3 0.196364 0.189405 0.437273 0.2483090 120 1229 1349
-## 4 0.200000 0.212122 0.590435 0.1602960 108 1454 1562
-## 5 0.226957 0.229270 0.436957 0.1869000 82 1518 1600
-## 6 0.204348 0.233209 0.518261 0.0895652 88 1518 1606
+bikedata <- read.csv("day.csv")
+bikedata[, 2] <- as.Date(bikedata[, 2])
+head(bikedata)
## instant dteday season yr mnth holiday weekday workingday weathersit
+## 1 1 2011-01-01 1 0 1 0 6 0 2
+## 2 2 2011-01-02 1 0 1 0 0 0 2
+## 3 3 2011-01-03 1 0 1 0 1 1 1
+## 4 4 2011-01-04 1 0 1 0 2 1 1
+## 5 5 2011-01-05 1 0 1 0 3 1 1
+## 6 6 2011-01-06 1 0 1 0 4 1 1
+## temp atemp hum windspeed casual registered cnt
+## 1 0.344167 0.363625 0.805833 0.1604460 331 654 985
+## 2 0.363478 0.353739 0.696087 0.2485390 131 670 801
+## 3 0.196364 0.189405 0.437273 0.2483090 120 1229 1349
+## 4 0.200000 0.212122 0.590435 0.1602960 108 1454 1562
+## 5 0.226957 0.229270 0.436957 0.1869000 82 1518 1600
+## 6 0.204348 0.233209 0.518261 0.0895652 88 1518 1606
-bikedata <- bikedata %>%
- rename(
- temperature = atemp,
- month = mnth,
- weathersituation = weathersit,
- humidity = hum,
- count = cnt
- )
bikedata <- bikedata %>%
+ rename(
+ temperature = atemp,
+ month = mnth,
+ weathersituation = weathersit,
+ humidity = hum,
+ count = cnt
+ )
See variable description on UCI web page.
-bikedata <- bikedata %>%
- mutate(
- temperature = 66 * temperature + 16,
- windspeed = 67 * windspeed,
- humidity = 100 * humidity
- )
bikedata <- bikedata %>%
+ mutate(
+ temperature = 66 * temperature + 16,
+ windspeed = 67 * windspeed,
+ humidity = 100 * humidity
+ )
-ggplot(bikedata, aes(dteday, count)) +
- geom_line() +
- scale_x_date(labels = scales::date_format("%b %y")) +
- xlab("date") +
- ylab("rental count") +
- stat_smooth(method = "lm", se = FALSE, linetype = "dashed") +
- theme(plot.title = element_text(lineheight = 0.8, size = 20)) +
- theme(text = element_text(size = 18))
ggplot(bikedata, aes(dteday, count)) +
+ geom_line() +
+ scale_x_date(labels = scales::date_format("%b %y")) +
+ xlab("date") +
+ ylab("rental count") +
+ stat_smooth(method = "lm", se = FALSE, linetype = "dashed") +
+ theme(plot.title = element_text(lineheight = 0.8, size = 20)) +
+ theme(text = element_text(size = 18))
-lm_trend <- lm(count ~ instant, data = bikedata)
-trend <- predict(lm_trend)
-bikedata <- mutate(bikedata, count = count / trend)
-ggplot(bikedata, aes(dteday, count)) +
- geom_line() +
- scale_x_date(labels = scales::date_format("%b %y")) +
- xlab("date") +
- ylab("detrended rental count") +
- theme(plot.title = element_text(lineheight = 0.8, size = 20)) +
- theme(text = element_text(size = 18))
lm_trend <- lm(count ~ instant, data = bikedata)
+trend <- predict(lm_trend)
+bikedata <- mutate(bikedata, count = count / trend)
+ggplot(bikedata, aes(dteday, count)) +
+ geom_line() +
+ scale_x_date(labels = scales::date_format("%b %y")) +
+ xlab("date") +
+ ylab("detrended rental count") +
+ theme(plot.title = element_text(lineheight = 0.8, size = 20)) +
+ theme(text = element_text(size = 18))
-bikedata <- bikedata %>%
- select(-instant, -dteday, -yr) %>% # time indices
- select(-casual, -registered) %>% # casual + registered = count
- select(-holiday) %>% # we use 'workingday' instead
- select(-temp) # we use 'temperature' (feeling temperature)
bikedata <- bikedata %>%
+ select(-instant, -dteday, -yr) %>% # time indices
+ select(-casual, -registered) %>% # casual + registered = count
+ select(-holiday) %>% # we use 'workingday' instead
+ select(-temp) # we use 'temperature' (feeling temperature)
ordered
-disc_vars <- c("season", "month", "weekday", "workingday", "weathersituation")
-bikedata <- bikedata %>%
- mutate(weekday = ifelse(weekday == 0, 7, weekday)) %>% # sun at end of week
- purrr::modify_at(disc_vars, as.ordered)
disc_vars <- c("season", "month", "weekday", "workingday", "weathersituation")
+bikedata <- bikedata %>%
+ mutate(weekday = ifelse(weekday == 0, 7, weekday)) %>% # sun at end of week
+ purrr::modify_at(disc_vars, as.ordered)
-fit <- vinereg(
- count ~ .,
- data = bikedata,
- family = c("onepar", "tll"),
- selcrit = "aic"
-)
-fit
## D-vine regression model: count | temperature, humidity, windspeed, month, season, weathersituation, workingday, weekday
-## nobs = 731, edf = 55.49, cll = 410.19, caic = -709.39, cbic = -454.45
+fit <- vinereg(
+ count ~ .,
+ data = bikedata,
+ family = c("onepar", "tll"),
+ selcrit = "aic"
+)
+fit
## D-vine regression model: count | temperature, humidity, windspeed, month, season, weathersituation, weekday, workingday
+## nobs = 731, edf = 72.13, cll = 435.3, caic = -726.34, cbic = -394.96
-summary(fit)
## var edf cll caic cbic p_value
-## 1 count 9.59683 -198.076002 415.345665 459.437472 NA
-## 2 temperature 21.96569 415.796680 -787.661982 -686.742527 1.081331e-161
-## 3 humidity 17.92777 118.896648 -201.937762 -119.570188 2.228987e-40
-## 4 windspeed 1.00000 22.818931 -43.637862 -39.043448 1.422649e-11
-## 5 month 1.00000 13.494037 -24.988073 -20.393660 2.047147e-07
-## 6 season 1.00000 11.793281 -21.586562 -16.992149 1.194186e-06
-## 7 weathersituation 1.00000 11.308234 -20.616468 -16.022054 1.977821e-06
-## 8 workingday 1.00000 10.001404 -18.002808 -13.408395 7.732851e-06
-## 9 weekday 1.00000 4.152908 -6.305817 -1.711403 3.951831e-03
+summary(fit)
+## var edf cll caic cbic p_value
+## 1 count 9.59683 -198.076002 415.34567 459.43747 NA
+## 2 temperature 21.98142 415.787940 -787.61304 -686.62130 1.122645e-161
+## 3 humidity 17.93921 118.956008 -202.03360 -119.61346 2.141039e-40
+## 4 windspeed 1.00000 22.861975 -43.72395 -39.12954 1.361480e-11
+## 5 month 1.00000 13.322233 -24.64447 -20.05005 2.445501e-07
+## 6 season 1.00000 12.044517 -22.08903 -17.49462 9.198266e-07
+## 7 weathersituation 1.00000 13.248269 -24.49654 -19.90212 2.640109e-07
+## 8 weekday 17.60987 30.157881 -25.09603 55.81098 1.406307e-06
+## 9 workingday 1.00000 6.996617 -11.99323 -7.39882 1.834697e-04
-plot_marginal_effects(
- covs = select(bikedata, temperature),
- preds = pred
-)
plot_marginal_effects(
+ covs = select(bikedata, temperature),
+ preds = pred
+)
plot_marginal_effects(covs = select(bikedata, humidity), preds = pred) +
+ xlim(c(25, 100))
-plot_marginal_effects(covs = select(bikedata, windspeed), preds = pred)
plot_marginal_effects(covs = select(bikedata, windspeed), preds = pred)
-month_labs <- c("Jan","", "Mar", "", "May", "", "Jul", "", "Sep", "", "Nov", "")
-plot_marginal_effects(covs = select(bikedata, month), preds = pred) +
- scale_x_discrete(limits = 1:12, labels = month_labs)
month_labs <- c("Jan","", "Mar", "", "May", "", "Jul", "", "Sep", "", "Nov", "")
+plot_marginal_effects(covs = select(bikedata, month), preds = pred) +
+ scale_x_discrete(limits = 1:12, labels = month_labs)
-plot_marginal_effects(covs = select(bikedata, weathersituation),
- preds = pred) +
- scale_x_discrete(limits = 1:3,labels = c("good", "medium", "bad"))
plot_marginal_effects(covs = select(bikedata, weathersituation),
+ preds = pred) +
+ scale_x_discrete(limits = 1:3,labels = c("good", "medium", "bad"))
-weekday_labs <- c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
-plot_marginal_effects(covs = select(bikedata, weekday), preds = pred) +
- scale_x_discrete(limits = 1:7, labels = weekday_labs)
weekday_labs <- c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
+plot_marginal_effects(covs = select(bikedata, weekday), preds = pred) +
+ scale_x_discrete(limits = 1:7, labels = weekday_labs)
-plot_marginal_effects(covs = select(bikedata, workingday), preds = pred) +
- scale_x_discrete(limits = 0:1, labels = c("no", "yes")) +
- geom_smooth(method = "lm", se = FALSE) +
- xlim(c(0, 1))
plot_marginal_effects(covs = select(bikedata, workingday), preds = pred) +
+ scale_x_discrete(limits = 0:1, labels = c("no", "yes")) +
+ geom_smooth(method = "lm", se = FALSE) +
+ xlim(c(0, 1))
-season_labs <- c("spring", "summer", "fall", "winter")
-plot_marginal_effects(covs = select(bikedata, season), preds = pred) +
- scale_x_discrete(limits = 1:4, labels = season_labs)
season_labs <- c("spring", "summer", "fall", "winter")
+plot_marginal_effects(covs = select(bikedata, season), preds = pred) +
+ scale_x_discrete(limits = 1:4, labels = season_labs)
@@ -324,8 +324,7 @@ Site built with pkgdown -2.0.1.
+Site built with pkgdown 2.0.7.
diff --git a/docs/articles/bike-rental_files/figure-html/count_with_trend-1.png b/docs/articles/bike-rental_files/figure-html/count_with_trend-1.png index 24587e4..ab180a1 100644 Binary files a/docs/articles/bike-rental_files/figure-html/count_with_trend-1.png and b/docs/articles/bike-rental_files/figure-html/count_with_trend-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_humidity-1.png b/docs/articles/bike-rental_files/figure-html/me_humidity-1.png index 35152b1..a352936 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_humidity-1.png and b/docs/articles/bike-rental_files/figure-html/me_humidity-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_month-1.png b/docs/articles/bike-rental_files/figure-html/me_month-1.png index f2f77d5..14bf50a 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_month-1.png and b/docs/articles/bike-rental_files/figure-html/me_month-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_season-1.png b/docs/articles/bike-rental_files/figure-html/me_season-1.png index 5f930a1..88538fc 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_season-1.png and b/docs/articles/bike-rental_files/figure-html/me_season-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_temperature-1.png b/docs/articles/bike-rental_files/figure-html/me_temperature-1.png index 09420f2..0e99397 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_temperature-1.png and b/docs/articles/bike-rental_files/figure-html/me_temperature-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_weathersituation-1.png b/docs/articles/bike-rental_files/figure-html/me_weathersituation-1.png index d0a3f3a..00699f6 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_weathersituation-1.png and b/docs/articles/bike-rental_files/figure-html/me_weathersituation-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_weekday-1.png b/docs/articles/bike-rental_files/figure-html/me_weekday-1.png index 6809edc..f5aa265 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_weekday-1.png and b/docs/articles/bike-rental_files/figure-html/me_weekday-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_windspeed-1.png b/docs/articles/bike-rental_files/figure-html/me_windspeed-1.png index 01c8637..0d24c7f 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_windspeed-1.png and b/docs/articles/bike-rental_files/figure-html/me_windspeed-1.png differ diff --git a/docs/articles/bike-rental_files/figure-html/me_workingday-1.png b/docs/articles/bike-rental_files/figure-html/me_workingday-1.png index a179d6e..87df947 100644 Binary files a/docs/articles/bike-rental_files/figure-html/me_workingday-1.png and b/docs/articles/bike-rental_files/figure-html/me_workingday-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index d6c9ec6..e366c17 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,7 +17,7 @@ diff --git a/docs/authors.html b/docs/authors.html index cec33c9..549ccbf 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@ @@ -78,15 +78,15 @@Nagler T (2023). +
Nagler T (2024). vinereg: D-Vine Quantile Regression. -R package version 0.9.1, https://tnagler.github.io/vinereg/. +R package version 0.10.0, https://tnagler.github.io/vinereg/.
@Manual{, title = {vinereg: D-Vine Quantile Regression}, author = {Thomas Nagler}, - year = {2023}, - note = {R package version 0.9.1}, + year = {2024}, + note = {R package version 0.10.0}, url = {https://tnagler.github.io/vinereg/}, }diff --git a/docs/index.html b/docs/index.html index 9608640..bbbbf0b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -37,7 +37,7 @@ @@ -87,7 +87,7 @@
An R package for D-vine copula based mean and quantile regression.
# predict mean and median
head(predict(fit, mtcars, alpha = c(NA, 0.5)), 4)
#> mean 0.5
-#> 1 22.39380 22.29866
-#> 2 22.23677 22.08015
-#> 3 25.33841 24.92450
-#> 4 20.33708 20.16153
NEWS.md
+
+ BUG FIX
+unary_function
.BUG FIX
-DEPENDS
-vinereg 0.8.0
BUG FIXES
-This is a maintenance release following an update in -rvinecopulib.
+This is a maintenance release following an update in rvinecopulib.
DEPENDS
-NEW FEATURES
-factor
s are now named with the
-corresponding factor level.factor
s are now named with the corresponding factor level.NEW FEATURES
faster runtimes, especially for parallelized code.
handle discrete variables properly with both parametric and -nonparametric pair-copulas.
handle discrete variables properly with both parametric and nonparametric pair-copulas.
REMOVED FEATURES
uscale
argument.DEPENDS
-BUG FIXES
prevent nan errors in loglik calculation.
allow for empty and bivariate models.
BUG FIXES
-Fix handling of uscale
in
-fitted.vinereg()
.
Fix handling of mult
parameter for pair-copula fits
-in vinereg()
.
Fix handling of uscale
in fitted.vinereg()
.
Fix handling of mult
parameter for pair-copula fits in vinereg()
.
Fix orientation of asymmetric pair-copulas.
DEPENDS
-furrr
and future
packages instead of
-parallel
, doParallel
, and foreach
-for parallelization.furrr
and future
packages instead of parallel
, doParallel
, and foreach
for parallelization.NEW FEATURES
-New plot_effects()
method to show the marginal
-effects of variables.
Allow to predict the mean with
-predict(object, alpha = NA)
.
New plot_effects()
method to show the marginal effects of variables.
Allow to predict the mean with predict(object, alpha = NA)
.
Calculates the conditional density of the response given the covariates.
+cpdf(object, newdata, cores = 1)
an object of class vinereg
.
matrix of response and covariate values for which to compute +the conditional density
integer; the number of cores to use for computations.
# \dontshow{
+set.seed(1)
+# }
+# simulate data
+x <- matrix(rnorm(500), 250, 2)
+y <- x %*% c(1, -2)
+dat <- data.frame(y = y, x = x, z = as.factor(rbinom(250, 2, 0.5)))
+
+# fit vine regression model
+fit <- vinereg(y ~ ., dat)
+
+cpdf(fit, dat)
+#> [1] 7.702229e+00 7.786503e+00 6.770718e+00 3.907868e+00 6.299966e+00
+#> [6] 7.302949e+00 2.162574e-03 7.543265e+00 6.841347e+00 4.088258e+00
+#> [11] 3.748545e+00 5.765243e+00 4.380030e+00 7.250959e+00 4.717733e+00
+#> [16] 7.705719e+00 4.910442e+00 7.637205e+00 5.627719e+00 6.574962e+00
+#> [21] 4.939933e+00 5.565616e+00 6.716775e+00 6.559413e-02 4.983052e+00
+#> [26] 3.859757e+00 1.042508e-01 8.042180e+00 4.002169e+00 4.571622e+00
+#> [31] 1.486020e+00 4.638830e+00 3.127500e+00 5.668684e+00 4.258756e+00
+#> [36] 4.350911e+00 3.832283e+00 4.024594e+00 3.107419e+00 6.023398e+00
+#> [41] 4.469347e+00 7.610951e+00 5.024515e+00 7.476611e+00 7.366826e+00
+#> [46] 7.795914e+00 5.752886e+00 6.558990e+00 5.712558e+00 5.379007e+00
+#> [51] 4.702264e+00 3.138509e+00 3.113534e+00 4.994948e+00 7.133428e+00
+#> [56] 7.825007e+00 7.039635e+00 7.253096e+00 6.488448e+00 7.781031e+00
+#> [61] 4.633483e+00 6.717213e+00 6.480285e+00 5.869497e+00 6.785177e+00
+#> [66] 3.420703e+00 8.210606e+00 2.683296e+00 7.079232e+00 1.105640e+00
+#> [71] 3.161915e+00 7.385288e+00 6.733156e+00 6.865336e-01 7.573989e+00
+#> [76] 7.799372e+00 4.026715e+00 7.159457e+00 6.741621e+00 6.192476e+00
+#> [81] 4.091345e+00 5.263136e+00 5.672809e+00 6.869510e+00 5.666585e+00
+#> [86] 5.938310e+00 8.217052e+00 6.322439e+00 5.568050e+00 6.166252e+00
+#> [91] 5.910217e+00 7.947402e+00 2.180331e+00 5.380805e+00 4.360616e-06
+#> [96] 7.506010e+00 7.819416e+00 5.016344e+00 7.698130e+00 6.848461e+00
+#> [101] 7.273516e+00 5.598446e+00 7.582217e+00 5.087860e+00 7.362124e+00
+#> [106] 7.189107e-01 6.913791e+00 4.191336e+00 6.695376e-01 3.365240e+00
+#> [111] 5.593613e-02 6.418154e+00 7.642081e+00 3.583431e+00 5.019747e+00
+#> [116] 6.130364e+00 5.642868e+00 6.346182e+00 6.812571e+00 6.077757e+00
+#> [121] 3.833449e+00 1.471041e+00 5.216980e+00 5.633811e+00 6.596945e+00
+#> [126] 4.240371e+00 6.987894e+00 5.161893e+00 5.446191e+00 6.531481e+00
+#> [131] 4.902632e+00 6.413921e+00 6.658343e+00 8.151096e+00 3.241175e+00
+#> [136] 8.670457e+00 4.083574e-01 7.690153e+00 9.877669e-01 6.074161e+00
+#> [141] 5.767878e+00 3.800360e+00 7.540807e+00 7.799747e+00 7.520508e+00
+#> [146] 2.508644e+00 8.976693e+00 6.228953e+00 2.808001e+00 8.071260e+00
+#> [151] 3.702673e+00 4.698071e+00 4.076998e+00 4.162422e+00 6.835786e+00
+#> [156] 4.819522e+00 5.827331e+00 4.304387e+00 6.841837e+00 8.188474e+00
+#> [161] 5.812410e+00 5.713034e+00 7.556208e+00 7.061019e+00 3.326674e+00
+#> [166] 1.232830e+00 4.571277e+00 7.977774e+00 6.055875e+00 4.085833e+00
+#> [171] 8.559612e+00 6.402495e+00 4.958564e+00 3.303412e+00 6.355727e+00
+#> [176] 5.005700e+00 2.461110e+00 8.699447e+00 7.360022e+00 7.561845e+00
+#> [181] 3.122473e-01 4.698262e+00 6.744344e+00 8.587991e+00 7.839179e+00
+#> [186] 4.900903e+00 3.577782e+00 6.934802e+00 3.663421e+00 6.996445e+00
+#> [191] 4.435527e+00 3.581656e+00 6.904131e+00 7.838745e+00 8.079613e+00
+#> [196] 1.293565e-01 1.665414e+00 4.160496e+00 6.533835e+00 1.159444e-01
+#> [201] 4.225522e+00 7.639615e+00 8.021576e+00 4.187206e+00 1.918976e-01
+#> [206] 6.817152e+00 7.435194e+00 4.410293e-02 6.733230e+00 7.892006e+00
+#> [211] 4.485881e+00 1.564385e+00 5.865665e+00 7.779485e+00 3.188950e+00
+#> [216] 1.042826e+00 4.314377e+00 7.596939e+00 3.325105e+00 3.807630e+00
+#> [221] 3.300394e+00 5.359272e+00 5.827411e+00 7.239567e+00 7.315356e+00
+#> [226] 3.709037e-01 7.637483e+00 8.079161e+00 3.266893e+00 5.409966e+00
+#> [231] 4.625318e+00 2.628123e+00 3.276293e+00 5.820995e+00 8.451177e-01
+#> [236] 4.520307e-01 4.899131e+00 1.472202e+00 5.567458e-03 6.973750e+00
+#> [241] 6.603349e+00 8.752171e-01 6.970573e+00 7.956458e+00 8.140064e-06
+#> [246] 1.173534e+00 7.801674e+00 5.679846e+00 7.735491e+00 7.084380e+00
+
cll()
Conditional log-likelihood
Conditional PDF