Skip to content

fixed, random effects with variable weights

2 messages · Raphael Schoenle, Spencer Graves

3 days later
#
I don't have STATA and your example is not sufficiently complete for 
me to replicate anything.  However, my approach to that kind of thing is 
to try to find the absolute simplest possible example I can think and 
work with that.  I have on occasion programmed such simple examples in 
Excel;  if I get the same answers from Excel and R, I have reasonable 
confidence that I know that R (or STATA) is doing.

	  Beyond that, you have a great advantage with R in that the source 
code is available:  To see the R source, type the name of the function 
at a command prompt.  If I do that with "lme", I get the following:

 > lme
function (fixed, data = sys.frame(sys.parent()), random, correlation = 
NULL,
     weights = NULL, subset, method = c("REML", "ML"), na.action = na.fail,
     control = list(), contrasts = NULL)
UseMethod("lme")

	  This is not too helpful by itself.  To get further, I use "methods":

 > methods("lme")
[1] lme.formula      lme.groupedData* lme.lmList

	  Your "fixed" argument appears to have class "formula".  In that case, 
"lme.formula" is the function you want.  Typing this at a command prompt 
gives you the code.  You can then copy that into a script file, print it 
out, and walk through it line by line to make sure you understand what 
it does.  A walk-through like this can be facilitated by using "degug", 
which you can invoke as follows:

debug(lme.formula)
regsc<-lme(dsc~dcomp+dperc,random=~1|ind7090)

	  The "debug" documentation describes how to use it to walk line by 
line through the function flagged for debugging.  You can query the 
status of any variable at any point, change variables, etc.

	  Hope this helps.
	  spencer graves
Raphael Schoenle wrote: