Re: [R] equivalent of stata command in R‏‏

2010-06-09 Thread Joris Meys
If you don't know how to proceed, you should look for a good book on
statistics. I checked the .nlcom, and what it does is give estimates
and tests on a (nonlinear) combination of estimated parameters. That's
doable, but a bit tedious to program. It is basically using the rules
on the adding and multiplication of random variables and standard
errors. but the interpretation is also not that straightforward.

In the generalized mixed model world, the appropriate way of
estimating the marginal effects you're looking for (I guess...) is
centering your data around the mean before fitting the model. That
way, the parameter of the main effect represent exactly the marginal
effect at the sample mean for the other variables, simply because the
mean is 0 for all of them and the equation you use simplifies to
_b[eco]. Yet, the test statistic only gives you an idea about whether
or not this coefficient differs from zero, assuming it is normally
distributed with se as calculated. That is not the same as testing
whether there is a significant marginal effect.

Marginal effects are in my opinion better tested using likelihood
ratio methods. These are not provided in plm, as that one is based on
generalized least squares and hence does not return a likelihood
value. To use LR tests, you'll have to go to nlme or lme4.

Following is an obligatory read if you're going to use plm methods :
http://cran.r-project.org/web/packages/plm/vignettes/plm.pdf

Maybe you better contact the maintainer of the package
yves.croiss...@let.ish-lyon.cnrs.fr directly to ask for the correct
testing procedure for your hypothesis, because I'm still not sure that
you're doing the fitting correctly in R. Just like you specify fe
i(stno) in Stata, you should specify index=stno in the R command.

Cheers
Joris

On Wed, Jun 9, 2010 at 1:27 PM, mike mick  wrote:

>
> Thanx for your response,
> yeah, i know i didnst specified the indexes
> when i wrote the 2nd mail, in fact in the 1st mail i wrote already that
> i dont have problem with the estimation of the model... thats the
> reason why i didnt write in fact since the issue is not to estimate the
> model but to get the marginal effect,
> anyway, i figured out that predict(), doesnt work for panel data...
> and
> well, my problem is that contrary to your guess, i couldnt figure out
> the rest of the calculations... since i am not that experienced in R.
> one last help of yours would be quite helpful to get rid of this silly 
> problem!
> Thanx again...
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] equivalent of stata command in R‏‏

2010-06-09 Thread mike mick






Thanx for your response,
yeah, i know i didnst specified the indexes
when i wrote the 2nd mail, in fact in the 1st mail i wrote already that
i dont have problem with the estimation of the model... thats the
reason why i didnt write in fact since the issue is not to estimate the
model but to get the marginal effect,
anyway, i figured out that predict(), doesnt work for panel data...
and
well, my problem is that contrary to your guess, i couldnt figure out
the rest of the calculations... since i am not that experienced in R.
one last help of yours would be quite helpful to get rid of this silly problem!
Thanx again...


> Date: Wed, 9 Jun 2010 12:40:42 +0200
> Subject: Re: [R] equivalent of stata command in R‏
> From: jorism...@gmail.com
> To: saint-fi...@hotmail.com
> CC: r-help@r-project.org
> 
> plm does not have a predict function, so forget my former mail. To get
> to the coefficients, you just  :
> coef(mdl)
> 
> The rest of the calculations you can figure out I guess.
> 
> I'm also not sure if you're doing what you think you're doing. You
> never specified the index stno in your pml call. Read the help files
> again. And while you're at it, read the posting guide for the list as
> well:
> http://www.R-project.org/posting-guide.html
> 
> Cheers
> Joris
> 
> 
> On Wed, Jun 9, 2010 at 11:54 AM, mike mick  wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> > From: saint-fi...@hotmail.com
> > To: saint-fi...@hotmail.com
> > Subject: RE:
> > Date: Wed, 9 Jun 2010 09:53:20 +
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > OK! sorry thats my fault,
> >
> > here the translations of the stata commands
> > 1st step is to get the mean values of the variables, well that doesnt need 
> > explanation i guess,
> >
> > 2nd step is to estimate the model on panel data estimation method
> > which is:
> > mdl<-plm(lnLP~lnC+lnL+lnM+lnE+Eco+Inno+Eco*Inno+Eco*lnM+Eco*lnE+year,data=newdata,model="within")
>
> and basically i need to get the marginal effect of variable "Eco"
at the sample mean (step 3) but i am not that good in R so any
additional help is wlcome!
> > Thanks
> > From: saint-fi...@hotmail.com
> > To: r-help@r-project.org
> > Subject:
> > Date: Wed, 9 Jun 2010 09:45:16 +
> >
> >
> >
> >
> >
> >
> >
> > It helps if you translate the Stata commands. Not everybody is fluent
> > in those. It would even help more if you would enlight us about the
> > function you used to fit the model. Getting the marginal effects is
> > not that hard at all, but how depends a bit on the function you used
> > to estimate the model.
> >
> > You can try
> > predict(your_model,type="terms",terms="the_term_you're_interested_in")
> >
> > For exact information, look at the respective predict function, eg if
> > you use lme, do ?predict.lme
> > Be aware of the fact that R normally choses the correct predict
> > function without you having to specify it. predict() works for most
> > model objects. Yet, depending on the model eacht predict function can
> > have different options or different functionality. That information is
> > in the help files of the specific function.
> >
> > Cheers
> > Joris
> >
> > Dear all,
> >
>
> I need to use R for one estimation, and i have readily available
 stata command, but i need also the R version of the same command.
> > the estimation in stata is as following:
> >   1. Compute mean values of relevant variables
> >
> >
> >
> > . sum inno lnE lnM
> >
> >
> >
> >Variable |   ObsMeanStd. Dev.   MinMax
> >
> > -+
> >
> >inno |146574.0880374.2833503  0  1
> >
> > lnE |146353.92562391.732912  -4.473922   10.51298
> >
> > lnM |1462094.2819031.862192  -4.847253   13.71969
> >
> >
> >
> >2. Estimate model
> >
> >
> >
> > . xi: xtreg lnLP lnC lnL lnE lnM eco inno eco_inno eco_lnE eco_lnM i.year, 
> > fe i(stno)
> >
> > i.year_Iyear_1997-1999(naturally coded; _Iyear_1997 omitted)
> >
> >
> >
> > Fixed-effects (within) regression   Number of obs  =
> > 146167
> >
> > Group variable (i): stnoNumber of groups   = 
> > 48855
> >
> >
> >
> > R-sq:  within  = 0.9908 Obs per group: min =
> >  1
> >
> >   between = 0.9122avg =   
> > 3.0
> >
> >   overall = 0.9635max = 
> > 3
> >
> >
> >
> >F(11,97301)= 
> > 949024.29
> >
> > corr(u_i, Xb)  = 0.2166 Prob > F   =
> > 0.
> >
> >
> >
> > --
> >
> >lnLP |  Coef.   Std. Err.  tP>|t| [95% Conf. 
> > Interval]
> >
> > -+
> >
> > lnC |   .