Fixed Effects in betareg - r

I am currently working with 20+ years panel data and upon implementing a standard linear fixed effects model I realized that there was some considerable non-linearity towards the boundary. As I am working with data on the Gini coefficient I implemented a beta regression.
There is definitely a need to include fixed effects but I am not entirely sure how to do this in a beta regression framework as implemented through the betareg package in R. Is it unproblematic to simply include individual dummies in the regression?

Related

Multilevel mixed-effects tobit regression in R

I have a dataset with data left censored and I wanted to apply a multilevel mixed-effects tobit regression, but I only find information about how to do it in Stata. Is it possible to do it in R?
I found the packages 'VGAM' and 'CensREG', but I don't get how to add fixed and random effects.
Also my data is log-normal distributed, is there a way to add this to the model?
Thanks!
According to Section 3.5 of a vignette, the censReg package can handle a mixed model if the data are prepared properly via the plm package.
This Cross Validated page shows an example.
I don't have experience with this; it might only work with formal panel data rather than more general random-effects structures.
If your data are truly log-normal, you could take logs first and set the lower censoring limit on the log scale. Note that an apparent log-normal distribution of outcomes might just represent a corresponding distribution of predictor values with an underlying normal error distribution around the predictions. Don't jump blindly into a log-normal assumption.

How to calculate marginal effects for plm models

I wish to obtain marginal effects for covariates that are in my plm models in first differences with interacted variables. For my lm and glm models I am using the margins package and its functions. However, this method does not seem to work with panel models.
What alternatives do I have?
Thank you.
EDIT:
In the absence of any viable solution I would calculate by hand the marginal effects at specific values of the relevant covariables. Ideally I would like to do so in a faster way.

Does first-difference work on unbalanced data with holes in plm?

On page 423 in Computational Laboratory for Economics, it is stated that "the argument model="fd" doesn't work correctly, with the current version (1.3-1) of plm, on unbalanced data with holes." Has this been fixed in the newer versions of plm?
As a workaround, the author used diff to obtain the first differences and fitted a model="pooling"on the differenced data. Can someone explain how the diff function works on unbalanced data with holes?
Also, on page 68 in the plm documenation version (1.6-5), it is stated that
"plm is a general function for the estimation of linear panel models. It supports the following estimation methods: pooled OLS (model = "pooling"), fixed effects ("within"), random effects ("random"), first–differences ("fd"), and between ("between"). It supports unbalanced panels and two–way effects (although not with all methods)."

Handling ceiling effect of dependent variable in mixed models (R lmer)

I would like to ask around who has any experience with handling ceiling effects of the dependent variable in linear mixed effects models. I found this paper here suggesting results for models outside mixed modeling ( https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2778494/ ) but it would be very convenient to find options within the lme4 (lmer) package in R. Any ideas? Can this problem be solved with generalized mixed models by adjusting the link function? How?

Goodness of fit functions in R

What functions do you use in R to fit a curve to your data and test how well that curve fits? What results are considered good?
Just the first part of that question can fill entire books. Just some quick choices:
lm() for standard linear models
glm() for generalised linear models (eg for logistic regression)
rlm() from package MASS for robust linear models
lmrob() from package robustbase for robust linear models
loess() for non-linear / non-parametric models
Then there are domain-specific models as e.g. time series, micro-econometrics, mixed-effects and much more. Several of the Task Views as e.g. Econometrics discuss this in more detail. As for goodness of fit, that is also something one can spend easily an entire book discussing.
The workhorses of canonical curve fitting in R are lm(), glm() and nls(). To me, goodness-of-fit is a subproblem in the larger problem of model selection. Infact, using goodness-of-fit incorrectly (e.g., via stepwise regression) can give rise to seriously misspecified model (see Harrell's book on "Regression Modeling Strategies"). Rather than discussing the issue from scratch, I recommend Harrell's book for lm and glm. Venables and Ripley's bible is terse, but still worth a reading. "Extending the Linear Model with R" by Faraway is comprehensive and readable. nls is not covered in these sources, but "Nonlinear Regression with R" by Ritz & Streibig fills the gap and is very hands-on.
The nls() function (http://sekhon.berkeley.edu/stats/html/nls.html) is pretty standard for nonlinear least-squares curve fitting. Chi squared (the sum of the squared residuals) is the metric that is optimized in that case, but it is not normalized so you can't readily use it to determine how good the fit is. The main thing you should ensure is that your residuals are normally distributed. Unfortunately I'm not sure of an automated way to do that.
The Quick R site has a reasonable good summary of basic functions used for fitting models and testing the fits, along with sample R code:
http://www.statmethods.net/stats/regression.html
The main thing you should ensure is
that your residuals are normally
distributed. Unfortunately I'm not
sure of an automated way to do that.
qqnorm() could probably be modified to find the correlation between the sample quantiles and the theoretical quantiles. Essentially, this would just be a numerical interpretation of the normal quantile plot. Perhaps providing several values of the correlation coefficient for different ranges of quantiles could be useful. For example, if the correlation coefficient is close to 1 for the middle 97% of the data and much lower at the tails, this tells us the distribution of residuals is approximately normal, with some funniness going on in the tails.
Best to keep simple, and see if linear methods work "well enuff". You can judge your goodness of fit GENERALLY by looking at the R squared AND F statistic, together, never separate. Adding variables to your model that have no bearing on your dependant variable can increase R2, so you must also consider F statistic.
You should also compare your model to other nested, or more simpler, models. Do this using log liklihood ratio test, so long as dependant variables are the same.
Jarque–Bera test is good for testing the normality of the residual distribution.

Resources