Re: [R] NLME: Problem with plotting ranef vs a factor

2006-08-08 Thread Spencer Graves
  Your question is entirely too complex for me to try to answer in a 
reasonable amount of time, especially since your example in not self 
contained.

  If you would still like help on this, I suggest you try to generate a 
self contained example that is as simple as you can make it that 
illustrates your problem, as suggested in the posting guide 
www.R-project.org/posting-guide.html.  With only a modest amount of 
luck, the things you try to simplify your example will lead to 
enlightenment.  If that fails, please submit another question that is 
self contained, simple and clear.  Doing so should substantially 
increase your chances of getting a quick, useful reply.

  I know this doesn't answer your question, but I hope it helps.

  Spencer Graves

Greg Distiller wrote:
 Hi
 I am following the model building strategy that is outlined in the Pinheiro 
 and Bates book wrt including covariates but am having a problem with the 
 plot. Basically I am using 4 covariates (1 of them is continuous) and 3 of 
 them are fine but the 4th one is being shown as a scatterplot despite the 
 fact that it is a factor. I have explicitly declared this to be a factor 
 (pcat-as.factor(pcat)) and have also checked by using the is.factor and 
 the levels command that it is a factor. Yet despite this the plot command 
 is not recognising it as a factor.
  
 Here is more information about my problem:
 
 I am reading in the data by:
 
 Data-read.csv(Data1_93_2.csv,header=T)
 attach(Data)
 Data1_93-transform(Data,log2game=log2(gamedens+1))
 pcat-as.factor(pcat)
 Data1_93-groupedData(log2game ~ day | subjectno, data=Data1_93)
 detach(Data)
 
 Here is the code to check that the covariate called pcat is indeed a factor:
 levels(pcat)
 [1] 1 2 3
 
 is.factor(pcat)
 [1] TRUE
 
 and then after the model is fitted I extract the random effects:
 
 D1C2.ran - ranef(mod11.103nlme,augFrame=T)
 
 and here is an extract from the object:
 
 C R  day   gamedens pcat   site   
 mutcat1  pdens0  log2game
 NA02_259 -1.016987007  0.0162825099 15.75000   23.51   Namaacha 
 Mixed   15018  3.761099
 NA02_073 -0.939355374  0.0132589702 10.5   23.750001   Namaacha 
 Resistant6170  3.675543
 M00_12   -0.775048474  0.0047124742 10.5   25.01 Mpumulanga 
 Sensitive   17525  3.768326
 M00_93   -0.555801118  0.0053872868 14.0   37.52 Mpumulanga 
 Sensitive  332000  4.254319
 NA02_053 -0.327990343 -0.0037659864  6.0   39.250001   Namaacha 
 Resistant   65529  4.292481
 
 Note that this output also seems to indicate that pcat is a factor as it is 
 summarised correctly.
 
 I then generate plots for my random effects:
 
 plot(D1C2.ran,form= C ~site+mutcat2+pcat+pdens0)
 
 and the problem is that the panel for my random effects vs pcat is displayed 
 as a scatterplot rather than as a boxplot.
 I am getting told to check warnings and these warnings look like:
 
 Warning messages:
 1: at  0.99
 2: radius  0.0001
 3: all data on boundary of neighborhood. make span bigger
 4: pseudoinverse used at 0.99
 5: neighborhood radius 0.01
 6: reciprocal condition number  -1.#IND
 7: zero-width neighborhood. make span bigger
 
 I do not get these warnings if I exclude the problematic variable pcat so 
 must be something to do with this. Any ideas?
 
 Many thanks
 
 Greg
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch 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.

__
R-help@stat.math.ethz.ch 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.


[R] NLME: Problem with plotting ranef vs a factor

2006-08-03 Thread Greg Distiller
Hi
I am following the model building strategy that is outlined in the Pinheiro and 
Bates book wrt including covariates but am having a problem with the plot. 
Basically I am using 4 covariates (1 of them is continuous) and 3 of them are 
fine but the 4th one is being shown as a scatterplot despite the fact that it 
is a factor. I have explicitly declared this to be a factor 
(pcat-as.factor(pcat)) and have also checked by using the is.factor and the 
levels command that it is a factor. Yet despite this the plot command is not 
recognising it as a factor.
 
Here is more information about my problem:

I am reading in the data by:

Data-read.csv(Data1_93_2.csv,header=T)
attach(Data)
Data1_93-transform(Data,log2game=log2(gamedens+1))
pcat-as.factor(pcat)
Data1_93-groupedData(log2game ~ day | subjectno, data=Data1_93)
detach(Data)

Here is the code to check that the covariate called pcat is indeed a factor:
 levels(pcat)
[1] 1 2 3

 is.factor(pcat)
[1] TRUE

and then after the model is fitted I extract the random effects:

D1C2.ran - ranef(mod11.103nlme,augFrame=T)

and here is an extract from the object:

C R  day   gamedens pcat   site   
mutcat1  pdens0  log2game
NA02_259 -1.016987007  0.0162825099 15.75000   23.51   Namaacha 
Mixed   15018  3.761099
NA02_073 -0.939355374  0.0132589702 10.5   23.750001   Namaacha 
Resistant6170  3.675543
M00_12   -0.775048474  0.0047124742 10.5   25.01 Mpumulanga 
Sensitive   17525  3.768326
M00_93   -0.555801118  0.0053872868 14.0   37.52 Mpumulanga 
Sensitive  332000  4.254319
NA02_053 -0.327990343 -0.0037659864  6.0   39.250001   Namaacha 
Resistant   65529  4.292481

Note that this output also seems to indicate that pcat is a factor as it is 
summarised correctly.

I then generate plots for my random effects:

plot(D1C2.ran,form= C ~site+mutcat2+pcat+pdens0)

and the problem is that the panel for my random effects vs pcat is displayed as 
a scatterplot rather than as a boxplot.
I am getting told to check warnings and these warnings look like:

Warning messages:
1: at  0.99
2: radius  0.0001
3: all data on boundary of neighborhood. make span bigger
4: pseudoinverse used at 0.99
5: neighborhood radius 0.01
6: reciprocal condition number  -1.#IND
7: zero-width neighborhood. make span bigger

I do not get these warnings if I exclude the problematic variable pcat so must 
be something to do with this. Any ideas?

Many thanks

Greg

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] NLME: Problem with plotting ranef vs a factor

2006-08-03 Thread Dirk Enzmann
Greg,

be careful using attach() and detach(). From the syntax snippets you 
showed it seems that you did create an object pcat (factor 
variable), but you did not change the respective variable in your 
data frame.

Try to remove pcat and see what happens do the results of lme()!

Dirk

__
R-help@stat.math.ethz.ch 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.