| Type: | Package |
| Title: | Efficient Bayesian Algorithms for Binary and Categorical DataRegression Models |
| Version: | 0.3.5 |
| Author: | Gregor Zens [aut, cre], Sylvia Frühwirth-Schnatter [aut], Helga Wagner [aut] |
| Maintainer: | Gregor Zens <zens@iiasa.ac.at> |
| Description: | Efficient Bayesian implementations of probit, logit, multinomial logit and binomial logit models. Functions for plotting and tabulating the estimation output are available as well. Estimation is based on Gibbs sampling where the Markov chain Monte Carlo algorithms are based on the latent variable representations and marginal data augmentation algorithms described in "Gregor Zens, Sylvia Frühwirth-Schnatter & Helga Wagner (2023). Ultimate Pólya Gamma Samplers – Efficient MCMC for possibly imbalanced binary and categorical data, Journal of the American Statistical Association <doi:10.1080/01621459.2023.2259030>". |
| Encoding: | UTF-8 |
| License: | GPL-3 |
| Language: | en-US |
| Depends: | R (≥ 3.5.0) |
| Imports: | ggplot2, knitr, matrixStats, mnormt, pgdraw, reshape2, coda,truncnorm |
| LazyData: | true |
| RoxygenNote: | 7.2.1 |
| NeedsCompilation: | no |
| Packaged: | 2024-11-10 14:37:06 UTC; Gregor |
| Repository: | CRAN |
| Date/Publication: | 2024-11-10 17:00:10 UTC |
Efficient MCMC Samplers for Bayesian probit regression and various logistic regression models
Description
UPG estimates Bayesian regression models for binary or categorical outcomes using samplers based on marginal data augmentation.
Usage
UPG(y, X, model, Ni = NULL, baseline = NULL, draws = 1000, burnin = 1000, A0 = 4, B0 = 4, d0 = 2.5, D0 = 1.5, G0 = 100, verbose = TRUE, gamma.boost = TRUE, delta.boost = TRUE, beta.start = NULL)Arguments
y | a binary vector for probit and logit models. A character, factor or numeric vector for multinomial logit models. A numerical vector of the number of successes for the binomial model. |
X | a matrix of explanatory variables including an intercept in the first column. Rows are individuals, columns are variables. |
model | indicates the model to be estimated. |
Ni | a vector containing the number of trials when estimating a binomial logit model. |
baseline | a string that can be used to change the baseline category in MNL models. Default baseline is the most commonly observed category. |
draws | number of saved Gibbs sampler iterations. Default is 1000 for illustration purposes, you should use more when estimating a model (e.g. 10,000). |
burnin | number of burned Gibbs sampler iterations. Default is 1000 for illustration purposes, you should use more when estimating a model (e.g. 2,000). |
A0 | prior variance for the intercept, 4 is the default. |
B0 | prior variance for the coefficients, 4 is the default. |
d0 | prior shape for working parameter delta, 2.5 is the default. |
D0 | prior rate for working parameter delta, 1.5 is the default. |
G0 | prior variance for working parameter gamma, 100 is the default. |
verbose | logical variable indicating whether progress should be printed during estimation. |
gamma.boost | logical variable indicating whether location-based parameter expansion boosting should be used. |
delta.boost | logical variable indicating whether scale-based parameter expansion boosting should be used. |
beta.start | provides starting values for beta (e.g. for use within Gibbs sampler). Baseline coefficients need to be zero for multinomial model. |
Value
Depending on the estimated model,UPG() returns aUPG.Probit,UPG.Logit,UPG.MNL orUPG.Binomial object.
Author(s)
Gregor Zens
See Also
summary.UPG.Probit to summarize aUPG.Probit object and to create tables.predict.UPG.Logit to predict probabilities using aUPG.Logit object.plot.UPG.MNL to plot aUPG.MNL object.
Examples
# load packagelibrary(UPG)# estimate a probit model using example data# warning: use more burn-ins, burnin = 100 is just used for demonstration purposesdata(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit", burnin = 100)# estimate a logit model using example data# warning: use more burn-ins, burnin = 100 is just used for demonstration purposesdata(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit", burnin = 100)# estimate a MNL model using example data# warning: use more burn-ins, burnin = 100 is just used for demonstration purposesdata(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl", burnin = 100)# estimate a binomial logit model using example data# warning: use more burn-ins, burnin = 100 is just used for demonstration purposesdata(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial", burnin = 100)MCMC Diagnostics forUPG.Probit,UPG.Logit,UPG.MNL andUPG.Binomial objects usingcoda
Description
UPG.Diag computes a number of MCMC diagnostics based on the Markov chains that are contained in the model output returned byUPG.
Usage
UPG.Diag(object = NULL)Arguments
object | an object of class |
Value
Returns a list containing effective sample size, effective sampling rate and inefficiency factors for each coefficient. In addition, maximum, minimum and median of these measures are returned.
Author(s)
Gregor Zens
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")# compute MCMC diagnosticsUPG.Diag(results.probit)MCMC Diagnostics forUPG.Binomial objects
Description
UPG.Diag.Binomial computes inefficiency factors, effective sample size and effective sampling rate based on the posterior distributions in aUPG.Binomial object.
Usage
UPG.Diag.Binomial(object = NULL)Arguments
object | an object of class |
Value
Returns a list containing effective sample size, effective sampling rate and inefficiency factors for each coefficient.
Author(s)
Gregor Zens
MCMC Diagnostics forUPG.Logit objects
Description
UPG.Diag.Logit computes inefficiency factors, effective sample size and effective sampling rate based on the posterior distributions in aUPG.Logit object.
Usage
UPG.Diag.Logit(object = NULL)Arguments
object | an object of class |
Value
Returns a list containing effective sample size, effective sampling rate and inefficiency factors for each coefficient.
Author(s)
Gregor Zens
MCMC Diagnostics forUPG.MNL objects
Description
UPG.Diag.MNL computes inefficiency factors, effective sample size and effective sampling rate based on the posterior distributions in aUPG.MNL object.
Usage
UPG.Diag.MNL(object = NULL)Arguments
object | an object of class |
Value
Returns a list containing effective sample size, effective sampling rate and inefficiency factors for each coefficient.
Author(s)
Gregor Zens
MCMC Diagnostics for UPG.Probit objects
Description
UPG.Diag.Probit computes inefficiency factors, effective sample size and effective sampling rate based on the posterior distributions in aUPG.Probit object.
Usage
UPG.Diag.Probit(object = NULL)Arguments
object | an object of class |
Value
Returns a list containing effective sample size, effective sampling rate and inefficiency factors for each coefficient.
Author(s)
Gregor Zens
Extract coefficients from UPG.Binomial objects
Description
coef can be used to extract posterior means and credible intervals based on posterior quantiles fromUPG.Binomial objects.
Usage
## S3 method for class 'UPG.Binomial'coef(object, ..., q = c(0.025, 0.975))Arguments
object | an object of class |
... | other coef parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a matrix containing posterior means and the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.Binomial to summarize aUPG.Binomial object and create tables.predict.UPG.Binomial to predict probabilities using aUPG.Binomial object.plot.UPG.Binomial to plot aUPG.Binomial object.
Examples
# estimate a binomial logit model using example datalibrary(UPG)data(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial")# extract posterior means and credible interval based on 0.025 and 0.975 quantilescoef(results.binomial, q = c(0.025, 0.975))Extract coefficients from UPG.Logit objects
Description
coef can be used to extract posterior means and credible intervals based on posterior quantiles fromUPG.Logit objects.
Usage
## S3 method for class 'UPG.Logit'coef(object, ..., q = c(0.025, 0.975))Arguments
object | an object of class |
... | other coef parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a matrix containing posterior means and the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.Logit to summarize aUPG.Logit object and create tables.predict.UPG.Logit to predict probabilities using aUPG.Logit object.plot.UPG.Logit to plot aUPG.Logit object.
Examples
# estimate a logit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit")# extract posterior means and credible interval based on 0.025 and 0.975 quantilescoef(results.logit, q = c(0.025, 0.975))Extract coefficients from UPG.MNL objects
Description
coef can be used to extract posterior means and credible intervals based on posterior quantiles fromUPG.MNL objects.
Usage
## S3 method for class 'UPG.MNL'coef(object, ..., q = c(0.025, 0.975))Arguments
object | an object of class |
... | other coef parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a list containing posterior means and the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.MNL to summarize aUPG.MNL object and create tables.predict.UPG.MNL to predict probabilities using aUPG.MNL object.plot.UPG.MNL to plot aUPG.MNL object.
Examples
# estimate a multinomial logit model using example datalibrary(UPG)data(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl")# extract posterior means and credible interval based on 0.025 and 0.975 quantilescoef(results.mnl, q = c(0.025, 0.975))Extract coefficients from UPG.Probit objects
Description
coef can be used to extract posterior means and credible intervals based on posterior quantiles fromUPG.Probit objects.
Usage
## S3 method for class 'UPG.Probit'coef(object, ..., q = c(0.025, 0.975))Arguments
object | an object of class |
... | other coef parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a matrix containing posterior means and the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.Probit to summarize aUPG.Probit object and create tables.predict.UPG.Probit to predict probabilities using aUPG.Probit object.plot.UPG.Probit to plot aUPG.Probit object.
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")# extract posterior means and credible interval based on 0.025 and 0.975 quantilescoef(results.probit, q = c(0.025, 0.975))Female labor force participation data.
Description
A dataset containing socio-economic characteristics as well as a laborforce participation dummy for 753 married women from the panel studyof income dynamics.
Usage
lfpFormat
A data frame with 753 rows and 9 variables:
- lfp
binary indicator for participating in the labor force (=1) or not (=0)
- intercept
intercept
- k5
number of children 5 years old or younger
- k618
number of children 6 to 18 years old
- age
age in years
- wc
binary indicator for college education of the wife
- hc
binary indicator for college education of the husband
- lwg
log expected wage rate; for women in the labor force, the actual wage rate; for women not in the labor force, an imputed value based on a regression of
lwgon the other variables- inc
family income exclusive of wife's income
Source
Data taken from 'carData' package. Also known as the 'Mroz' dataset. Mroz, T. A. (1987) The sensitivity of an empirical model of married women's hours of work to economic and statistical assumptions. Econometrica 55, 765-799.
Compute log-likelihoods from UPG.Binomial objects
Description
logLik can be used to compute log-likelihoods fromUPG.Binomial objects. The log-likelihood is based on the posterior mean of the coefficients.
Usage
## S3 method for class 'UPG.Binomial'logLik(object = NULL, ...)Arguments
object | an object of class |
... | other logLik parameters. |
Value
Returns a numeric of classlogLik with attributes containing the number of estimated parameters and the number of observations.
Author(s)
Gregor Zens
See Also
summary.UPG.Binomial to summarize aUPG.Binomial object and create tables.plot.UPG.Binomial to plot aUPG.Binomial object.coef.UPG.Binomial to extract coefficients from aUPG.Binomial object.
Examples
# estimate a binomial logit model using example datalibrary(UPG)data(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial")# extract log-likelihoodll.binomial = logLik(results.binomial)Compute log-likelihoods from UPG.Logit objects
Description
logLik can be used to compute log-likelihoods fromUPG.Logit objects. The log-likelihood is based on the posterior mean of the coefficients.
Usage
## S3 method for class 'UPG.Logit'logLik(object = NULL, ...)Arguments
object | an object of class |
... | other logLik parameters. |
Value
Returns a numeric of classlogLik with attributes containing the number of estimated parameters and the number of observations.
Author(s)
Gregor Zens
See Also
summary.UPG.Logit to summarize aUPG.Logit object and create tables.plot.UPG.Logit to plot aUPG.Logit object.coef.UPG.Logit to extract coefficients from aUPG.Logit object.
Examples
# estimate a logit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit")# extract log-likelihoodll.logit = logLik(results.logit)Compute log-likelihoods from UPG.MNL objects
Description
logLik can be used to compute log-likelihoods fromUPG.MNL objects. The log-likelihood is based on the posterior mean of the coefficients.
Usage
## S3 method for class 'UPG.MNL'logLik(object = NULL, ...)Arguments
object | an object of class |
... | other logLik parameters. |
Value
Returns a numeric of classlogLik with attributes containing the number of estimated parameters and the number of observations.
Author(s)
Gregor Zens
See Also
summary.UPG.MNL to summarize aUPG.MNL object and create tables.plot.UPG.MNL to plot aUPG.MNL object.coef.UPG.MNL to extract coefficients from aUPG.MNL object.
Examples
# estimate a multinomial logit model using example datalibrary(UPG)data(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl")# extract log-likelihoodll.mnl = logLik(results.mnl)Compute log-likelihoods from UPG.Probit objects
Description
logLik can be used to compute log-likelihoods fromUPG.Probit objects. The log-likelihood is based on the posterior mean of the coefficients.
Usage
## S3 method for class 'UPG.Probit'logLik(object = NULL, ...)Arguments
object | an object of class |
... | other logLik parameters. |
Value
Returns a numeric of classlogLik with attributes containing the number of estimated parameters and the number of observations.
Author(s)
Gregor Zens
See Also
summary.UPG.Probit to summarize aUPG.Probit object and create tables.plot.UPG.Probit to plot aUPG.Probit object.coef.UPG.Probit to extract coefficients from aUPG.Probit object.
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")# extract log-likelihoodll.probit = logLik(results.probit)Coefficient plots for UPG.Binomial objects
Description
plot generates plots fromUPG.Binomial objects usingggplot2. Coefficient plots show point estimates for all coefficients as well as their credible intervals.
Usage
## S3 method for class 'UPG.Binomial'plot( x = NULL, ..., sort = FALSE, names = NULL, xlab = NULL, ylab = NULL, q = c(0.025, 0.975), include = NULL)Arguments
x | an object of class |
... | other plot parameters. |
sort | a logical variable indicating whether the plotted coefficients should be sorted according to effect sizes. Default is FALSE. |
names | a character vector indicating names for the variables used in the plots. |
xlab | a character vector of length 1 indicating a title for the x-axis. |
ylab | a character vector of length 1 indicating a title for the y-axis. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
include | can be used to plot only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
Value
Returns a ggplot2 object.
Author(s)
Gregor Zens
See Also
summary.UPG.Binomial to summarize aUPG.Binomial object and create tables.predict.UPG.Binomial to predict probabilities using aUPG.Binomial object.coef.UPG.Binomial to extract coefficients from aUPG.Binomial object.
Examples
# estimate a binomial logit model using example datalibrary(UPG)data(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial")# plot the results and sort coefficients by effect sizeplot(results.binomial, sort = TRUE)# plot only variables 1 and 3 with custom names, credible intervals and axis labelsplot(results.binomial, include = c(1,3), names = c("Custom 1", "Custom 2"), q = c(0.1, 0.9), xlab = c("Custom X"), ylab = c("Custom Y"))Coefficient plots for UPG.Logit objects
Description
plot generates plots fromUPG.Logit objects usingggplot2. Coefficient plots show point estimates for all coefficients as well as their credible intervals.
Usage
## S3 method for class 'UPG.Logit'plot( x = NULL, ..., sort = FALSE, names = NULL, xlab = NULL, ylab = NULL, q = c(0.025, 0.975), include = NULL)Arguments
x | an object of class |
... | other plot parameters. |
sort | a logical variable indicating whether the plotted coefficients should be sorted according to effect sizes. Default is FALSE. |
names | a character vector indicating names for the variables used in the plots. |
xlab | a character vector of length 1 indicating a title for the x-axis. |
ylab | a character vector of length 1 indicating a title for the y-axis. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
include | can be used to plot only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
Value
Returns a ggplot2 object.
Author(s)
Gregor Zens
See Also
summary.UPG.Logit to summarize aUPG.Logit object and create tables.predict.UPG.Logit to predict probabilities using aUPG.Logit object.coef.UPG.Logit to extract coefficients from aUPG.Logit object.
Examples
# estimate a logit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit")# plot the results and sort coefficients by effect sizeplot(results.logit, sort = TRUE)# plot only variables 1 and 3 with custom names, credible intervals and axis labelsplot(results.logit, include = c(1,3), names = c("Custom 1", "Custom 2"), q = c(0.1, 0.9), xlab = c("Custom X"), ylab = c("Custom Y"))Coefficient plots for UPG.MNL objects
Description
plot generates plots fromUPG.MNL objects usingggplot2. Coefficient plots show point estimates for all coefficients in all groups except the baseline as well as their credible intervals.
Usage
## S3 method for class 'UPG.MNL'plot( x = NULL, ..., sort = FALSE, names = NULL, groups = NULL, xlab = NULL, ylab = NULL, q = c(0.025, 0.975), include = NULL)Arguments
x | an object of class |
... | other plot parameters. |
sort | a logical variable indicating whether the plotted coefficients should be sorted according to average effect sizes across groups. Default is FALSE. |
names | a character vector indicating names for the variables used in the plots. |
groups | a character vector indicating names for the groups excluding the baseline. The group names must correspond to the ordering in the dependent variable used for estimation. |
xlab | a character vector of length 1 indicating a title for the x-axis. |
ylab | a character vector of length 1 indicating a title for the y-axis. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
include | can be used to plot only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
Value
Returns a ggplot2 object.
Author(s)
Gregor Zens
See Also
summary.UPG.MNL to summarize aUPG.MNL object and create tables.predict.UPG.MNL to predict probabilities using aUPG.MNL object.coef.UPG.MNL to extract coefficients from aUPG.MNL object.
Examples
# estimate a multinomial logit model using example datalibrary(UPG)data(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl")# plot the results and sort coefficients by average effect sizeplot(results.mnl, sort = TRUE)# plot only variables 1 and 3 with custom group and variable names# also, customize credible intervals and axis labelsplot(results.mnl, include = c(1,3), names = c("Custom 1", "Custom 2"), groups = c("Alpha", "Beta"), q = c(0.1, 0.9), xlab = c("Custom X"), ylab = c("Custom Y"))Coefficient plots for UPG.Probit objects
Description
plot generates plots fromUPG.Probit objects usingggplot2. Coefficient plots show point estimates for all coefficients as well as their credible intervals.
Usage
## S3 method for class 'UPG.Probit'plot( x = NULL, ..., sort = FALSE, names = NULL, xlab = NULL, ylab = NULL, q = c(0.025, 0.975), include = NULL)Arguments
x | an object of class |
... | other plot parameters. |
sort | a logical variable indicating whether the plotted coefficients should be sorted according to effect sizes. Default is FALSE. |
names | a character vector indicating names for the variables used in the plots. |
xlab | a character vector of length 1 indicating a title for the x-axis. |
ylab | a character vector of length 1 indicating a title for the y-axis. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
include | can be used to plot only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
Value
Returns a ggplot2 object.
Author(s)
Gregor Zens
See Also
summary.UPG.Probit to summarize aUPG.Probit object and create tables.predict.UPG.Probit to predict probabilities using aUPG.Probit object.coef.UPG.Probit to extract coefficients from aUPG.Probit object.
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")# plot the results and sort coefficients by effect sizeplot(results.probit, sort = TRUE)# plot only variables 1 and 3 with custom names, credible intervals and axis labelsplot(results.probit, include = c(1, 3), names = c("Custom 1", "Custom 2"), q = c(0.1, 0.9), xlab = c("Custom X"), ylab = c("Custom Y"))Predicted probabilities from UPG.Binomial objects
Description
predict generates predicted probabilities from aUPG.Binomial object. In addition, credible intervals for these probabilities are computed. Probabilities can be predicted from the data used for estimating the model or for a new data set with the same structure.
Usage
## S3 method for class 'UPG.Binomial'predict(object = NULL, ..., newdata = NULL, q = c(0.025, 0.975))Arguments
object | an object of class |
... | other predict parameters. |
newdata | a matrix or a |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a list containing posterior means of predicted probabilities as well as the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.Binomial to summarize aUPG.Binomial object and create tables.plot.UPG.Binomial to plot aUPG.Binomial object.coef.UPG.Binomial to extract coefficients from aUPG.Binomial object.
Examples
# estimate a binomial logit model using example datalibrary(UPG)data(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial")# extract predicted probabilitiespredict(results.binomial)Predicted probabilities from UPG.Logit objects
Description
predict generates predicted probabilities from aUPG.Logit object. In addition, credible intervals for these probabilities are computed. Probabilities can be predicted from the data used for estimating the model or for a new data set with the same structure.
Usage
## S3 method for class 'UPG.Logit'predict(object = NULL, ..., newdata = NULL, q = c(0.025, 0.975))Arguments
object | an object of class |
... | other predict parameters. |
newdata | a matrix or a |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a list containing posterior means of predicted probabilities as well as the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.Logit to summarize aUPG.Logit object and create tables.plot.UPG.Logit to plot aUPG.Logit object.coef.UPG.Logit to extract coefficients from aUPG.Logit object.
Examples
# estimate a logit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit")# extract predicted probabilitiespredict(results.logit)Predicted probabilities from UPG.MNL objects
Description
predict generates predicted probabilities from aUPG.MNL object. In addition, credible intervals for these probabilities are computed. Probabilities can be predicted from the data used for estimating the model or for a new data set with the same structure.
Usage
## S3 method for class 'UPG.MNL'predict(object = NULL, ..., newdata = NULL, q = c(0.025, 0.975))Arguments
object | an object of class |
... | other predict parameters. |
newdata | a matrix or a |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a list containing posterior means of predicted probabilities as well as the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.MNL to summarize aUPG.MNL object and create tables.plot.UPG.MNL to plot aUPG.MNL object.coef.UPG.MNL to extract coefficients from aUPG.MNL object.
Examples
# estimate a multinomial logit model using example datalibrary(UPG)data(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl")# extract predicted probabilitiespredict(results.mnl)Predicted probabilities from UPG.Probit objects
Description
predict generates predicted probabilities from aUPG.Probit object. In addition, credible intervals for these probabilities are computed. Probabilities can be predicted from the data used for estimating the model or for a new data set with the same structure.
Usage
## S3 method for class 'UPG.Probit'predict(object = NULL, ..., newdata = NULL, q = c(0.025, 0.975))Arguments
object | an object of class |
... | other predict parameters. |
newdata | a matrix or a |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
Value
Returns a list containing posterior means of predicted probabilities as well as the desired credible interval.
Author(s)
Gregor Zens
See Also
summary.UPG.Probit to summarize aUPG.Probit object and create tables.plot.UPG.Probit to plot aUPG.Probit object.coef.UPG.Probit to extract coefficients from aUPG.Probit object.
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")# extract predicted probabilitiespredict(results.probit)Print information for UPG.Binomial objects
Description
print provides some basic information about aUPG.Binomial object.
Usage
## S3 method for class 'UPG.Binomial'print(x, ...)Arguments
x | an object of class |
... | other print parameters. |
Author(s)
Gregor Zens
See Also
summary.UPG.Binomial to summarize aUPG.Binomial object and create tables.predict.UPG.Binomial to predict probabilities using aUPG.Binomial object.plot.UPG.Binomial to plot aUPG.Binomial object.
Examples
# estimate a binomial logit model using example datalibrary(UPG)data(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial")print(results.binomial)Print information for UPG.Logit objects
Description
print provides some basic information about aUPG.Logit object.
Usage
## S3 method for class 'UPG.Logit'print(x, ...)Arguments
x | an object of class |
... | other print parameters. |
Author(s)
Gregor Zens
See Also
summary.UPG.Logit to summarize aUPG.Logit object and create tables.predict.UPG.Logit to predict probabilities using aUPG.Logit object.plot.UPG.Logit to plot aUPG.Logit object.
Examples
# estimate a logit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit")print(results.logit)Print information for UPG.MNL objects
Description
print provides some basic information about aUPG.MNL object.
Usage
## S3 method for class 'UPG.MNL'print(x, ...)Arguments
x | an object of class |
... | other print parameters. |
Author(s)
Gregor Zens
See Also
summary.UPG.MNL to summarize aUPG.MNL object and create tables.predict.UPG.MNL to predict probabilities using aUPG.MNL object.plot.UPG.MNL to plot aUPG.MNL object.
Examples
# estimate a multinomial logit model using example datalibrary(UPG)data(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl")print(results.mnl)Print information for UPG.Probit objects
Description
print provides some basic information about aUPG.Probit object.
Usage
## S3 method for class 'UPG.Probit'print(x, ...)Arguments
x | an object of class |
... | other print parameters. |
Author(s)
Gregor Zens
See Also
summary.UPG.Probit to summarize aUPG.Probit object and create tables.predict.UPG.Probit to predict probabilities using aUPG.Probit object.plot.UPG.Probit to plot aUPG.Probit object.
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")print(results.probit)Students program choices.
Description
A dataset containing the choice among general program, vocational program and academic program for 200 high school students as well as some explanatoryvariables.
Usage
programFormat
A data frame with 200 rows and 5 variables:
- program
a vector of program choices
- intercept
an intercept term
- female
binary indicator for female students
- ses
socioeconomic status, 1 is lowest
- write
writing score of student
Source
Original dataset is known as 'hsbdemo' and has been sourced fromhttps://stats.oarc.ucla.edu/stat/data/hsbdemo.dta.
Estimation results and tables for UPG.Binomial objects
Description
summary generates a summary of estimation results forUPG.Binomial objects. Point estimates, estimated standard deviation as well as credible intervals for each variable are tabulated. In addition, an indicator quickly shows whether the credible interval includes zero or not. Moreover, LaTeX, HTML and pandoc tables can be quickly generated viaknitr.
Usage
## S3 method for class 'UPG.Binomial'summary( object = NULL, ..., q = c(0.025, 0.975), names = NULL, digits = 2, include = NULL, table = NULL, cap = NULL)Arguments
object | an object of class |
... | other summary parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
names | a character vector indicating names for the variables used in the output. |
digits | number of digits to be included in output. Last digit will be rounded using |
include | can be used to summarize and tabulate only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
table | can be used to return a LaTeX table ( |
cap | character vector that can be used to specify the table caption. |
Value
Returns aknitr_kable object containing the summary table.
Author(s)
Gregor Zens
See Also
plot.UPG.Binomial to plot aUPG.Binomial object.predict.UPG.Binomial to predict probabilities using aUPG.Binomial object.coef.UPG.Binomial to extract coefficients from aUPG.Binomial object.
Examples
# estimate a binomial logit model using example datalibrary(UPG)data(titanic)y = titanic[,1]Ni = titanic[,2]X = titanic[,-c(1,2)]results.binomial = UPG(y = y, X = X, Ni = Ni, model = "binomial")# basic summary of regression resultssummary(results.binomial)# generate a LaTeX table with subset of variables and custom namessummary(results.binomial, include=c(1,3), names=c("V. kept 1", "V. kept 3"), table="latex")Estimation results and tables for UPG.Logit objects
Description
summary generates a summary of estimation results forUPG.Logit objects. Point estimates, estimated standard deviation as well as credible intervals for each variable are tabulated. In addition, an indicator quickly shows whether the credible interval includes zero or not. Moreover, LaTeX, HTML and pandoc tables can be quickly generated viaknitr.
Usage
## S3 method for class 'UPG.Logit'summary( object = NULL, ..., q = c(0.025, 0.975), names = NULL, digits = 2, include = NULL, table = NULL, cap = NULL)Arguments
object | an object of class |
... | other summary parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
names | a character vector indicating names for the variables used in the output. |
digits | number of digits to be included in output. Last digit will be rounded using |
include | can be used to summarize and tabulate only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
table | can be used to return a LaTeX table ( |
cap | character vector that can be used to specify the table caption. |
Value
Returns aknitr_kable object containing the summary table.
Author(s)
Gregor Zens
See Also
plot.UPG.Logit to plot aUPG.Logit object.predict.UPG.Logit to predict probabilities using aUPG.Logit object.coef.UPG.Logit to extract coefficients from aUPG.Logit object.
Examples
# estimate a logit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.logit = UPG(y = y, X = X, model = "logit")# basic summary of regression resultssummary(results.logit)# generate a LaTeX table with subset of variables and custom namessummary(results.logit, include=c(1,3), names=c("V. kept 1", "V. kept 3"), table="latex")Estimation results and tables for UPG.MNL objects
Description
summary generates a summary of estimation results forUPG.MNL objects. Point estimates, estimated standard deviation as well as credible intervals for each variable are tabulated. In addition, an indicator quickly shows whether the credible interval includes zero or not. Moreover, LaTeX, HTML and pandoc tables can be quickly generated viaknitr.
Usage
## S3 method for class 'UPG.MNL'summary( object = NULL, ..., q = c(0.025, 0.975), groups = NULL, names = NULL, digits = 2, include = NULL, table = NULL, cap = NULL)Arguments
object | an object of class |
... | other summary parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
groups | a character vector indicating names for the groups, excluding the baseline. The group names must correspond to the ordering in the dependent variable used for estimation. |
names | a character vector indicating names for the variables used in the output. |
digits | number of digits to be included in output. Last digit will be rounded using |
include | can be used to summarize and tabulate only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
table | can be used to return a LaTeX table ( |
cap | character vector that can be used to specify the table caption. |
Value
Returns aknitr_kable object containing the summary table.
Author(s)
Gregor Zens
See Also
plot.UPG.MNL to plot aUPG.MNL object.predict.UPG.MNL to predict probabilities using aUPG.MNL object.coef.UPG.MNL to extract coefficients from aUPG.MNL object.
Examples
# estimate a multinomial logit model using example datalibrary(UPG)data(program)y = program[,1]X = program[,-1]results.mnl = UPG(y = y, X = X, model = "mnl")# basic summary of regression resultssummary(results.mnl)# generate a LaTeX table with subset of variables and custom namessummary(results.mnl, include=c(1,3), groups=c("Alpha","Beta"), names=c("V. kept 1", "V. kept 3"), table="latex")Estimation result summary and tables for UPG.Probit objects
Description
summary generates a summary of estimation results forUPG.Probit objects. Point estimates, estimated standard deviation as well as credible intervals for each variable are tabulated. In addition, an indicator quickly shows whether the credible interval includes zero or not. Moreover, LaTeX, HTML and pandoc tables can be quickly generated viaknitr.
Usage
## S3 method for class 'UPG.Probit'summary( object = NULL, ..., q = c(0.025, 0.975), names = NULL, digits = 2, include = NULL, table = NULL, cap = NULL)Arguments
object | an object of class |
... | other summary parameters. |
q | a numerical vector of length two providing the posterior quantiles to be extracted. Default are 0.025 and 0.975 quantiles. |
names | a character vector indicating names for the variables used in the output. |
digits | number of digits to be included in output. Last digit will be rounded using |
include | can be used to summarize and tabulate only a subset of variables. Specify the columns of X that should be kept in the plot. See examples for further information. |
table | can be used to return a LaTeX table ( |
cap | character vector that can be used to specify the table caption. |
Value
Returns aknitr_kable object containing the summary table.
Author(s)
Gregor Zens
See Also
plot.UPG.Probit to plot aUPG.Probit object.predict.UPG.Probit to predict probabilities using aUPG.Probit object.coef.UPG.Probit to extract coefficients from aUPG.Probit object.
Examples
# estimate a probit model using example datalibrary(UPG)data(lfp)y = lfp[,1]X = lfp[,-1]results.probit = UPG(y = y, X = X, model = "probit")# basic summary of regression resultssummary(results.probit)# generate a LaTeX table with subset of variables and custom namessummary(results.probit, include=c(1,3), names=c("V. kept 1", "V. kept 3"), table="latex")Grouped Titanic survival data.
Description
A dataset containing the number of survivals and the total number of persons bypassenger class, age group and gender.
Usage
titanicFormat
A data frame with 78 rows and 6 variables:
- survived
number of passengers that survived
- total
number of total passengers
- intercept
an intercept term
- pclass
passenger class (3 is lowest)
- female
binary indicator for female passenger groups
- age.group
age group indicator (0-5yrs, 5-10yrs, ...)
Source
Data originally sourced fromhttps://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv. See alsohttps://towardsdatascience.com/the-binomial-regression-model-everything-you-need-to-know-5216f1a483d3.