marginal-effects

How to plot marginal effect of an interaction after felm() function

…衆ロ難τιáo~ 提交于 2020-07-07 11:14:28
问题 I ran a regression based on a "giant" panel data with a bunch of unit fixed effects. So I employed function "felm()" from package "lfe". In addition, I have an interaction term of two continuous variables in the regression. But when plotting how the marginal effects of x on y vary with x2, it seems that the objects produced by "felm()" are often incompatible to most plotting functions like "ggplot", "interplot()" and "meplot". But I have to use "felm()" because I need to control for a large

Testing the difference between marginal effects calculated across factors

北慕城南 提交于 2020-02-23 06:55:14
问题 I'm trying to test the difference between two marginal effects. I can get R to calculate the effects, but I can't find any resource explaining how to test their difference. I've looked in the margins documentations and other marginal effects packages but have not been able to find something that tests the difference. data("mtcars") mod<-lm(mpg~as.factor(am)*disp,data=mtcars) (marg<-margins(model = mod,at = list(am = c("0","1")))) at(am) disp am1 0 -0.02758 0.4518 1 -0.05904 0.4518 summary

Testing the difference between marginal effects calculated across factors

孤者浪人 提交于 2020-02-23 06:55:11
问题 I'm trying to test the difference between two marginal effects. I can get R to calculate the effects, but I can't find any resource explaining how to test their difference. I've looked in the margins documentations and other marginal effects packages but have not been able to find something that tests the difference. data("mtcars") mod<-lm(mpg~as.factor(am)*disp,data=mtcars) (marg<-margins(model = mod,at = list(am = c("0","1")))) at(am) disp am1 0 -0.02758 0.4518 1 -0.05904 0.4518 summary

mfxboot function for marginal effects for probit regressions?

放肆的年华 提交于 2020-01-01 06:26:50
问题 Data: Data Code: #function that calculates ‘the average of the sample marginal effects’. mfxboot <- function(modform,dist,data,boot=1000,digits=3){ x <- glm(modform, family=binomial(link=dist),data) # get marginal effects pdf <- ifelse(dist=="probit", mean(dnorm(predict(x, type = "link"))), mean(dlogis(predict(x, type = "link")))) marginal.effects <- pdf*coef(x) # start bootstrap bootvals <- matrix(rep(NA,boot*length(coef(x))), nrow=boot) set.seed(1111) for(i in 1:boot){ samp1 <- data[sample

How to get average marginal effects (AMEs) with standard errors of a multinomial logit model?

核能气质少年 提交于 2019-12-23 22:43:04
问题 I want to get the average marginal effects (AME) of a multinomial logit model with standard errors. For this I've tried different methods, but they haven't led to the goal so far. Best attempt My best attempt was to get the AMEs by hand using mlogit which I show below. library(mlogit) ml.d <- mlogit.data(df1, choice="Y", shape="wide") # shape data for `mlogit()` ml.fit <- mlogit(Y ~ 1 | D + x1 + x2, reflevel="1", data=ml.d) # fit the model # coefficient names c.names <- names(ml.fit$model)[-

R probit regression marginal effects

断了今生、忘了曾经 提交于 2019-12-21 02:48:08
问题 I am using R to replicate a study and obtain mostly the same results the author reported. At one point, however, I calculate marginal effects that seem to be unrealistically small. I would greatly appreciate if you could have a look at my reasoning and the code below and see if I am mistaken at one point or another. My sample contains 24535 observations, the dependent variable "x028bin" is a binary variable taking on the values 0 and 1, and there are furthermore 10 explaining variables. Nine

How can I generate marginal effects for a logit model when using survey weights?

a 夏天 提交于 2019-12-06 03:49:21
问题 I normally generate logit model marginal effects using the mfx package and the logitmfx function. However, the current survey I am using has weights (which have a large effect on the proportion of the DV in the sample because of oversampling in some populations) and logitmfx doesn't appear to have any way to include weights. I have fitted the model with svyglm as follows: library(survey) survey.design <- svydesign(ids = combined.survey$id, weights = combined.survey$weight, data = combined

How can I generate marginal effects for a logit model when using survey weights?

≡放荡痞女 提交于 2019-12-04 07:07:38
I normally generate logit model marginal effects using the mfx package and the logitmfx function. However, the current survey I am using has weights (which have a large effect on the proportion of the DV in the sample because of oversampling in some populations) and logitmfx doesn't appear to have any way to include weights. I have fitted the model with svyglm as follows: library(survey) survey.design <- svydesign(ids = combined.survey$id, weights = combined.survey$weight, data = combined.survey) vote.pred.1 <- svyglm(formula = turnout ~ gender + age.group + education + income, design = survey

Is there a way of getting “marginal effects” from a `glmer` object

无人久伴 提交于 2019-12-03 19:09:03
问题 I am estimating random effects logit model using glmer and I would like to report Marginal Effects for the independent variables. For glm models, package mfx helps compute marginal effects. Is there any package or function for glmer objects? Thanks for your help. A reproducible example is given below mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") mydata$rank <- factor(mydata$rank) #creating ranks id <- rep(1:ceiling(nrow(mydata)/2), times=c(2)) #creating ID variable mydata

R probit regression marginal effects

。_饼干妹妹 提交于 2019-12-03 08:43:10
I am using R to replicate a study and obtain mostly the same results the author reported. At one point, however, I calculate marginal effects that seem to be unrealistically small. I would greatly appreciate if you could have a look at my reasoning and the code below and see if I am mistaken at one point or another. My sample contains 24535 observations, the dependent variable "x028bin" is a binary variable taking on the values 0 and 1, and there are furthermore 10 explaining variables. Nine of those independent variables have numeric levels, the independent variable "f025grouped" is a factor