Description Usage Arguments Value Author(s) References See Also Examples
oglmx
is used to estimate models for which the outcome variable is discrete and the mean and/or variance of the underlying latent variable can be modelled as a linear combination of explanatory variables. Standard models such as probit, logit, ordered probit and ordered logit are included in the diverse set of models estimated by the function.
1 2 3 4 5 6 7 8 | oglmx(formulaMEAN, formulaSD=NULL, data, start=NULL, weights=NULL,
link="probit", constantMEAN=TRUE, constantSD=TRUE, beta=NULL,
delta=NULL, threshparam=NULL, analhessian=TRUE,
sdmodel=expression(exp(z)), SameModelMEANSD=FALSE, na.action,
savemodelframe=TRUE, Force=FALSE, robust=FALSE)
oglmx.fit(outcomeMatrix, X, Z, w, beta, delta, threshparam, link, start,
sdmodel, optmeth="maxLik", analhessian, robust)
|
formulaMEAN |
an object of class |
formulaSD |
either |
data |
a data frame containing the variables in the model. |
start |
either |
weights |
either |
link |
specifies a link function for the model to be estimated, accepted values are " |
constantMEAN |
logical. Should an intercept be included in the model of the mean of the latent variable? Can be overwritten and set to |
constantSD |
logical. Should an intercept be included in the model of the variance of the latent variable? Can be overwritten and set to |
beta |
|
delta |
|
threshparam |
|
analhessian |
logical. Indicates whether the analytic Hessian should be calculated and used, default is TRUE, if set to FALSE a finite-difference approximation of the Hessian is used. |
sdmodel |
object of mode “ |
SameModelMEANSD |
logical. Indicates whether the matrix used to model the mean of the latent variable is identical to that used to model the variance. If |
na.action |
a function which indicates what should happen when the data contain NAs. The default is set by the |
savemodelframe |
logical. Indicates whether the model frame(s) should be saved for future use. Default is |
Force |
logical. If set to |
robust |
logical. If set to |
outcomeMatrix, X, Z |
|
w |
|
optmeth |
|
An object of class "oglmx
" with the following components:
link |
link function used in the estimated model. |
sdmodel |
Expression for the model for the standard deviation, default is exp(z). |
call |
the call used to generate the results. |
factorvars |
vector listing factor variables included in the model |
Outcomes |
numeric vector listing the values of the different outcomes. |
NoVarModData |
dataframe. Contains data required to estimate the no information model used in calculation of McFadden's R-squared measure. |
NOutcomes |
the number of distinct outcomes in the response variable. |
Hetero |
logical. If |
formula |
two element list. Each element is an object of type |
modelframes |
If |
BothEq |
Omitted in the case of a homoskedastic model. Dataframe listing variables that are contained in both the mean and variance equations. |
varMeans |
a list containing two numeric vectors. The vectors list the mean values of the variables in the mean and variance equation respectively. Stored for use in a call of |
varBinary |
a list containing two numeric vectors. The vectors indicate whether the variables in the mean and variance equations are binary indicators. Stored for use in a call of |
loglikelihood |
log-likelihood for the estimated model. Includes as attributes the log-likelihood for the constant only model and the number of observations. |
coefficients |
vector of estimated parameters. |
gradient |
numeric vector, the value of the gradient of the log-likelihood function at the obtained parameter vector. Should be approximately equal to zero. |
no.iterations |
number of iterations of maximisation algorithm. |
returnCode |
code returned by the |
hessian |
hessian matrix of the log-likelihood function evaluated at the obtained parameter vector. |
allparams |
a list containing three numeric vectors, the vectors contain the parameters from the mean equation, the variance equation and the threshold parameters respectively. Includes the prespecified and estimated parameters together. |
Est.Parameters |
list containing three logical vectors. Indicates which parameters in the parameter vectors were estimated. |
BHHHhessian |
Omitted if |
Nathan Carroll, nathan.carroll@ur.de
Cameron, A. C. & Trivedi, P. K. (2005) Microeconometrics : methods and applications Cambridge University Press
Wooldridge, J. M. (2002) Econometric analysis of cross section and panel data The MIT Press
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 | # create random sample, three variables, two binary.
set.seed(242)
n<-250
x1<-sample(c(0,1),n,replace=TRUE,prob=c(0.75,0.25))
x2<-vector("numeric",n)
x2[x1==0]<-sample(c(0,1),n-sum(x1==1),replace=TRUE,prob=c(2/3,1/3))
z<-rnorm(n,0.5)
# create latent outcome variable
latenty<-0.5+1.5*x1-0.5*x2+0.5*z+rnorm(n,sd=exp(0.5*x1-0.5*x2))
# observed y has four possible values: -1,0,1,2
# threshold values are: -0.5, 0.5, 1.5.
y<-vector("numeric",n)
y[latenty< -0.5]<--1
y[latenty>= -0.5 & latenty<0.5]<- 0
y[latenty>= 0.5 & latenty<1.5]<- 1
y[latenty>= 1.5]<- 2
dataset<-data.frame(y,x1,x2)
# estimate standard ordered probit
results.oprob<-oglmx(y ~ x1 + x2 + z, data=dataset,link="probit",constantMEAN=FALSE,
constantSD=FALSE,delta=0,threshparam=NULL)
coef(results.oprob) # extract estimated coefficients
summary(results.oprob)
# calculate marginal effects at means
margins.oglmx(results.oprob)
# estimate ordered probit with heteroskedasticity
results.oprobhet<-oglmx(y ~ x1 + x2 + z, ~ x1 + x2, data=dataset, link="probit",
constantMEAN=FALSE, constantSD=FALSE,threshparam=NULL)
summary(results.oprobhet)
library("lmtest")
# likelihood ratio test to compare model with and without heteroskedasticity.
lrtest(results.oprob,results.oprobhet)
# calculate marginal effects at means.
margins.oglmx(results.oprobhet)
# scale of parameter values is meaningless. Suppose instead two of the
# three threshold values were known, then can include constants in the
# mean and standard deviation equation and the scale is meaningful.
results.oprobhet1<-oglmx(y ~ x1 + x2 + z, ~ x1 + x2, data=dataset, link="probit",
constantMEAN=TRUE, constantSD=TRUE,threshparam=c(-0.5,0.5,NA))
summary(results.oprobhet1)
margins.oglmx(results.oprobhet1)
# marginal effects are identical to results.oprobithet, but using the true thresholds
# means the estimated parameters are on the same scale as underlying data.
# can choose any two of the threshold values and get broadly the same result.
results.oprobhet2<-oglmx(y ~ x1 + x2 + z, ~ x1 + x2, data=dataset, link="probit",
constantMEAN=TRUE, constantSD=TRUE,threshparam=c(-0.5,NA,1.5))
summary(results.oprobhet2)
margins.oglmx(results.oprobhet2)
# marginal effects are again identical. Parameter estimates do change.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.