In this question, we consider a way to select a code variable in a probit model with limit effects (either directly or by calling some previously existing package).
I conduct a small probit regression of the effects of free and commercial availability of films at the level of piracy of these films in the form of a blog related to the TLAPD post .
A simple way to start broken through in R usually goes through glm, that is:
probit <- glm(y ~ x1 + x2, data=data, family =binomial(link = "probit"))
but this is problematic for interpretation, since it does not produce marginal effects.
As a rule, if I want to use the marginal effects of a regression probit, I define this function (I do not remember the original source, but this is a popular function that is repeatedly republished):
mfxboot <- function(modform,dist,data,boot=500,digits=3){
x <- glm(modform, family=binomial(link=dist),data)
pdf <- ifelse(dist=="probit",
mean(dnorm(predict(x, type = "link"))),
mean(dlogis(predict(x, type = "link"))))
marginal.effects <- pdf*coef(x)
bootvals <- matrix(rep(NA,boot*length(coef(x))), nrow=boot)
set.seed(1111)
for(i in 1:boot){
samp1 <- data[sample(1:dim(data)[1],replace=T,dim(data)[1]),]
x1 <- glm(modform, family=binomial(link=dist),samp1)
pdf1 <- ifelse(dist=="probit",
mean(dnorm(predict(x, type = "link"))),
mean(dlogis(predict(x, type = "link"))))
bootvals[i,] <- pdf1*coef(x1)
}
res <- cbind(marginal.effects,apply(bootvals,2,sd),marginal.effects/apply(bootvals,2,sd))
if(names(x$coefficients[1])=="(Intercept)"){
res1 <- res[2:nrow(res),]
res2 <- matrix(as.numeric(sprintf(paste("%.",paste(digits,"f",sep=""),sep=""),res1)),nrow=dim(res1)[1])
rownames(res2) <- rownames(res1)
} else {
res2 <- matrix(as.numeric(sprintf(paste("%.",paste(digits,"f",sep=""),sep="")),nrow=dim(res)[1]))
rownames(res2) <- rownames(res)
}
colnames(res2) <- c("marginal.effect","standard.error","z.ratio")
return(res2)
}
:
mfxboot(modform = "y ~ x1 + x2",
dist = "probit",
data = piracy)
, , , forward, backward, stepwise ..
? R, , ? mfxboot ?
!